From 2958bcc6c283bbdcc5216f3873b5fe256aac104a Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 23 Feb 2017 19:23:10 -0800 Subject: [PATCH] compiler.h: correctly handle HAVE_DECL_*, test HAVE_DECL_STRNLEN HAVE_DECL_* are 0/1 not ifdef; use HAVE_DECL_STRNLEN to see if we need to declare this, lest stdlib/strnlen.c fails to compile. Signed-off-by: H. Peter Anvin --- include/compiler.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/include/compiler.h b/include/compiler.h index 065ff214..e9a8de22 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -104,7 +104,7 @@ int vsnprintf(char *, size_t, const char *, va_list); # endif #endif -#if !defined(HAVE_STRLCPY) || !defined(HAVE_DECL_STRLCPY) +#if !defined(HAVE_STRLCPY) || !HAVE_DECL_STRLCPY size_t strlcpy(char *, const char *, size_t); #endif @@ -136,26 +136,30 @@ typedef enum bool { false, true } bool; #endif /* Some misguided platforms hide the defs for these */ -#if defined(HAVE_STRCASECMP) && !defined(HAVE_DECL_STRCASECMP) +#if defined(HAVE_STRCASECMP) && !HAVE_DECL_STRCASECMP int strcasecmp(const char *, const char *); #endif -#if defined(HAVE_STRICMP) && !defined(HAVE_DECL_STRICMP) +#if defined(HAVE_STRICMP) && !HAVE_DECL_STRICMP int stricmp(const char *, const char *); #endif -#if defined(HAVE_STRNCASECMP) && !defined(HAVE_DECL_STRNCASECMP) +#if defined(HAVE_STRNCASECMP) && !HAVE_DECL_STRNCASECMP int strncasecmp(const char *, const char *, size_t); #endif -#if defined(HAVE_STRNICMP) && !defined(HAVE_DECL_STRNICMP) +#if defined(HAVE_STRNICMP) && !HAVE_DECL_STRNICMP int strnicmp(const char *, const char *, size_t); #endif -#if defined(HAVE_STRSEP) && !defined(HAVE_DECL_STRSEP) +#if defined(HAVE_STRSEP) && !HAVE_DECL_STRSEP char *strsep(char **, const char *); #endif +#if !HAVE_DECL_STRNLEN +size_t strnlen(const char *s, size_t maxlen); +#endif + /* * Define this to 1 for faster performance if this is a littleendian * platform which can do unaligned memory references. It is safe