Add detect macros should support trailing commas (Fix #443)
This commit is contained in:
parent
d226e32984
commit
e51ee17aa7
8 changed files with 76 additions and 0 deletions
|
|
@ -66,6 +66,9 @@ macro_rules! is_aarch64_feature_detected {
|
|||
("v8.3a") => {
|
||||
compile_error!("\"v8.3a\" feature cannot be detected at run-time")
|
||||
};
|
||||
($t:tt,) => {
|
||||
is_aarch64_feature_detected!($t);
|
||||
};
|
||||
($t:tt) => { compile_error!(concat!("unknown aarch64 target feature: ", $t)) };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ macro_rules! is_arm_feature_detected {
|
|||
("vfp2") => { compile_error!("\"vfp2\" feature cannot be detected at run-time") };
|
||||
("vfp3") => { compile_error!("\"vfp3\" feature cannot be detected at run-time") };
|
||||
("vfp4") => { compile_error!("\"vfp4\" feature cannot be detected at run-time") };
|
||||
($t:tt,) => {
|
||||
is_arm_feature_detected!($t);
|
||||
};
|
||||
($t:tt) => { compile_error!(concat!("unknown arm target feature: ", $t)) };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ macro_rules! is_mips_feature_detected {
|
|||
cfg!(target_feature = "msa") ||
|
||||
$crate::detect::check_for($crate::detect::Feature::msa)
|
||||
};
|
||||
($t:tt,) => {
|
||||
is_mips_feature_detected!($t);
|
||||
};
|
||||
($t:tt) => { compile_error!(concat!("unknown mips target feature: ", $t)) };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ macro_rules! is_mips64_feature_detected {
|
|||
cfg!(target_feature = "msa") ||
|
||||
$crate::detect::check_for($crate::detect::Feature::msa)
|
||||
};
|
||||
($t:tt,) => {
|
||||
is_mips64_feature_detected!($t);
|
||||
};
|
||||
($t:tt) => { compile_error!(concat!("unknown mips64 target feature: ", $t)) };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ macro_rules! is_powerpc_feature_detected {
|
|||
cfg!(target_feature = "power8") ||
|
||||
$crate::detect::check_for($crate::detect::Feature::power8)
|
||||
};
|
||||
($t:tt,) => {
|
||||
is_powerpc_feature_detected!($t);
|
||||
};
|
||||
($t:tt) => { compile_error!(concat!("unknown powerpc target feature: ", $t)) };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ macro_rules! is_powerpc64_feature_detected {
|
|||
cfg!(target_feature = "power8") ||
|
||||
$crate::detect::check_for($crate::detect::Feature::power8)
|
||||
};
|
||||
($t:tt,) => {
|
||||
is_powerpc64_feature_detected!($t);
|
||||
};
|
||||
($t:tt) => { compile_error!(concat!("unknown powerpc64 target feature: ", $t)) };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -234,6 +234,9 @@ macro_rules! is_x86_feature_detected {
|
|||
cfg!(target_feature = "adx") || $crate::detect::check_for(
|
||||
$crate::detect::Feature::adx)
|
||||
};
|
||||
($t:tt,) => {
|
||||
is_x86_feature_detected!($t);
|
||||
};
|
||||
($t:tt) => {
|
||||
compile_error!(concat!("unknown target feature: ", $t))
|
||||
};
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
#![feature(stdsimd)]
|
||||
#![cfg_attr(stdsimd_strict, deny(warnings))]
|
||||
#![cfg_attr(
|
||||
feature = "cargo-clippy",
|
||||
allow(clippy::option_unwrap_used, clippy::use_debug, clippy::print_stdout)
|
||||
)]
|
||||
|
||||
#[cfg(any(
|
||||
target_arch = "arm",
|
||||
target_arch = "aarch64",
|
||||
target_arch = "x86",
|
||||
target_arch = "x86_64",
|
||||
target_arch = "powerpc",
|
||||
target_arch = "powerpc64"
|
||||
))]
|
||||
#[macro_use]
|
||||
extern crate std_detect;
|
||||
|
||||
#[test]
|
||||
#[cfg(all(target_arch = "arm", any(target_os = "linux", target_os = "android")))]
|
||||
fn arm_linux() {
|
||||
let _ = is_arm_feature_detected!("neon");
|
||||
let _ = is_arm_feature_detected!("neon",);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(
|
||||
target_arch = "aarch64",
|
||||
any(target_os = "linux", target_os = "android")
|
||||
))]
|
||||
fn aarch64_linux() {
|
||||
let _ = is_aarch64_feature_detected!("fp");
|
||||
let _ = is_aarch64_feature_detected!("fp",);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(target_arch = "powerpc", target_os = "linux"))]
|
||||
fn powerpc_linux() {
|
||||
let _ = is_powerpc_feature_detected!("altivec");
|
||||
let _ = is_powerpc_feature_detected!("altivec",);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(target_arch = "powerpc64", target_os = "linux"))]
|
||||
fn powerpc64_linux() {
|
||||
let _ = is_powerpc64_feature_detected!("altivec");
|
||||
let _ = is_powerpc64_feature_detected!("altivec",);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
|
||||
fn x86_all() {
|
||||
let _ = is_x86_feature_detected!("sse");
|
||||
let _ = is_x86_feature_detected!("sse",);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue