-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-144130: support getrandom syscall on non-linux #144131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
7b9fb51 to
5da4196
Compare
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
fe5aacd to
3e595a5
Compare
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.
3e595a5 to
f3af163
Compare
serhiy-storchaka
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See Python/bootstrap_hash.c. Could you make the code similar?
|
According to the FreeBSD manual page:
|
Yup, FreeBSD since 12.0 (December 2018), and NetBSD since 10.0 (March 2024) both claim to support the syscall now. I've not tested this on NetBSD, but their documentation is similar to FreeBSD's. To satisfy my own curiosity I checked DragonFly and OpenBSD's documentation too. DragonFly claims support as of version 5.7. OpenBSD does not claim support, so if it has it it's undocumented, but OpenBSD's man pages are usually complete. |
vstinner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
See Python/bootstrap_hash.c. Could you make the code similar?
@serhiy-storchaka: I didn't understand your comment. Which code should be made similar to Python/bootstrap_hash.c?
Co-authored-by: Victor Stinner <vstinner@python.org>
I wasn't sure either. The code in bootstrap_hash.c already does the right thing, so I added a note about the BSDs. |
|
I meant that the code in |
Ah, okay, that makes sense. You're suggesting I make |
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.