From aecf3810c22ac5e904b0eb7bfe26e3168f3f4f43 Mon Sep 17 00:00:00 2001 From: dimitri staessens Date: Thu, 10 Aug 2017 22:56:12 +0200 Subject: build: Fix compilation on OS X Sierra --- src/lib/random.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/lib/random.c') diff --git a/src/lib/random.c b/src/lib/random.c index 17973695..4ce378cd 100644 --- a/src/lib/random.c +++ b/src/lib/random.c @@ -24,10 +24,20 @@ #include #include -#if defined(HAVE_SYS_RANDOM) +#if defined(__APPLE__) /* Barf */ +#undef __OSX_AVAILABLE +#define __OSX_AVAILABLE(arg) +#undef __IOS_AVAILABLE +#define __IOS_AVAILABLE(arg) +#undef __TVOS_AVAILABLE +#define __TVOS_AVAILABLE(arg) +#undef __WATCHOS_AVAILABLE +#define __WATCHOS_AVAILABLE(arg) +#include +#elif defined(HAVE_SYS_RANDOM) #include #elif defined(HAVE_LIBGCRYPT) -#include +#include #elif defined(__FreeBSD__) #include #elif defined(HAVE_OPENSSL) @@ -43,10 +53,13 @@ int random_buffer(void * buf, #elif defined(HAVE_LIBGCRYPT) return gcry_randomize(buf, len, GCRY_STRONG_RANDOM); #elif defined(__FreeBSD__) - return arc4random_buf(buf, len); + arc4random_buf(buf, len); + return 0; #elif defined(HAVE_OPENSSL) if (len > 0 && len < INT_MAX) return RAND_bytes((unsigned char *) buf, (int) len); return -1; +#elif defined(__APPLE__) + return getentropy(buf, len); #endif } -- cgit v1.2.3