Skip to content

Commit dc35c8c

Browse files
authored
Shuffle around stdsimd::arch::detect bits (#428)
Compile more code on more platforms, tweak imports, try to catch mistakes sooner.
1 parent 6d0e439 commit dc35c8c

File tree

12 files changed

+37
-46
lines changed

12 files changed

+37
-46
lines changed

crates/stdsimd/src/lib.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
extern crate cfg_if;
1919
extern crate coresimd;
2020
extern crate libc;
21-
extern crate std as _std;
21+
extern crate std as __do_not_use_this_import;
2222

2323
#[cfg(test)]
2424
#[macro_use(println, print)]
@@ -30,8 +30,10 @@ mod stdsimd;
3030
pub use stdsimd::*;
3131

3232
#[allow(unused_imports)]
33-
use _std::fs;
33+
use __do_not_use_this_import::fs;
3434
#[allow(unused_imports)]
35-
use _std::io;
35+
use __do_not_use_this_import::io;
3636
#[allow(unused_imports)]
37-
use _std::prelude;
37+
use __do_not_use_this_import::prelude;
38+
#[allow(unused_imports)]
39+
use __do_not_use_this_import::mem;
File renamed without changes.
File renamed without changes.

stdsimd/arch/detect/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ cfg_if! {
5656
}
5757
pub use self::arch::Feature;
5858

59+
mod cache;
60+
mod bit;
61+
5962
cfg_if! {
6063
if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
6164
// On x86/x86_64 no OS specific functionality is required.

stdsimd/arch/detect/os/linux/aarch64.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
//! Run-time feature detection for Aarch64 on Linux.
22
3-
#[path = "../cache.rs"]
4-
mod cache;
5-
#[path = "../bit.rs"]
6-
mod bit;
7-
#[path = "auxvec.rs"]
8-
mod auxvec;
9-
#[path = "cpuinfo.rs"]
10-
mod cpuinfo;
11-
123
use arch::detect::Feature;
4+
use arch::detect::cache;
5+
use arch::detect::bit;
6+
use super::auxvec;
7+
use super::cpuinfo;
138

149
/// Performs run-time feature detection.
1510
pub fn check_for(x: Feature) -> bool {

stdsimd/arch/detect/os/linux/arm.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
//! Run-time feature detection for ARM on Linux.
22
3-
#[path = "../cache.rs"]
4-
mod cache;
5-
#[path = "../bit.rs"]
6-
mod bit;
7-
#[path = "auxvec.rs"]
8-
mod auxvec;
9-
#[path = "cpuinfo.rs"]
10-
mod cpuinfo;
11-
123
use arch::detect::Feature;
4+
use arch::detect::cache;
5+
use arch::detect::bit;
6+
use super::auxvec;
7+
use super::cpuinfo;
138

149
/// Performs run-time feature detection.
1510
pub fn check_for(x: Feature) -> bool {

stdsimd/arch/detect/os/linux/auxvec.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
//! Parses ELF auxiliary vectors.
2+
#![cfg_attr(not(target_arch = "aarch64"), allow(dead_code))]
23

3-
use core::mem;
4-
use _std::prelude::v1::*;
5-
use _std::fs::File;
6-
use _std::io::Read;
4+
use mem;
5+
use prelude::v1::*;
6+
use fs::File;
7+
use io::Read;
78

89
/// Key to access the CPU Hardware capabilities bitfield.
910
pub const AT_HWCAP: usize = 16;
@@ -68,6 +69,7 @@ pub fn auxv() -> Result<AuxVec, ()> {
6869
}
6970
}
7071
}
72+
drop(hwcap);
7173
}
7274
// If calling getauxval fails, try to read the auxiliary vector from
7375
// its file:
@@ -144,6 +146,7 @@ fn auxv_from_buf(buf: &[usize; 64]) -> Result<AuxVec, ()> {
144146
return Ok(AuxVec { hwcap, hwcap2 });
145147
}
146148
}
149+
drop(buf);
147150
Err(())
148151
}
149152

@@ -179,7 +182,7 @@ mod tests {
179182

180183
// FIXME: on mips/mips64 getauxval returns 0, and /proc/self/auxv
181184
// does not always contain the AT_HWCAP key under qemu.
182-
#[cfg(not(any(target_arch = "mips", target_arch = "mips64")))]
185+
#[cfg(not(any(target_arch = "mips", target_arch = "mips64", target_arch = "powerpc")))]
183186
#[test]
184187
fn auxv_crate() {
185188
let v = auxv();

stdsimd/arch/detect/os/linux/cpuinfo.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//! Parses /proc/cpuinfo
2+
#![cfg_attr(not(target_arch = "arm"), allow(dead_code))]
23

34
use prelude::v1::*;
45
use fs::File;

stdsimd/arch/detect/os/linux/mips.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
//! Run-time feature detection for MIPS on Linux.
22
3-
#[path = "../cache.rs"]
4-
mod cache;
5-
#[path = "../bit.rs"]
6-
mod bit;
7-
#[path = "auxvec.rs"]
8-
mod auxvec;
9-
103
use arch::detect::Feature;
4+
use arch::detect::cache;
5+
use arch::detect::bit;
6+
use super::auxvec;
117

128
/// Performs run-time feature detection.
139
pub fn check_for(x: Feature) -> bool {

stdsimd/arch/detect/os/linux/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
//! Run-time feature detection on Linux
22
3+
mod auxvec;
4+
mod cpuinfo;
5+
36
cfg_if! {
47
if #[cfg(target_arch = "aarch64")] {
58
mod aarch64;

stdsimd/arch/detect/os/linux/powerpc64.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
//! Run-time feature detection for ARM on Linux.
22
3-
#[path = "../cache.rs"]
4-
mod cache;
5-
#[path = "auxvec.rs"]
6-
mod auxvec;
7-
#[path = "cpuinfo.rs"]
8-
mod cpuinfo;
9-
103
use arch::detect::Feature;
4+
use arch::detect::cache;
5+
use super::auxvec;
6+
use super::cpuinfo;
117

128
/// Performs run-time feature detection.
139
pub fn check_for(x: Feature) -> bool {

stdsimd/arch/detect/os/x86.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ use coresimd::arch::x86::*;
77
#[cfg(target_arch = "x86_64")]
88
use coresimd::arch::x86_64::*;
99

10-
#[path = "cache.rs"]
11-
mod cache;
12-
#[path = "bit.rs"]
13-
mod bit;
14-
1510
use arch::detect::Feature;
11+
use arch::detect::cache;
12+
use arch::detect::bit;
1613

1714
/// Performs run-time feature detection.
1815
pub fn check_for(x: Feature) -> bool {

0 commit comments

Comments
 (0)