mirror of
https://github.com/dogecoin/dogecoin.git
synced 2026-01-31 10:30:52 +00:00
random: getentropy on macOS does not need unistd.h
change sys/random.h to random.h in AC_MSG_CHECK remove definitions that are applicable to macos which include unistd.h additionally change comparator argument from NULL to nullptr when evaluating &getentropy Inspired by: c13c97dbf846cf0e6a5581ac414ef96a215b0dc6
This commit is contained in:
parent
743c3acd3d
commit
d693d4a008
@ -655,8 +655,8 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]],
|
|||||||
[ AC_MSG_RESULT(no)]
|
[ AC_MSG_RESULT(no)]
|
||||||
)
|
)
|
||||||
|
|
||||||
AC_MSG_CHECKING(for getentropy via random.h)
|
AC_MSG_CHECKING([for getentropy via sys/random.h])
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||||
#include <sys/random.h>]],
|
#include <sys/random.h>]],
|
||||||
[[ getentropy(nullptr, 32) ]])],
|
[[ getentropy(nullptr, 32) ]])],
|
||||||
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_GETENTROPY_RAND, 1,[Define this symbol if the BSD getentropy system call is available with sys/random.h]) ],
|
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_GETENTROPY_RAND, 1,[Define this symbol if the BSD getentropy system call is available with sys/random.h]) ],
|
||||||
|
|||||||
@ -25,7 +25,7 @@
|
|||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <linux/random.h>
|
#include <linux/random.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_GETENTROPY) || (defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX))
|
#if defined(HAVE_GETENTROPY)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
|
#if defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
|
||||||
@ -169,7 +169,7 @@ void GetOSRand(unsigned char *ent32)
|
|||||||
}
|
}
|
||||||
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
|
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
|
||||||
// We need a fallback for OSX < 10.12
|
// We need a fallback for OSX < 10.12
|
||||||
if (&getentropy != NULL) {
|
if (&getentropy != nullptr) {
|
||||||
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
|
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
|
||||||
RandFailure();
|
RandFailure();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user