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:
Joe Richey
2020-02-18 22:45:02 -08:00
committed by Joseph Richey
parent cd84484205
commit ff6299dd77
2 changed files with 4 additions and 0 deletions
+2
View File
@@ -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
+2
View File
@@ -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: \