diff options
author | dimitri staessens <dimitri.staessens@ugent.be> | 2017-08-11 09:57:31 +0000 |
---|---|---|
committer | Sander Vrijders <sander.vrijders@ugent.be> | 2017-08-11 09:57:31 +0000 |
commit | f957c2c499f8093ae86e673e2170f9dbfdcb761a (patch) | |
tree | 89cb20e426cb3977337e1d16bdb0a445622d6f75 /src/lib/random.c | |
parent | 2b42b1e1121dfd715a78502a3652d326330b8160 (diff) | |
parent | aecf3810c22ac5e904b0eb7bfe26e3168f3f4f43 (diff) | |
download | ouroboros-f957c2c499f8093ae86e673e2170f9dbfdcb761a.tar.gz ouroboros-f957c2c499f8093ae86e673e2170f9dbfdcb761a.zip |
Merged in dstaesse/ouroboros/be-apple (pull request #548)
build: Fix compilation on OS X Sierra
Diffstat (limited to 'src/lib/random.c')
-rw-r--r-- | src/lib/random.c | 19 |
1 files changed, 16 insertions, 3 deletions
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 <ouroboros/config.h> #include <ouroboros/random.h> -#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 <sys/random.h> +#elif defined(HAVE_SYS_RANDOM) #include <sys/random.h> #elif defined(HAVE_LIBGCRYPT) -#include <grypt.h> +#include <gcrypt.h> #elif defined(__FreeBSD__) #include <stdlib.h> #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 } |