aarch64-prep: Wrap x86_64 specific crate references and code with conditionals

This commit is contained in:
Robin Randhawa
2019-01-15 12:19:39 +00:00
parent 0e55459e0e
commit 0e613dcc15
2 changed files with 12 additions and 2 deletions
+3 -1
View File
@@ -4,5 +4,7 @@ version = "0.1.0"
[dependencies]
rand = "0.3"
raw-cpuid = "2.0"
redox_syscall = "0.1"
[target.'cfg(target_arch = "x86_64")'.dependencies]
raw-cpuid = "2.0"
+9 -1
View File
@@ -1,6 +1,8 @@
#![feature(asm)]
extern crate syscall;
#[cfg(target_arch = "x86_64")]
extern crate raw_cpuid;
extern crate rand;
@@ -11,6 +13,7 @@ use std::os::unix::io::AsRawFd;
use rand::chacha::ChaChaRng;
use rand::Rng;
#[cfg(target_arch = "x86_64")]
use raw_cpuid::CpuId;
use syscall::{Error, Result, SchemeMut, EINVAL, MODE_CHR};
@@ -88,7 +91,12 @@ impl SchemeMut for RandScheme {
}
fn main(){
let has_rdrand = CpuId::new().get_feature_info().unwrap().has_rdrand();
let has_rdrand = false;
#[cfg(target_arch = "x86_64")]
{
has_rdrand = CpuId::new().get_feature_info().unwrap().has_rdrand();
}
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {