cpu: Add support for CPU-based randomness
This allows freestanding targets to use getrandom. Signed-off-by: Joe Richey <joerichey@google.com>
This commit is contained in:
committed by
Joseph Richey
parent
cd84484205
commit
ff6299dd77
@@ -35,6 +35,8 @@ wasi = "0.9"
|
||||
|
||||
[features]
|
||||
std = []
|
||||
# Feature to enable fallback CPU-based implementation
|
||||
cpu = []
|
||||
# Feature to enable custom RNG implementations
|
||||
custom = []
|
||||
# Unstable feature to support being a libstd dependency
|
||||
|
||||
@@ -185,6 +185,8 @@ cfg_if! {
|
||||
#[path = "rdrand.rs"] mod imp;
|
||||
} else if #[cfg(feature = "custom")] {
|
||||
use custom as imp;
|
||||
} else if #[cfg(all(feature = "cpu", target_arch = "x86_64"))] {
|
||||
#[path = "rdrand.rs"] mod imp;
|
||||
} else {
|
||||
compile_error!("\
|
||||
target is not supported, for more information see: \
|
||||
|
||||
Reference in New Issue
Block a user