Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu: Have "rdrand" feature take precedence over "custom" #150

Merged
merged 2 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: \
Expand Down Expand Up @@ -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;
2 changes: 1 addition & 1 deletion src/test_cpu.rs → src/test_rdrand.rs
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down