From a4cc953911a745d6e769a03cbe6442ee2fc27cbd Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Wed, 29 Oct 2014 15:44:36 -0500 Subject: Improve and simplify function and header detection logic. Simplify autoconf checks by using AC_CHECK_FUNCS/HEADERS. Clarify some ambiguous dependencies around strnlen/strndup. Unconditionally enable pidwraptest for all arc4random implementations. Remove HAVE_VASPRINTF conditional, since asprintf requires vasprintf. ok @doug --- include/stdio.h | 2 +- include/stdlib.h | 6 +++--- include/string.h | 17 +++++++++-------- include/unistd.h | 4 ++-- 4 files changed, 15 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/stdio.h b/include/stdio.h index fffa170..4a40f6a 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -3,7 +3,7 @@ #ifndef LIBCRYPTOCOMPAT_STDIO_H #define LIBCRYPTOCOMPAT_STDIO_H -#ifdef NO_ASPRINTF +#ifndef HAVE_ASPRINTF #include int vasprintf(char **str, const char *fmt, va_list ap); int asprintf(char **str, const char *fmt, ...); diff --git a/include/stdlib.h b/include/stdlib.h index c314f38..1a1cb6c 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -7,16 +7,16 @@ #include #include -#ifdef NO_ARC4RANDOM_BUF +#ifndef HAVE_ARC4RANDOM_BUF uint32_t arc4random(void); void arc4random_buf(void *_buf, size_t n); #endif -#ifdef NO_REALLOCARRAY +#ifndef HAVE_REALLOCARRAY void *reallocarray(void *, size_t, size_t); #endif -#ifdef NO_STRTONUM +#ifndef HAVE_STRTONUM long long strtonum(const char *nptr, long long minval, long long maxval, const char **errstr); #endif diff --git a/include/string.h b/include/string.h index f092477..47ada28 100644 --- a/include/string.h +++ b/include/string.h @@ -12,34 +12,35 @@ #include #endif -#ifdef NO_STRLCPY +#ifndef HAVE_STRLCPY size_t strlcpy(char *dst, const char *src, size_t siz); #endif -#ifdef NO_STRLCAT +#ifndef HAVE_STRLCAT size_t strlcat(char *dst, const char *src, size_t siz); #endif -#ifdef NO_STRNDUP +#ifndef HAVE_STRNDUP char * strndup(const char *str, size_t maxlen); -#ifdef NO_STRNLEN +/* the only user of strnlen is strndup, so only build it if needed */ +#ifndef HAVE_STRNLEN size_t strnlen(const char *str, size_t maxlen); #endif #endif -#ifdef NO_EXPLICIT_BZERO +#ifndef HAVE_EXPLICIT_BZERO void explicit_bzero(void *, size_t); #endif -#ifdef NO_TIMINGSAFE_BCMP +#ifndef HAVE_TIMINGSAFE_BCMP int timingsafe_bcmp(const void *b1, const void *b2, size_t n); #endif -#ifdef NO_TIMINGSAFE_MEMCMP +#ifndef HAVE_TIMINGSAFE_MEMCMP int timingsafe_memcmp(const void *b1, const void *b2, size_t len); #endif -#ifdef NO_MEMMEM +#ifndef HAVE_MEMMEM void * memmem(const void *big, size_t big_len, const void *little, size_t little_len); #endif diff --git a/include/unistd.h b/include/unistd.h index 037b11a..38caeb1 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -3,11 +3,11 @@ #ifndef LIBCRYPTOCOMPAT_UNISTD_H #define LIBCRYPTOCOMPAT_UNISTD_H -#ifdef NO_GETENTROPY +#ifndef HAVE_GETENTROPY int getentropy(void *buf, size_t buflen); #endif -#ifdef NO_ISSETUGID +#ifndef HAVE_ISSETUGID int issetugid(void); #endif -- cgit v1.2.3-55-g6feb