Skip to content

Remove 'static mut' usage in features::os::kernel_version. #2029

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

Merged
merged 1 commit into from
May 20, 2023

Conversation

zachs18
Copy link
Contributor

@zachs18 zachs18 commented Apr 29, 2023

Resolves #2028

Note that this is (AFAICT) the first use of Atomic* types in nix (other than tests). However, this shouldn't be a portability issue, since nix is not #![no_std], and (IIUC) std requires at least loads and stores of pointer-sized atomics (i.e. AtomicUsize), which is all this PR uses.

@zachs18
Copy link
Contributor Author

zachs18 commented Apr 29, 2023

(see bytecodealliance/rustix#645 about CI failures)

(re-commit for CI retry after rustix 0.37.18 release)
@zachs18 zachs18 force-pushed the atomic_kernel_version branch from 0169fff to 2f60820 Compare April 29, 2023 23:36
Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

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

Nice catch. This function dates all the way back to 2014, which may be before the standard library offered stuff like AtomicUsize and Once.

bors r+

@bors
Copy link
Contributor

bors bot commented May 20, 2023

@bors bors bot merged commit ae66999 into nix-rust:master May 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kernel_version can cause a data race when called from multiple threads
2 participants