diff --git a/Cargo.toml b/Cargo.toml index aad17bf..511cd4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,6 @@ name = "raw-cpuid" version = "8.1.2" authors = ["Gerd Zellweger "] -build = "build.rs" edition = "2018" description = "A library to parse the x86 CPUID instruction, written in rust with no external dependencies. The implementation closely resembles the Intel CPUID manual description. The library does only depend on libcore." @@ -33,7 +32,3 @@ serde_derive = {version = "1.0", optional = true } libc = { version = "0.2", default-features = false } core_affinity = "0.5.10" rustversion = "1.0" - -[build-dependencies] -rustc_version = "0.3" -cc = "1" diff --git a/build.rs b/build.rs deleted file mode 100644 index 1c41b6e..0000000 --- a/build.rs +++ /dev/null @@ -1,16 +0,0 @@ -extern crate cc; -extern crate rustc_version; -use rustc_version::{version, version_meta, Channel, Version}; - -fn main() { - let newer_than_1_27 = version().unwrap() >= Version::parse("1.27.0").unwrap(); - if newer_than_1_27 { - println!("cargo:rustc-cfg=feature=\"use_arch\""); - } else { - cc::Build::new().file("src/cpuid.c").compile("libcpuid.a"); - } - - if version_meta().unwrap().channel == Channel::Nightly { - println!("cargo:rustc-cfg=feature=\"nightly\""); - } -} diff --git a/src/cpuid.c b/src/cpuid.c deleted file mode 100644 index c014da4..0000000 --- a/src/cpuid.c +++ /dev/null @@ -1,32 +0,0 @@ -#include - -void cpuid(uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx) { -#ifdef _MSC_VER - uint32_t regs[4]; - __cpuidex((int *)regs, *eax, *ecx); - *eax = regs[0], *ebx = regs[1], *ecx = regs[2], *edx = regs[3]; -#else - asm volatile( -#if defined(__i386__) && defined(__PIC__) - // The reason for this ebx juggling is the -fPIC rust compilation mode. - // On 32-bit to locate variables it uses a global offset table whose - // pointer is stored in ebx. Without temporary storing ebx in edi, the - // compiler will complain about inconsistent operand constraints in an - // 'asm'. - // Also note that this is only an issue on older compiler versions. - "mov %%ebx, %%edi;" - "cpuid;" - "xchgl %%ebx, %%edi;" - : - "+a" (*eax), - "=D" (*ebx), -#else - "cpuid" - : - "+a"(*eax), - "=b"(*ebx), -#endif - "+c"(*ecx), - "=d"(*edx)); -#endif -} diff --git a/src/lib.rs b/src/lib.rs index 6d4640e..a6e03ab 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,29 +15,7 @@ extern crate serde_derive; #[macro_use] extern crate bitflags; -/// Provides `cpuid` on stable by linking against a C implementation. -#[cfg(not(feature = "use_arch"))] -pub mod native_cpuid { - use super::CpuIdResult; - - extern "C" { - fn cpuid(a: *mut u32, b: *mut u32, c: *mut u32, d: *mut u32); - } - - pub fn cpuid_count(mut eax: u32, mut ecx: u32) -> CpuIdResult { - let mut ebx = 0u32; - let mut edx = 0u32; - - unsafe { - cpuid(&mut eax, &mut ebx, &mut ecx, &mut edx); - } - - CpuIdResult { eax, ebx, ecx, edx } - } -} - /// Uses Rust's `cpuid` function from the `arch` module. -#[cfg(feature = "use_arch")] pub mod native_cpuid { use super::CpuIdResult;