summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-06-14 12:52:03 +0300
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2018-06-16 15:22:34 +0200
commite4c2963add8a1173e6e33a789a6f5b131cb65a5a (patch)
tree5821b331a0c4b0bbcda17adc66cc12d6aa864c3f
parent317f382ddc5839f5d65203dd749234fde2ab6d63 (diff)
downloadgnutls-e4c2963add8a1173e6e33a789a6f5b131cb65a5a.tar.gz
configure: Include sys/random.h before checking for getentropy on macOS
This function is available since macOS 10.12, but it's in sys/random.h on macOS, contrary to the other platforms supporting it where it is present in unistd.h. If we don't include the right header that declares the function and its availability, the configure check would succeed even if targeting older versions of macOS that lacks the function. Also include the same header in the source file that actually uses getentropy. Signed-off-by: Martin Storsjo <martin@martin.st>
-rw-r--r--configure.ac3
-rw-r--r--lib/nettle/sysrng-getentropy.c3
2 files changed, 6 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 162f187d4d..53adee922a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -241,6 +241,9 @@ AC_LINK_IFELSE([AC_LANG_PROGRAM([
AC_MSG_CHECKING([for getentropy])
AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <unistd.h>
+ #ifdef __APPLE__
+ #include <sys/random.h>
+ #endif
#ifdef __linux__
#error 1
#endif
diff --git a/lib/nettle/sysrng-getentropy.c b/lib/nettle/sysrng-getentropy.c
index 13aee36245..ec2585e82b 100644
--- a/lib/nettle/sysrng-getentropy.c
+++ b/lib/nettle/sysrng-getentropy.c
@@ -34,6 +34,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#ifdef __APPLE__
+#include <sys/random.h>
+#endif
/* gnulib wants to claim strerror even if it cannot provide it. WTF */
#undef strerror