diff options
Diffstat (limited to 'src/random.cpp')
-rw-r--r-- | src/random.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/random.cpp b/src/random.cpp index f0082cf3e0..2a27e6ba0d 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -15,7 +15,7 @@ #endif #include <logging.h> // for LogPrintf() #include <sync.h> // for Mutex -#include <util/time.h> // for GetTime() +#include <util/time.h> // for GetTimeMicros() #include <stdlib.h> #include <thread> @@ -315,19 +315,16 @@ void GetOSRand(unsigned char *ent32) RandFailure(); } #elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX) - // We need a fallback for OSX < 10.12 - if (&getentropy != nullptr) { - if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) { - RandFailure(); - } - } else { - GetDevURandom(ent32); + /* getentropy() is available on macOS 10.12 and later. + */ + if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) { + RandFailure(); } #elif defined(HAVE_SYSCTL_ARND) - /* FreeBSD and similar. It is possible for the call to return less + /* FreeBSD, NetBSD and similar. It is possible for the call to return less * bytes than requested, so need to read in a loop. */ - static const int name[2] = {CTL_KERN, KERN_ARND}; + static int name[2] = {CTL_KERN, KERN_ARND}; int have = 0; do { size_t len = NUM_OS_RANDOM_BYTES - have; |