Skip to content

Commit 7b9fb51

Browse files
committed
support getrandom syscall on non-linux
At least FreeBSD and NetBSD also implement getrandom using the same semantics as Linux >= 3.17. They don't define any of it it in linux/random.h, however. They do define all the necessary bits in sys/random.h. glibc >= 2.25 also defines it there as well as in linux/random.h. Simply use sys/random.h when checking for its existence.
1 parent 14f96a8 commit 7b9fb51

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

Modules/posixmodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@
148148
# include <sys/sysctl.h>
149149
#endif
150150

151+
#ifdef HAVE_SYS_RANDOM_H
152+
# include <sys/random.h> // GRND_RANDOM on !Linux
153+
#endif
151154
#ifdef HAVE_LINUX_RANDOM_H
152155
# include <linux/random.h> // GRND_RANDOM
153156
#endif

configure

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7377,7 +7377,7 @@ AC_LINK_IFELSE(
73777377
#include <stddef.h>
73787378
#include <unistd.h>
73797379
#include <sys/syscall.h>
7380-
#include <linux/random.h>
7380+
#include <sys/random.h>
73817381
73827382
int main(void) {
73837383
char buffer[1];

0 commit comments

Comments
 (0)