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 ef90ac5de09c65..4ac03ed9a406f7 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -148,6 +148,9 @@ # include #endif +#ifdef HAVE_SYS_RANDOM_H +# include // GRND_RANDOM on FreeBSD and NetBSD +#endif #ifdef HAVE_LINUX_RANDOM_H # include // GRND_RANDOM #endif 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 c826a1bb85667b..2d88c50d89edb9 100755 --- a/configure +++ b/configure @@ -30324,7 +30324,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 322d33dd0e3c99..6a994090ce21eb 100644 --- a/configure.ac +++ b/configure.ac @@ -7377,7 +7377,7 @@ AC_LINK_IFELSE( #include #include #include - #include + #include int main(void) { char buffer[1];