Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -17440,7 +17440,7 @@ os_getrandom_impl(PyObject *module, Py_ssize_t size, unsigned int flags)
#ifdef HAVE_GETRANDOM
n = getrandom(data, size, flags);
#else
n = syscall(SYS_getrandom, data, size, flags);
n = syscall(__NR_getrandom, data, size, flags);
#endif
if (n < 0 && errno == EINTR) {
if (PyErr_CheckSignals() < 0) {
Expand Down
6 changes: 3 additions & 3 deletions Python/bootstrap_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# include <sys/random.h> // getrandom()
# endif
# if !defined(HAVE_GETRANDOM) && defined(HAVE_GETRANDOM_SYSCALL)
# include <sys/syscall.h> // SYS_getrandom
# include <sys/syscall.h> // __NR_getrandom

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This include should be removed, __NR_getrandom comes from <unistd.h> which is already included above.

__NR_getrandom comes the kernel header files, like /usr/include/asm/unistd_64.h on my Fedora 44. <sys/syscall.h> is the glibc header file which provides SYS_getrandom constant, but this change replace __NR_getrandom with SYS_getrandom.

# endif
#endif

Expand Down Expand Up @@ -128,11 +128,11 @@ py_getrandom(void *buffer, Py_ssize_t size, int blocking, int raise)
#else
if (raise) {
Py_BEGIN_ALLOW_THREADS
n = syscall(SYS_getrandom, dest, n, flags);
n = syscall(__NR_getrandom, dest, n, flags);
Py_END_ALLOW_THREADS
}
else {
n = syscall(SYS_getrandom, dest, n, flags);
n = syscall(__NR_getrandom, dest, n, flags);
}
# ifdef _Py_MEMORY_SANITIZER
if (n > 0) {
Expand Down
2 changes: 1 addition & 1 deletion configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7812,7 +7812,7 @@ AC_LINK_IFELSE(
const size_t buflen = sizeof(buffer);
const int flags = GRND_NONBLOCK;
/* ignore the result, Python checks for ENOSYS and EAGAIN at runtime */
(void)syscall(SYS_getrandom, buffer, buflen, flags);
(void)syscall(__NR_getrandom, buffer, buflen, flags);
return 0;
}
]])
Expand Down
Loading