Skip to content

Commit c13c97d

Browse files
committed
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 <sys/random.h> 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.
1 parent 17acb27 commit c13c97d

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,8 +1179,8 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
11791179
[ AC_MSG_RESULT([no])]
11801180
)
11811181

1182-
AC_MSG_CHECKING([for getentropy via random.h])
1183-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>
1182+
AC_MSG_CHECKING([for getentropy via sys/random.h])
1183+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
11841184
#include <sys/random.h>]],
11851185
[[ getentropy(nullptr, 32) ]])],
11861186
[ 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]) ],

src/random.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include <linux/random.h>
3434
#endif
3535
#if defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
36-
#include <unistd.h>
3736
#include <sys/random.h>
3837
#endif
3938
#ifdef HAVE_SYSCTL_ARND
@@ -314,8 +313,6 @@ void GetOSRand(unsigned char *ent32)
314313
// Silence a compiler warning about unused function.
315314
(void)GetDevURandom;
316315
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
317-
/* getentropy() is available on macOS 10.12 and later.
318-
*/
319316
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
320317
RandFailure();
321318
}

0 commit comments

Comments
 (0)