mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-04-28 10:53:40 +00:00
check for and use C library provided strlcpy and strlcat
The musl-libc library provides implementations of strlcpy and strlcat, so introduce a feature check for it and only use the kvmtool implementation if there is no library support for it. This avoids clashes with the public definition. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com>
This commit is contained in:
committed by
Will Deacon
parent
52c22e6e64
commit
8f22adc423
5
Makefile
5
Makefile
@@ -199,6 +199,11 @@ endif
|
||||
# On a given system, some libs may link statically, some may not; so, check
|
||||
# both and only build those that link!
|
||||
|
||||
ifeq ($(call try-build,$(SOURCE_STRLCPY),$(CFLAGS),),y)
|
||||
CFLAGS_DYNOPT += -DHAVE_STRLCPY
|
||||
CFLAGS_STATOPT += -DHAVE_STRLCPY
|
||||
endif
|
||||
|
||||
ifeq ($(call try-build,$(SOURCE_BFD),$(CFLAGS),-lbfd -static),y)
|
||||
CFLAGS_STATOPT += -DCONFIG_HAS_BFD
|
||||
OBJS_STATOPT += symbol.o
|
||||
|
||||
@@ -196,3 +196,13 @@ int main(void)
|
||||
return 0;
|
||||
}
|
||||
endef
|
||||
|
||||
define SOURCE_STRLCPY
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
strlcpy(NULL, NULL, 0);
|
||||
return 0;
|
||||
}
|
||||
endef
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
|
||||
int prefixcmp(const char *str, const char *prefix);
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
extern size_t strlcat(char *dest, const char *src, size_t count);
|
||||
extern size_t strlcpy(char *dest, const char *src, size_t size);
|
||||
#endif
|
||||
|
||||
/* some inline functions */
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ int prefixcmp(const char *str, const char *prefix)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef HAVE_STRLCPY
|
||||
/**
|
||||
* strlcat - Append a length-limited, %NUL-terminated string to another
|
||||
* @dest: The string to be appended to
|
||||
@@ -60,3 +61,4 @@ size_t strlcpy(char *dest, const char *src, size_t size)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user