Skip to content

Commit de49003

Browse files
committed
Linux/Android: Use once_cell::race::OnceBool.
Now lazy.rs is no longer needed.
1 parent da4b092 commit de49003

File tree

4 files changed

+5
-71
lines changed

4 files changed

+5
-71
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exclude = [".*"]
1515
cfg-if = "1"
1616
once_cell = { version = "1.19.0", default-features = false, optional = true }
1717

18-
[target.'cfg(all(target_arch = "x86_64", target_env = "sgx"))'.dependencies]
18+
[target.'cfg(any(target_os = "android", target_os = "linux", all(target_arch = "x86_64", target_env = "sgx")))'.dependencies]
1919
once_cell = { version = "1.19.0", default-features = false, features = ["race"] }
2020

2121
# When built as part of libstd

src/lazy.rs

-66
This file was deleted.

src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ use crate::util::{slice_as_uninit_mut, slice_assume_init_mut};
216216
use core::mem::MaybeUninit;
217217

218218
mod error;
219-
mod lazy;
220219
mod util;
221220
// To prevent a breaking change when targets are added, we always export the
222221
// register_custom_getrandom macro, so old Custom RNG crates continue to build.

src/linux_android_with_fallback.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
//! Implementation for Linux / Android with `/dev/urandom` fallback
2-
use crate::{lazy::LazyBool, linux_android, use_file, util_libc::last_os_error, Error};
2+
use crate::{linux_android, use_file, util_libc::last_os_error, Error};
33
use core::mem::MaybeUninit;
4+
use once_cell::race::OnceBool;
45

56
pub fn getrandom_inner(dest: &mut [MaybeUninit<u8>]) -> Result<(), Error> {
67
// getrandom(2) was introduced in Linux 3.17
7-
static HAS_GETRANDOM: LazyBool = LazyBool::new();
8-
if HAS_GETRANDOM.unsync_init(is_getrandom_available) {
8+
static HAS_GETRANDOM: OnceBool = OnceBool::new();
9+
if HAS_GETRANDOM.get_or_init(is_getrandom_available) {
910
linux_android::getrandom_inner(dest)
1011
} else {
1112
use_file::getrandom_inner(dest)

0 commit comments

Comments
 (0)