Skip to content

Commit 8ac79d4

Browse files
committed
cpu: Add support for CPU-based randomness
This allows freestanding targets to use getrandom. Signed-off-by: Joe Richey <[email protected]>
1 parent 7aed17e commit 8ac79d4

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ wasi = "0.9"
3535

3636
[features]
3737
std = []
38+
# Feature to enable fallback CPU-based implementation
39+
cpu = []
3840
# Feature to enable custom RNG implementations
3941
custom = []
4042
# Unstable feature to support being a libstd dependency

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ cfg_if! {
185185
#[path = "rdrand.rs"] mod imp;
186186
} else if #[cfg(feature = "custom")] {
187187
use custom as imp;
188+
} else if #[cfg(all(feature = "cpu", target_arch = "x86_64"))] {
189+
#[path = "rdrand.rs"] mod imp;
188190
} else {
189191
compile_error!("\
190192
target is not supported, for more information see: \

0 commit comments

Comments
 (0)