diff --git a/Misc/NEWS.d/next/Library/2026-01-22-15-54-57.gh-issue-144130.QaHIxE.rst b/Misc/NEWS.d/next/Library/2026-01-22-15-54-57.gh-issue-144130.QaHIxE.rst new file mode 100644 index 00000000000000..34ad9506fd3b1a --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-01-22-15-54-57.gh-issue-144130.QaHIxE.rst @@ -0,0 +1 @@ +Add support for FreeBSD's implementation of getrandom, so :func:`os.getrandom` works there too. diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 8c360ce3b79b8a..76f4358a43f814 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -151,8 +151,11 @@ #ifdef HAVE_LINUX_RANDOM_H # include // GRND_RANDOM #endif +#if defined(HAVE_SYS_RANDOM_H) && (defined(HAVE_GETRANDOM) || defined(HAVE_GETENTROPY)) +# include // getrandom(), GRND_NONBLOCK on FreeBSD and NetBSD +#endif #ifdef HAVE_GETRANDOM_SYSCALL -# include // syscall() +# include // SYS_getrandom #endif #ifdef HAVE_POSIX_SPAWN diff --git a/Python/bootstrap_hash.c b/Python/bootstrap_hash.c index f0fb87c4a5d15e..76673bc8b3db26 100644 --- a/Python/bootstrap_hash.c +++ b/Python/bootstrap_hash.c @@ -20,7 +20,7 @@ # include // GRND_NONBLOCK # endif # if defined(HAVE_SYS_RANDOM_H) && (defined(HAVE_GETRANDOM) || defined(HAVE_GETENTROPY)) -# include // getrandom() +# include // getrandom(), GRND_NONBLOCK on FreeBSD and NetBSD # endif # if !defined(HAVE_GETRANDOM) && defined(HAVE_GETRANDOM_SYSCALL) # include // SYS_getrandom diff --git a/configure b/configure index a3eeef373bf7fb..9d1ecc8e2a66f9 100755 --- a/configure +++ b/configure @@ -30442,7 +30442,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #include #include #include - #include + #include int main(void) { char buffer[1]; diff --git a/configure.ac b/configure.ac index 75e81761f95e38..1bab97d01f470a 100644 --- a/configure.ac +++ b/configure.ac @@ -7439,7 +7439,7 @@ AC_LINK_IFELSE( #include #include #include - #include + #include int main(void) { char buffer[1];