summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2020-05-31 01:02:21 +0200
committerBruno Haible <bruno@clisp.org>2020-05-31 01:02:21 +0200
commitafdf2fbbe1dee48a75065aa351e9e526330317fe (patch)
treea7adcb15ff29f8f7fdbafa4de6d4c18e77e46101 /lib
parent1d1722af8dfee991bad4eed33dd351ca76550fe7 (diff)
downloadgnulib-afdf2fbbe1dee48a75065aa351e9e526330317fe.tar.gz
sys_random: Work around macOS bug.
* m4/sys_random_h.m4 (gl_HEADER_SYS_RANDOM): Include <sys/types.h> and <stdlib.h> before <sys/random.h>. * m4/getrandom.m4 (gl_FUNC_GETRANDOM): Likewise. * lib/sys_random.in.h: On macOS, include <sys/types.h> and <stdlib.h> first. * doc/glibc-headers/sys_random.texi: Mention the macOS problem.
Diffstat (limited to 'lib')
-rw-r--r--lib/sys_random.in.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/sys_random.in.h b/lib/sys_random.in.h
index 4d12db95ea..290fa3938e 100644
--- a/lib/sys_random.in.h
+++ b/lib/sys_random.in.h
@@ -23,6 +23,14 @@
#if @HAVE_SYS_RANDOM_H@
+/* On Mac OS X 10.5, <sys/random.h> assumes prior inclusion of <sys/types.h>.
+ On Max OS X 10.13, <sys/random.h> assumes prior inclusion of a file that
+ includes <Availability.h>, such as <stdlib.h> or <unistd.h>. */
+# if defined __APPLE__ && defined __MACH__ /* Mac OS X */
+# include <sys/types.h>
+# include <stdlib.h>
+# endif
+
/* The include_next requires a split double-inclusion guard. */
# @INCLUDE_NEXT@ @NEXT_SYS_RANDOM_H@