+2020-05-30 Bruno Haible <bruno@clisp.org>
+
+ 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.
+
2020-05-30 Bruno Haible <bruno@clisp.org>
getrandom: Override incompatible system function on Solaris 11.
This header file is missing on some platforms:
glibc 2.24, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 7.1, HP-UX 11.11, IRIX 6.5, Cygwin, mingw, MSVC 14.
@item
+This header file is not self-contained on some platforms:
+Mac OS X 10.13.
+@item
This header file does not declare the @code{getrandom} function on some platforms:
Mac OS X 10.5, FreeBSD 11.0, HP-UX 11.31, Solaris 11.0.
@end itemize
#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@
-# getrandom.m4 serial 3
+# getrandom.m4 serial 4
dnl Copyright 2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
[gl_cv_func_getrandom_ok],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
- [[#include <sys/random.h>
+ [[/* Additional includes are needed before <sys/random.h> on Mac OS X. */
#include <sys/types.h>
+ #include <stdlib.h>
+ #include <sys/random.h>
ssize_t getrandom (void *, size_t, unsigned int);
]],
[[]])
-# sys_random_h.m4 serial 2
+# sys_random_h.m4 serial 3
dnl Copyright (C) 2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl corresponding gnulib module is not in use.
gl_WARN_ON_USE_PREPARE([[
#if HAVE_SYS_RANDOM_H
+/* Additional includes are needed before <sys/random.h> on Mac OS X. */
+# include <sys/types.h>
+# include <stdlib.h>
# include <sys/random.h>
#endif
]],