PATCH random/rndgetentropy.c: fix build failure on macOS

Christoph Badura bad at bsd.de
Mon Jan 24 18:38:55 CET 2022


Before the weekend I did a speedo.mk build of gnupg off the master
branches on an Intel MacBook running Big Sur with Xcode 13.2.1 using the
MacOS SDK 12.1.

libgcrypt fails in rndgetentropy.c because the prototype for getentropy()
is missing.  The prototype is provided by sys/random.h per the man pages.

The following patch fixes this for me.
--chris

1 file changed, 3 insertions(+)
random/rndgetentropy.c | 3 +++

modified   random/rndgetentropy.c
@@ -23,6 +23,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
+#ifdef __APPLE__
+#include <sys/random.h>	/* getentropy(2) lives here */
+#endif
 #include <sys/types.h>
 #include <string.h>
 #include <unistd.h>




More information about the Gcrypt-devel mailing list