diff --git a/.travis.yml b/.travis.yml index a5f74cde..3d3e443c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -145,11 +145,11 @@ jobs: script: # We test that getrandom builds for all targets - echo $STD_TARGETS | xargs -t -n1 cargo build --target - - echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --features=cpu --target + - echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --features=rdrand --target # also test minimum dependency versions are usable - cargo generate-lockfile -Z minimal-versions - echo $STD_TARGETS | xargs -t -n1 cargo build --target - - echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --features=cpu --target + - echo $NO_STD_TARGETS | xargs -t -n1 cargo xbuild --features=rdrand --target # Trust cross-built/emulated targets. We must repeat all non-default values. - name: "Linux (MIPS, big-endian)" diff --git a/Cargo.toml b/Cargo.toml index 0488cc19..5ace3432 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,8 +35,8 @@ wasi = "0.9" [features] std = [] -# Feature to enable fallback CPU-based implementation -cpu = [] +# Feature to enable fallback RDRAND-based implementation +rdrand = [] # Feature to enable custom RNG implementations custom = [] # Unstable feature to support being a libstd dependency diff --git a/src/lib.rs b/src/lib.rs index 8a03009a..b988445c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -183,11 +183,11 @@ cfg_if! { #[path = "windows.rs"] mod imp; } else if #[cfg(all(target_arch = "x86_64", target_env = "sgx"))] { #[path = "rdrand.rs"] mod imp; - } else if #[cfg(feature = "custom")] { - use custom as imp; - } else if #[cfg(all(feature = "cpu", + } else if #[cfg(all(feature = "rdrand", any(target_arch = "x86_64", target_arch = "x86")))] { #[path = "rdrand.rs"] mod imp; + } else if #[cfg(feature = "custom")] { + use custom as imp; } else { compile_error!("\ target is not supported, for more information see: \ @@ -219,4 +219,4 @@ pub fn getrandom(dest: &mut [u8]) -> Result<(), Error> { #[cfg(test)] mod test_common; #[cfg(test)] -mod test_cpu; +mod test_rdrand; diff --git a/src/test_cpu.rs b/src/test_rdrand.rs similarity index 71% rename from src/test_cpu.rs rename to src/test_rdrand.rs index 7a9a0669..fafa6acc 100644 --- a/src/test_cpu.rs +++ b/src/test_rdrand.rs @@ -1,4 +1,4 @@ -// We only test the CPU-based RNG source on supported architectures. +// We only test the RDRAND-based RNG source on supported architectures. #![cfg(any(target_arch = "x86_64", target_arch = "x86"))] #[path = "rdrand.rs"]