about summary refs log tree commit diff
path: root/library/stdarch/crates
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2019-09-09 11:45:41 +0200
committergnzlbg <gnzlbg@users.noreply.github.com>2019-09-09 22:20:10 +0200
commitf3140f4b25860a1aa6257c6afc064efe177b0b67 (patch)
tree8f3203c395f3fe7b4aff87449d04606e958cfa7b /library/stdarch/crates
parent5b11935d4331f9a908f00359cc3e96e99e055be1 (diff)
downloadrust-f3140f4b25860a1aa6257c6afc064efe177b0b67.tar.gz
rust-f3140f4b25860a1aa6257c6afc064efe177b0b67.zip
Factor out check_for
All the os-specific code implements a `check_for` and a `detect_features`.

Move the always identical check_for in the mod.rs and use
`os::detect_features` there.
Diffstat (limited to 'library/stdarch/crates')
-rw-r--r--library/stdarch/crates/std_detect/src/detect/mod.rs7
-rw-r--r--library/stdarch/crates/std_detect/src/detect/os/freebsd/aarch64.rs9
-rw-r--r--library/stdarch/crates/std_detect/src/detect/os/freebsd/arm.rs8
-rw-r--r--library/stdarch/crates/std_detect/src/detect/os/freebsd/powerpc.rs8
-rw-r--r--library/stdarch/crates/std_detect/src/detect/os/linux/aarch64.rs8
-rw-r--r--library/stdarch/crates/std_detect/src/detect/os/linux/arm.rs8
-rw-r--r--library/stdarch/crates/std_detect/src/detect/os/linux/mips.rs8
-rw-r--r--library/stdarch/crates/std_detect/src/detect/os/linux/powerpc.rs8
-rw-r--r--library/stdarch/crates/std_detect/src/detect/os/other.rs8
-rw-r--r--library/stdarch/crates/std_detect/src/detect/os/x86.rs8
10 files changed, 17 insertions, 63 deletions
diff --git a/library/stdarch/crates/std_detect/src/detect/mod.rs b/library/stdarch/crates/std_detect/src/detect/mod.rs
index 80207daad8f..3e00c205547 100644
--- a/library/stdarch/crates/std_detect/src/detect/mod.rs
+++ b/library/stdarch/crates/std_detect/src/detect/mod.rs
@@ -90,4 +90,9 @@ cfg_if! {
         mod os;
     }
 }
-pub use self::os::check_for;
+
+/// Performs run-time feature detection.
+#[inline]
+pub fn check_for(x: Feature) -> bool {
+    cache::test(x as u32, self::os::detect_features)
+}
diff --git a/library/stdarch/crates/std_detect/src/detect/os/freebsd/aarch64.rs b/library/stdarch/crates/std_detect/src/detect/os/freebsd/aarch64.rs
index 910d2f33b39..e5df9ba4c9b 100644
--- a/library/stdarch/crates/std_detect/src/detect/os/freebsd/aarch64.rs
+++ b/library/stdarch/crates/std_detect/src/detect/os/freebsd/aarch64.rs
@@ -1,13 +1,6 @@
 //! Run-time feature detection for Aarch64 on FreeBSD.
 
-use crate::detect::{Feature, cache};
-use super::super::aarch64::detect_features;
-
-/// Performs run-time feature detection.
-#[inline]
-pub fn check_for(x: Feature) -> bool {
-    cache::test(x as u32, detect_features)
-}
+pub use super::super::aarch64::detect_features;
 
 #[cfg(test)]
 mod tests {
diff --git a/library/stdarch/crates/std_detect/src/detect/os/freebsd/arm.rs b/library/stdarch/crates/std_detect/src/detect/os/freebsd/arm.rs
index e13847dcbd8..38e37721ef3 100644
--- a/library/stdarch/crates/std_detect/src/detect/os/freebsd/arm.rs
+++ b/library/stdarch/crates/std_detect/src/detect/os/freebsd/arm.rs
@@ -3,14 +3,8 @@
 use crate::detect::{Feature, cache};
 use super::{auxvec};
 
-/// Performs run-time feature detection.
-#[inline]
-pub fn check_for(x: Feature) -> bool {
-    cache::test(x as u32, detect_features)
-}
-
 /// Try to read the features from the auxiliary vector
-fn detect_features() -> cache::Initializer {
+pub(crate) fn detect_features() -> cache::Initializer {
     let mut value = cache::Initializer::default();
     let enable_feature = |value: &mut cache::Initializer, f, enable| {
         if enable {
diff --git a/library/stdarch/crates/std_detect/src/detect/os/freebsd/powerpc.rs b/library/stdarch/crates/std_detect/src/detect/os/freebsd/powerpc.rs
index c7f761d4d60..52a71e672a3 100644
--- a/library/stdarch/crates/std_detect/src/detect/os/freebsd/powerpc.rs
+++ b/library/stdarch/crates/std_detect/src/detect/os/freebsd/powerpc.rs
@@ -3,13 +3,7 @@
 use crate::detect::{Feature, cache};
 use super::{auxvec};
 
-/// Performs run-time feature detection.
-#[inline]
-pub fn check_for(x: Feature) -> bool {
-    cache::test(x as u32, detect_features)
-}
-
-fn detect_features() -> cache::Initializer {
+pub(crate) fn detect_features() -> cache::Initializer {
     let mut value = cache::Initializer::default();
     let enable_feature = |value: &mut cache::Initializer, f, enable| {
         if enable {
diff --git a/library/stdarch/crates/std_detect/src/detect/os/linux/aarch64.rs b/library/stdarch/crates/std_detect/src/detect/os/linux/aarch64.rs
index f7dc0f0222e..43c0976daf3 100644
--- a/library/stdarch/crates/std_detect/src/detect/os/linux/aarch64.rs
+++ b/library/stdarch/crates/std_detect/src/detect/os/linux/aarch64.rs
@@ -3,15 +3,9 @@
 use crate::detect::{Feature, cache, bit};
 use super::{auxvec, cpuinfo};
 
-/// Performs run-time feature detection.
-#[inline]
-pub fn check_for(x: Feature) -> bool {
-    cache::test(x as u32, detect_features)
-}
-
 /// Try to read the features from the auxiliary vector, and if that fails, try
 /// to read them from /proc/cpuinfo.
-fn detect_features() -> cache::Initializer {
+pub(crate) fn detect_features() -> cache::Initializer {
     if let Ok(auxv) = auxvec::auxv() {
         let hwcap: AtHwcap = auxv.into();
         return hwcap.cache();
diff --git a/library/stdarch/crates/std_detect/src/detect/os/linux/arm.rs b/library/stdarch/crates/std_detect/src/detect/os/linux/arm.rs
index 0d58a847cd6..95624e1285d 100644
--- a/library/stdarch/crates/std_detect/src/detect/os/linux/arm.rs
+++ b/library/stdarch/crates/std_detect/src/detect/os/linux/arm.rs
@@ -3,15 +3,9 @@
 use crate::detect::{Feature, cache, bit};
 use super::{auxvec, cpuinfo};
 
-/// Performs run-time feature detection.
-#[inline]
-pub fn check_for(x: Feature) -> bool {
-    cache::test(x as u32, detect_features)
-}
-
 /// Try to read the features from the auxiliary vector, and if that fails, try
 /// to read them from /proc/cpuinfo.
-fn detect_features() -> cache::Initializer {
+pub(crate) fn detect_features() -> cache::Initializer {
     let mut value = cache::Initializer::default();
     let enable_feature = |value: &mut cache::Initializer, f, enable| {
         if enable {
diff --git a/library/stdarch/crates/std_detect/src/detect/os/linux/mips.rs b/library/stdarch/crates/std_detect/src/detect/os/linux/mips.rs
index c0a5fb2e5d8..6486673f805 100644
--- a/library/stdarch/crates/std_detect/src/detect/os/linux/mips.rs
+++ b/library/stdarch/crates/std_detect/src/detect/os/linux/mips.rs
@@ -3,15 +3,9 @@
 use crate::detect::{Feature, cache, bit};
 use super::auxvec;
 
-/// Performs run-time feature detection.
-#[inline]
-pub fn check_for(x: Feature) -> bool {
-    cache::test(x as u32, detect_features)
-}
-
 /// Try to read the features from the auxiliary vector, and if that fails, try
 /// to read them from `/proc/cpuinfo`.
-fn detect_features() -> cache::Initializer {
+pub(crate) fn detect_features() -> cache::Initializer {
     let mut value = cache::Initializer::default();
     let enable_feature = |value: &mut cache::Initializer, f, enable| {
         if enable {
diff --git a/library/stdarch/crates/std_detect/src/detect/os/linux/powerpc.rs b/library/stdarch/crates/std_detect/src/detect/os/linux/powerpc.rs
index 1c08a58443d..5be35b96dda 100644
--- a/library/stdarch/crates/std_detect/src/detect/os/linux/powerpc.rs
+++ b/library/stdarch/crates/std_detect/src/detect/os/linux/powerpc.rs
@@ -3,15 +3,9 @@
 use crate::detect::{Feature, cache};
 use super::{auxvec, cpuinfo};
 
-/// Performs run-time feature detection.
-#[inline]
-pub fn check_for(x: Feature) -> bool {
-    cache::test(x as u32, detect_features)
-}
-
 /// Try to read the features from the auxiliary vector, and if that fails, try
 /// to read them from /proc/cpuinfo.
-fn detect_features() -> cache::Initializer {
+pub(crate) fn detect_features() -> cache::Initializer {
     let mut value = cache::Initializer::default();
     let enable_feature = |value: &mut cache::Initializer, f, enable| {
         if enable {
diff --git a/library/stdarch/crates/std_detect/src/detect/os/other.rs b/library/stdarch/crates/std_detect/src/detect/os/other.rs
index 23e399ea790..bf7be87f073 100644
--- a/library/stdarch/crates/std_detect/src/detect/os/other.rs
+++ b/library/stdarch/crates/std_detect/src/detect/os/other.rs
@@ -1,9 +1,7 @@
 //! Other operating systems
 
-use crate::detect::Feature;
+use crate::detect::cache;
 
-/// Performs run-time feature detection.
-#[inline]
-pub fn check_for(_x: Feature) -> bool {
-    false
+pub(crate) fn detect_features() -> cache::Initializer {
+    cache::Initializer::default()
 }
diff --git a/library/stdarch/crates/std_detect/src/detect/os/x86.rs b/library/stdarch/crates/std_detect/src/detect/os/x86.rs
index 9257b8a4be6..d9d286071a2 100644
--- a/library/stdarch/crates/std_detect/src/detect/os/x86.rs
+++ b/library/stdarch/crates/std_detect/src/detect/os/x86.rs
@@ -9,12 +9,6 @@ use crate::mem;
 
 use crate::detect::{Feature, cache, bit};
 
-/// Performs run-time feature detection.
-#[inline]
-pub fn check_for(x: Feature) -> bool {
-    cache::test(x as u32, detect_features)
-}
-
 /// Run-time feature detection on x86 works by using the CPUID instruction.
 ///
 /// The [CPUID Wikipedia page][wiki_cpuid] contains
@@ -31,7 +25,7 @@ pub fn check_for(x: Feature) -> bool {
 /// [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf
 /// [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf
 #[allow(clippy::similar_names)]
-fn detect_features() -> cache::Initializer {
+pub(crate) fn detect_features() -> cache::Initializer {
     let mut value = cache::Initializer::default();
 
     // If the x86 CPU does not support the CPUID instruction then it is too