Skip to content

Commit ff6299d

Browse files
committed
cpu: Add support for CPU-based randomness
This allows freestanding targets to use getrandom. Signed-off-by: Joe Richey <joerichey@google.com>
1 parent cd84484 commit ff6299d

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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)