mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Check if sys/random.h is required for getentropy on OSX.
This commit is contained in:
@@ -27,9 +27,12 @@
|
||||
#include <sys/syscall.h>
|
||||
#include <linux/random.h>
|
||||
#endif
|
||||
#ifdef HAVE_GETENTROPY
|
||||
#if defined(HAVE_GETENTROPY) || (defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX))
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#if defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
|
||||
#include <sys/random.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYSCTL_ARND
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
@@ -237,6 +240,15 @@ void GetOSRand(unsigned char *ent32)
|
||||
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
|
||||
RandFailure();
|
||||
}
|
||||
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
|
||||
// We need a fallback for OSX < 10.12
|
||||
if (&getentropy != NULL) {
|
||||
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
|
||||
RandFailure();
|
||||
}
|
||||
} else {
|
||||
GetDevURandom(ent32);
|
||||
}
|
||||
#elif defined(HAVE_SYSCTL_ARND)
|
||||
/* FreeBSD and similar. It is possible for the call to return less
|
||||
* bytes than requested, so need to read in a loop.
|
||||
|
||||
Reference in New Issue
Block a user