From c13c97dbf846cf0e6a5581ac414ef96a215b0dc6 Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 19 May 2023 10:14:35 +0100 Subject: [PATCH] random: getentropy on macOS does not need unistd.h Remove it. Make this change, so in a future commit, we can combine #ifdefs, and avoid duplicate includes once we switch to using getrandom directly. Also remove the comment about macOS 10.12. We already require macOS > 10.15, so it is redundant. --- configure.ac | 4 ++-- src/random.cpp | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 97b970161c1..17cc31162c9 100644 --- a/configure.ac +++ b/configure.ac @@ -1179,8 +1179,8 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include [ AC_MSG_RESULT([no])] ) -AC_MSG_CHECKING([for getentropy via random.h]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include +AC_MSG_CHECKING([for getentropy via sys/random.h]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include ]], [[ 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]) ], diff --git a/src/random.cpp b/src/random.cpp index f4c51574ccc..144a5c53187 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -33,7 +33,6 @@ #include #endif #if defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX) -#include #include #endif #ifdef HAVE_SYSCTL_ARND @@ -314,8 +313,6 @@ void GetOSRand(unsigned char *ent32) // Silence a compiler warning about unused function. (void)GetDevURandom; #elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX) - /* getentropy() is available on macOS 10.12 and later. - */ if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) { RandFailure(); }