Skip to content
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

std: refactor UNIX random data generation #128655

Merged
merged 2 commits into from
Aug 13, 2024

Conversation

joboet
Copy link
Member

@joboet joboet commented Aug 4, 2024

This PR makes a number of changes to the UNIX randomness implementation:

  • Use io::Error for centralized error handling
  • Move the file-fallback logic out of the getrandom-specific module
  • Stop redefining the syscalls on macOS and DragonFly, they have appeared in libc
  • Add a OnceLock to cache the random device file descriptor

@joboet joboet added the O-unix Operating system: Unix-like label Aug 4, 2024
@rustbot
Copy link
Collaborator

rustbot commented Aug 4, 2024

r? @ChrisDenton

rustbot has assigned @ChrisDenton.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 4, 2024
This PR makes a number of changes to the UNIX randomness implementation:
* Use `io::Error` for centralized error handling
* Move the file-fallback logic out of the `getrandom`-specific module
* Stop redefining the syscalls on macOS and DragonFly, they have appeared in `libc`
* Add a `OnceLock` to cache the random device file descriptor
@joboet joboet force-pushed the play_with_the_dice branch from b80ec51 to 207ee73 Compare August 4, 2024 16:40
@joboet joboet force-pushed the play_with_the_dice branch from 51743c9 to 99c0d76 Compare August 12, 2024 08:23
Copy link
Member

@ChrisDenton ChrisDenton left a comment

Choose a reason for hiding this comment

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

LGTM. I've left some comments but these are just some notes to myself while I was reviewing. I do have one query but nothing that should block merging.

@ChrisDenton
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 12, 2024

📌 Commit 99c0d76 has been approved by ChrisDenton

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 12, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Aug 12, 2024
…Denton

std: refactor UNIX random data generation

This PR makes a number of changes to the UNIX randomness implementation:
* Use `io::Error` for centralized error handling
* Move the file-fallback logic out of the `getrandom`-specific module
* Stop redefining the syscalls on macOS and DragonFly, they have appeared in `libc`
* Add a `OnceLock` to cache the random device file descriptor
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 13, 2024
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#128643 (Refactor `powerpc64` call ABI handling)
 - rust-lang#128655 (std: refactor UNIX random data generation)
 - rust-lang#128745 (Remove unused lifetime parameter from spawn_unchecked)
 - rust-lang#128841 (bootstrap: don't use rustflags for `--rustc-args`)
 - rust-lang#128983 (Slightly refactor `TargetSelection` in bootstrap)
 - rust-lang#129026 (CFI: Move CFI ui tests to cfi directory)
 - rust-lang#129040 (Fix blessing of rmake tests)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit c977deb into rust-lang:master Aug 13, 2024
6 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 13, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Aug 13, 2024
Rollup merge of rust-lang#128655 - joboet:play_with_the_dice, r=ChrisDenton

std: refactor UNIX random data generation

This PR makes a number of changes to the UNIX randomness implementation:
* Use `io::Error` for centralized error handling
* Move the file-fallback logic out of the `getrandom`-specific module
* Stop redefining the syscalls on macOS and DragonFly, they have appeared in `libc`
* Add a `OnceLock` to cache the random device file descriptor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-unix Operating system: Unix-like S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants