summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-08-17 13:53:04 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-08-17 14:45:07 +0200
commitaa3416215e980a2ec87ac259be0ea39f1caf96df (patch)
tree0b03415aed79acf4da1102558b4478b8b138b8d8 /src/lib
parent44327027e32f5853995984a5bad9869b443898ca (diff)
downloadouroboros-aa3416215e980a2ec87ac259be0ea39f1caf96df.tar.gz
ouroboros-aa3416215e980a2ec87ac259be0ea39f1caf96df.zip
lib: Check system-specific call first
The build failed on OS X if an old version of libgrypt is installed.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/random.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/random.c b/src/lib/random.c
index 5d6763ca..66aefaa3 100644
--- a/src/lib/random.c
+++ b/src/lib/random.c
@@ -47,18 +47,18 @@
int random_buffer(void * buf,
size_t len)
{
-#if defined(HAVE_SYS_RANDOM)
- return getrandom(buf, len, GRND_NONBLOCK); /* glibc 2.25 */
-#elif defined(HAVE_LIBGCRYPT)
- return gcry_randomize(buf, len, GCRY_STRONG_RANDOM);
+#if defined(__APPLE__)
+ return getentropy(buf, len);
#elif defined(__FreeBSD__)
arc4random_buf(buf, len);
return 0;
+#elif defined(HAVE_SYS_RANDOM)
+ return getrandom(buf, len, GRND_NONBLOCK); /* glibc 2.25 */
+#elif defined(HAVE_LIBGCRYPT)
+ return gcry_randomize(buf, len, GCRY_STRONG_RANDOM);
#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
}