Skip to content

Commit af585ac

Browse files
committed
Format
1 parent 3f60e64 commit af585ac

File tree

14 files changed

+155
-154
lines changed

14 files changed

+155
-154
lines changed

crates/core_arch/src/mips/msa.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13531,7 +13531,7 @@ mod tests {
1353113531
#[simd_test(enable = "msa")]
1353213532
unsafe fn test_msa_frint_w() {
1353313533
#[rustfmt::skip]
13534-
let a = f32x4::new(2.6, -2.7, 1.3, -1.7);;
13534+
let a = f32x4::new(2.6, -2.7, 1.3, -1.7);
1353513535
#[rustfmt::skip]
1353613536
let r = f32x4::new(3.0, -3.0, 1.0, -2.0);
1353713537

@@ -13551,7 +13551,7 @@ mod tests {
1355113551
#[simd_test(enable = "msa")]
1355213552
unsafe fn test_msa_frcp_w() {
1355313553
#[rustfmt::skip]
13554-
let a = f32x4::new(2.6, -2.7, 1.3, -1.7);;
13554+
let a = f32x4::new(2.6, -2.7, 1.3, -1.7);
1355513555
#[rustfmt::skip]
1355613556
let r = f32x4::new(
1355713557
0.3846154, -0.37037036,
@@ -13574,7 +13574,7 @@ mod tests {
1357413574
#[simd_test(enable = "msa")]
1357513575
unsafe fn test_msa_frsqrt_w() {
1357613576
#[rustfmt::skip]
13577-
let a = f32x4::new(2.6, 2.7, 1.3, 1.7);;
13577+
let a = f32x4::new(2.6, 2.7, 1.3, 1.7);
1357813578
#[rustfmt::skip]
1357913579
let r = f32x4::new(
1358013580
0.6201737, 0.6085806,

crates/std_detect/src/detect/os/aarch64.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! - [Zircon implementation](https://fuchsia.googlesource.com/zircon/+/master/kernel/arch/arm64/feature.cpp)
1717
//! - [Linux documentation](https://www.kernel.org/doc/Documentation/arm64/cpu-feature-registers.txt)
1818
19-
use crate::detect::{Feature, cache};
19+
use crate::detect::{cache, Feature};
2020

2121
/// Try to read the features from the system registers.
2222
///
@@ -33,7 +33,9 @@ pub(crate) fn detect_features() -> cache::Initializer {
3333

3434
// ID_AA64ISAR0_EL1 - Instruction Set Attribute Register 0
3535
let aa64isar0: u64;
36-
unsafe { asm!("mrs $0, ID_AA64ISAR0_EL1" : "=r"(aa64isar0)); }
36+
unsafe {
37+
asm!("mrs $0, ID_AA64ISAR0_EL1" : "=r"(aa64isar0));
38+
}
3739

3840
let aes = bits_shift(aa64isar0, 7, 4) >= 1;
3941
let pmull = bits_shift(aa64isar0, 7, 4) >= 2;
@@ -47,7 +49,9 @@ pub(crate) fn detect_features() -> cache::Initializer {
4749

4850
// ID_AA64PFR0_EL1 - Processor Feature Register 0
4951
let aa64pfr0: u64;
50-
unsafe { asm!("mrs $0, ID_AA64PFR0_EL1" : "=r"(aa64pfr0)); }
52+
unsafe {
53+
asm!("mrs $0, ID_AA64PFR0_EL1" : "=r"(aa64pfr0));
54+
}
5155

5256
let fp = bits_shift(aa64pfr0, 19, 16) < 0xF;
5357
let fphp = bits_shift(aa64pfr0, 19, 16) >= 1;
@@ -60,12 +64,17 @@ pub(crate) fn detect_features() -> cache::Initializer {
6064
enable_feature(Feature::asimd, fp && asimd && (!fphp | asimdhp));
6165
// SIMD extensions require SIMD support:
6266
enable_feature(Feature::rdm, asimd && bits_shift(aa64isar0, 31, 28) >= 1);
63-
enable_feature(Feature::dotprod, asimd && bits_shift(aa64isar0, 47, 44) >= 1);
67+
enable_feature(
68+
Feature::dotprod,
69+
asimd && bits_shift(aa64isar0, 47, 44) >= 1,
70+
);
6471
enable_feature(Feature::sve, asimd && bits_shift(aa64pfr0, 35, 32) >= 1);
6572

6673
// ID_AA64ISAR1_EL1 - Instruction Set Attribute Register 1
6774
let aa64isar1: u64;
68-
unsafe { asm!("mrs $0, ID_AA64ISAR1_EL1" : "=r"(aa64isar1)); }
75+
unsafe {
76+
asm!("mrs $0, ID_AA64ISAR1_EL1" : "=r"(aa64isar1));
77+
}
6978

7079
enable_feature(Feature::rcpc, bits_shift(aa64isar1, 23, 20) >= 1);
7180
}

crates/std_detect/src/detect/os/freebsd/arm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Run-time feature detection for ARM on FreeBSD
22
3-
use crate::detect::{Feature, cache};
4-
use super::{auxvec};
3+
use super::auxvec;
4+
use crate::detect::{cache, Feature};
55

66
/// Try to read the features from the auxiliary vector
77
pub(crate) fn detect_features() -> cache::Initializer {

crates/std_detect/src/detect/os/freebsd/auxvec.rs

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,36 +44,44 @@ pub(crate) fn auxv() -> Result<AuxVec, ()> {
4444
fn archauxv(key: usize) -> Result<usize, ()> {
4545
use crate::mem;
4646

47-
#[derive (Copy, Clone)]
47+
#[derive(Copy, Clone)]
4848
#[repr(C)]
4949
pub struct Elf_Auxinfo {
5050
pub a_type: usize,
5151
pub a_un: unnamed,
5252
}
53-
#[derive (Copy, Clone)]
53+
#[derive(Copy, Clone)]
5454
#[repr(C)]
5555
pub union unnamed {
5656
pub a_val: libc::c_long,
5757
pub a_ptr: *mut libc::c_void,
5858
pub a_fcn: Option<unsafe extern "C" fn() -> ()>,
5959
}
6060

61-
let mut auxv: [Elf_Auxinfo; 27] =
62-
[Elf_Auxinfo{a_type: 0, a_un: unnamed{a_val: 0,},}; 27];
61+
let mut auxv: [Elf_Auxinfo; 27] = [Elf_Auxinfo {
62+
a_type: 0,
63+
a_un: unnamed { a_val: 0 },
64+
}; 27];
6365

6466
let mut len: libc::c_uint = mem::size_of_val(&auxv) as libc::c_uint;
6567

6668
unsafe {
67-
let mut mib = [libc::CTL_KERN, libc::KERN_PROC, libc::KERN_PROC_AUXV, libc::getpid()];
68-
69-
let ret = libc::sysctl(mib.as_mut_ptr(),
70-
mib.len() as u32,
71-
&mut auxv as *mut _ as *mut _,
72-
&mut len as *mut _ as *mut _,
73-
0 as *mut libc::c_void,
74-
0,
75-
);
76-
69+
let mut mib = [
70+
libc::CTL_KERN,
71+
libc::KERN_PROC,
72+
libc::KERN_PROC_AUXV,
73+
libc::getpid(),
74+
];
75+
76+
let ret = libc::sysctl(
77+
mib.as_mut_ptr(),
78+
mib.len() as u32,
79+
&mut auxv as *mut _ as *mut _,
80+
&mut len as *mut _ as *mut _,
81+
0 as *mut libc::c_void,
82+
0,
83+
);
84+
7785
if ret != -1 {
7886
for i in 0..auxv.len() {
7987
if auxv[i].a_type == key {

crates/std_detect/src/detect/os/freebsd/powerpc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Run-time feature detection for PowerPC on FreeBSD.
22
3-
use crate::detect::{Feature, cache};
4-
use super::{auxvec};
3+
use super::auxvec;
4+
use crate::detect::{cache, Feature};
55

66
pub(crate) fn detect_features() -> cache::Initializer {
77
let mut value = cache::Initializer::default();

crates/std_detect/src/detect/os/linux/aarch64.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Run-time feature detection for Aarch64 on Linux.
22
3-
use crate::detect::{Feature, cache, bit};
43
use super::{auxvec, cpuinfo};
4+
use crate::detect::{bit, cache, Feature};
55

66
/// Try to read the features from the auxiliary vector, and if that fails, try
77
/// to read them from /proc/cpuinfo.
@@ -21,16 +21,16 @@ pub(crate) fn detect_features() -> cache::Initializer {
2121
///
2222
/// [hwcap]: https://github.com/torvalds/linux/blob/master/arch/arm64/include/uapi/asm/hwcap.h
2323
struct AtHwcap {
24-
fp: bool, // 0
24+
fp: bool, // 0
2525
asimd: bool, // 1
2626
// evtstrm: bool, // 2
27-
aes: bool, // 3
28-
pmull: bool, // 4
29-
sha1: bool, // 5
30-
sha2: bool, // 6
31-
crc32: bool, // 7
27+
aes: bool, // 3
28+
pmull: bool, // 4
29+
sha1: bool, // 5
30+
sha2: bool, // 6
31+
crc32: bool, // 7
3232
atomics: bool, // 8
33-
fphp: bool, // 9
33+
fphp: bool, // 9
3434
asimdhp: bool, // 10
3535
// cpuid: bool, // 11
3636
asimdrdm: bool, // 12
@@ -144,7 +144,10 @@ impl AtHwcap {
144144
enable_feature(Feature::sve, self.sve && asimd);
145145

146146
// Crypto is specified as AES + PMULL + SHA1 + SHA2 per LLVM/hosts.cpp
147-
enable_feature(Feature::crypto, self.aes && self.pmull && self.sha1 && self.sha2);
147+
enable_feature(
148+
Feature::crypto,
149+
self.aes && self.pmull && self.sha1 && self.sha2,
150+
);
148151
}
149152
value
150153
}

crates/std_detect/src/detect/os/linux/arm.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Run-time feature detection for ARM on Linux.
22
3-
use crate::detect::{Feature, cache, bit};
43
use super::{auxvec, cpuinfo};
4+
use crate::detect::{bit, cache, Feature};
55

66
/// Try to read the features from the auxiliary vector, and if that fails, try
77
/// to read them from /proc/cpuinfo.
@@ -23,8 +23,11 @@ pub(crate) fn detect_features() -> cache::Initializer {
2323
}
2424

2525
if let Ok(c) = cpuinfo::CpuInfo::new() {
26-
enable_feature(&mut value, Feature::neon, c.field("Features").has("neon") &&
27-
!has_broken_neon(&c));
26+
enable_feature(
27+
&mut value,
28+
Feature::neon,
29+
c.field("Features").has("neon") && !has_broken_neon(&c),
30+
);
2831
enable_feature(&mut value, Feature::pmull, c.field("Features").has("pmull"));
2932
return value;
3033
}

crates/std_detect/src/detect/os/linux/auxvec.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ pub(crate) struct AuxVec {
5151
/// [auxvec_h]: https://github.com/torvalds/linux/blob/master/include/uapi/linux/auxvec.h
5252
/// [auxv_docs]: https://docs.rs/auxv/0.3.3/auxv/
5353
pub(crate) fn auxv() -> Result<AuxVec, ()> {
54-
#[cfg(feature = "std_detect_dlsym_getauxval")] {
54+
#[cfg(feature = "std_detect_dlsym_getauxval")]
55+
{
5556
// Try to call a dynamically-linked getauxval function.
5657
if let Ok(hwcap) = getauxval(AT_HWCAP) {
5758
// Targets with only AT_HWCAP:
58-
#[cfg(any(target_arch = "aarch64", target_arch = "mips",
59-
target_arch = "mips64"))]
59+
#[cfg(any(target_arch = "aarch64", target_arch = "mips", target_arch = "mips64"))]
6060
{
6161
if hwcap != 0 {
6262
return Ok(AuxVec { hwcap });
@@ -74,22 +74,24 @@ pub(crate) fn auxv() -> Result<AuxVec, ()> {
7474
}
7575
drop(hwcap);
7676
}
77-
#[cfg(feature = "std_detect_file_io")] {
77+
#[cfg(feature = "std_detect_file_io")]
78+
{
7879
// If calling getauxval fails, try to read the auxiliary vector from
7980
// its file:
8081
auxv_from_file("/proc/self/auxv")
8182
}
82-
#[cfg(not(feature = "std_detect_file_io"))] {
83+
#[cfg(not(feature = "std_detect_file_io"))]
84+
{
8385
Err(())
8486
}
8587
}
8688

87-
#[cfg(not(feature = "std_detect_dlsym_getauxval"))] {
89+
#[cfg(not(feature = "std_detect_dlsym_getauxval"))]
90+
{
8891
let hwcap = unsafe { ffi_getauxval(AT_HWCAP) };
8992

9093
// Targets with only AT_HWCAP:
91-
#[cfg(any(target_arch = "aarch64", target_arch = "mips",
92-
target_arch = "mips64"))]
94+
#[cfg(any(target_arch = "aarch64", target_arch = "mips", target_arch = "mips64"))]
9395
{
9496
if hwcap != 0 {
9597
return Ok(AuxVec { hwcap });
@@ -115,10 +117,7 @@ fn getauxval(key: usize) -> Result<usize, ()> {
115117
use libc;
116118
pub type F = unsafe extern "C" fn(usize) -> usize;
117119
unsafe {
118-
let ptr = libc::dlsym(
119-
libc::RTLD_DEFAULT,
120-
"getauxval\0".as_ptr() as *const _,
121-
);
120+
let ptr = libc::dlsym(libc::RTLD_DEFAULT, "getauxval\0".as_ptr() as *const _);
122121
if ptr.is_null() {
123122
return Err(());
124123
}
@@ -141,8 +140,7 @@ fn auxv_from_file(file: &str) -> Result<AuxVec, ()> {
141140
// 2*32 `usize` elements is enough to read the whole vector.
142141
let mut buf = [0_usize; 64];
143142
{
144-
let raw: &mut [u8; 64 * mem::size_of::<usize>()] =
145-
unsafe { mem::transmute(&mut buf) };
143+
let raw: &mut [u8; 64 * mem::size_of::<usize>()] = unsafe { mem::transmute(&mut buf) };
146144
file.read(raw).map_err(|_| ())?;
147145
}
148146
auxv_from_buf(&buf)
@@ -153,8 +151,7 @@ fn auxv_from_file(file: &str) -> Result<AuxVec, ()> {
153151
#[cfg(feature = "std_detect_file_io")]
154152
fn auxv_from_buf(buf: &[usize; 64]) -> Result<AuxVec, ()> {
155153
// Targets with only AT_HWCAP:
156-
#[cfg(any(target_arch = "aarch64", target_arch = "mips",
157-
target_arch = "mips64"))]
154+
#[cfg(any(target_arch = "aarch64", target_arch = "mips", target_arch = "mips64"))]
158155
{
159156
for el in buf.chunks(2) {
160157
match el[0] {
@@ -193,8 +190,8 @@ mod tests {
193190
// using the auxv crate.
194191
#[cfg(feature = "std_detect_file_io")]
195192
fn auxv_crate_getprocfs(key: usize) -> Option<usize> {
196-
use self::auxv_crate::AuxvType;
197193
use self::auxv_crate::procfs::search_procfs_auxv;
194+
use self::auxv_crate::AuxvType;
198195
let k = key as AuxvType;
199196
match search_procfs_auxv(&[k]) {
200197
Ok(v) => Some(v[&k] as usize),
@@ -206,8 +203,8 @@ mod tests {
206203
// using the auxv crate.
207204
#[cfg(not(any(target_arch = "mips", target_arch = "mips64")))]
208205
fn auxv_crate_getauxval(key: usize) -> Option<usize> {
209-
use self::auxv_crate::AuxvType;
210206
use self::auxv_crate::getauxval::Getauxval;
207+
use self::auxv_crate::AuxvType;
211208
let q = auxv_crate::getauxval::NativeGetauxval {};
212209
match q.getauxval(key as AuxvType) {
213210
Ok(v) => Some(v as usize),

crates/std_detect/src/detect/os/linux/cpuinfo.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#![cfg_attr(not(target_arch = "arm"), allow(dead_code))]
33

44
extern crate std;
5-
use self::std::{prelude::v1::*, fs::File, io, io::Read};
5+
use self::std::{fs::File, io, io::Read, prelude::v1::*};
66

77
/// cpuinfo
88
pub(crate) struct CpuInfo {
@@ -150,8 +150,7 @@ power management:
150150
assert!(!cpuinfo.field("flags").has("avx"));
151151
}
152152

153-
const ARM_CORTEX_A53: &str =
154-
r"Processor : AArch64 Processor rev 3 (aarch64)
153+
const ARM_CORTEX_A53: &str = r"Processor : AArch64 Processor rev 3 (aarch64)
155154
processor : 0
156155
processor : 1
157156
processor : 2

crates/std_detect/src/detect/os/linux/mips.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Run-time feature detection for MIPS on Linux.
22
3-
use crate::detect::{Feature, cache, bit};
43
use super::auxvec;
4+
use crate::detect::{bit, cache, Feature};
55

66
/// Try to read the features from the auxiliary vector, and if that fails, try
77
/// to read them from `/proc/cpuinfo`.

crates/std_detect/src/detect/os/linux/powerpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Run-time feature detection for PowerPC on Linux.
22
3-
use crate::detect::{Feature, cache};
43
use super::{auxvec, cpuinfo};
4+
use crate::detect::{cache, Feature};
55

66
/// Try to read the features from the auxiliary vector, and if that fails, try
77
/// to read them from /proc/cpuinfo.

0 commit comments

Comments
 (0)