File tree Expand file tree Collapse file tree 10 files changed +17
-63
lines changed
crates/std_detect/src/detect Expand file tree Collapse file tree 10 files changed +17
-63
lines changed Original file line number Diff line number Diff line change @@ -90,4 +90,9 @@ cfg_if! {
9090 mod os;
9191 }
9292}
93- pub use self :: os:: check_for;
93+
94+ /// Performs run-time feature detection.
95+ #[ inline]
96+ pub fn check_for ( x : Feature ) -> bool {
97+ cache:: test ( x as u32 , self :: os:: detect_features)
98+ }
Original file line number Diff line number Diff line change 11//! Run-time feature detection for Aarch64 on FreeBSD.
22
3- use crate :: detect:: { Feature , cache} ;
4- use super :: super :: aarch64:: detect_features;
5-
6- /// Performs run-time feature detection.
7- #[ inline]
8- pub fn check_for ( x : Feature ) -> bool {
9- cache:: test ( x as u32 , detect_features)
10- }
3+ pub use super :: super :: aarch64:: detect_features;
114
125#[ cfg( test) ]
136mod tests {
Original file line number Diff line number Diff line change 33use crate :: detect:: { Feature , cache} ;
44use super :: { auxvec} ;
55
6- /// Performs run-time feature detection.
7- #[ inline]
8- pub fn check_for ( x : Feature ) -> bool {
9- cache:: test ( x as u32 , detect_features)
10- }
11-
126/// Try to read the features from the auxiliary vector
13- fn detect_features ( ) -> cache:: Initializer {
7+ pub ( crate ) fn detect_features ( ) -> cache:: Initializer {
148 let mut value = cache:: Initializer :: default ( ) ;
159 let enable_feature = |value : & mut cache:: Initializer , f, enable| {
1610 if enable {
Original file line number Diff line number Diff line change 33use crate :: detect:: { Feature , cache} ;
44use super :: { auxvec} ;
55
6- /// Performs run-time feature detection.
7- #[ inline]
8- pub fn check_for ( x : Feature ) -> bool {
9- cache:: test ( x as u32 , detect_features)
10- }
11-
12- fn detect_features ( ) -> cache:: Initializer {
6+ pub ( crate ) fn detect_features ( ) -> cache:: Initializer {
137 let mut value = cache:: Initializer :: default ( ) ;
148 let enable_feature = |value : & mut cache:: Initializer , f, enable| {
159 if enable {
Original file line number Diff line number Diff line change 33use crate :: detect:: { Feature , cache, bit} ;
44use super :: { auxvec, cpuinfo} ;
55
6- /// Performs run-time feature detection.
7- #[ inline]
8- pub fn check_for ( x : Feature ) -> bool {
9- cache:: test ( x as u32 , detect_features)
10- }
11-
126/// Try to read the features from the auxiliary vector, and if that fails, try
137/// to read them from /proc/cpuinfo.
14- fn detect_features ( ) -> cache:: Initializer {
8+ pub ( crate ) fn detect_features ( ) -> cache:: Initializer {
159 if let Ok ( auxv) = auxvec:: auxv ( ) {
1610 let hwcap: AtHwcap = auxv. into ( ) ;
1711 return hwcap. cache ( ) ;
Original file line number Diff line number Diff line change 33use crate :: detect:: { Feature , cache, bit} ;
44use super :: { auxvec, cpuinfo} ;
55
6- /// Performs run-time feature detection.
7- #[ inline]
8- pub fn check_for ( x : Feature ) -> bool {
9- cache:: test ( x as u32 , detect_features)
10- }
11-
126/// Try to read the features from the auxiliary vector, and if that fails, try
137/// to read them from /proc/cpuinfo.
14- fn detect_features ( ) -> cache:: Initializer {
8+ pub ( crate ) fn detect_features ( ) -> cache:: Initializer {
159 let mut value = cache:: Initializer :: default ( ) ;
1610 let enable_feature = |value : & mut cache:: Initializer , f, enable| {
1711 if enable {
Original file line number Diff line number Diff line change 33use crate :: detect:: { Feature , cache, bit} ;
44use super :: auxvec;
55
6- /// Performs run-time feature detection.
7- #[ inline]
8- pub fn check_for ( x : Feature ) -> bool {
9- cache:: test ( x as u32 , detect_features)
10- }
11-
126/// Try to read the features from the auxiliary vector, and if that fails, try
137/// to read them from `/proc/cpuinfo`.
14- fn detect_features ( ) -> cache:: Initializer {
8+ pub ( crate ) fn detect_features ( ) -> cache:: Initializer {
159 let mut value = cache:: Initializer :: default ( ) ;
1610 let enable_feature = |value : & mut cache:: Initializer , f, enable| {
1711 if enable {
Original file line number Diff line number Diff line change 33use crate :: detect:: { Feature , cache} ;
44use super :: { auxvec, cpuinfo} ;
55
6- /// Performs run-time feature detection.
7- #[ inline]
8- pub fn check_for ( x : Feature ) -> bool {
9- cache:: test ( x as u32 , detect_features)
10- }
11-
126/// Try to read the features from the auxiliary vector, and if that fails, try
137/// to read them from /proc/cpuinfo.
14- fn detect_features ( ) -> cache:: Initializer {
8+ pub ( crate ) fn detect_features ( ) -> cache:: Initializer {
159 let mut value = cache:: Initializer :: default ( ) ;
1610 let enable_feature = |value : & mut cache:: Initializer , f, enable| {
1711 if enable {
Original file line number Diff line number Diff line change 11//! Other operating systems
22
3- use crate :: detect:: Feature ;
3+ use crate :: detect:: cache ;
44
5- /// Performs run-time feature detection.
6- #[ inline]
7- pub fn check_for ( _x : Feature ) -> bool {
8- false
5+ pub ( crate ) fn detect_features ( ) -> cache:: Initializer {
6+ cache:: Initializer :: default ( )
97}
Original file line number Diff line number Diff line change @@ -9,12 +9,6 @@ use crate::mem;
99
1010use crate :: detect:: { Feature , cache, bit} ;
1111
12- /// Performs run-time feature detection.
13- #[ inline]
14- pub fn check_for ( x : Feature ) -> bool {
15- cache:: test ( x as u32 , detect_features)
16- }
17-
1812/// Run-time feature detection on x86 works by using the CPUID instruction.
1913///
2014/// The [CPUID Wikipedia page][wiki_cpuid] contains
@@ -31,7 +25,7 @@ pub fn check_for(x: Feature) -> bool {
3125/// [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
3226/// [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf
3327#[ allow( clippy:: similar_names) ]
34- fn detect_features ( ) -> cache:: Initializer {
28+ pub ( crate ) fn detect_features ( ) -> cache:: Initializer {
3529 let mut value = cache:: Initializer :: default ( ) ;
3630
3731 // If the x86 CPU does not support the CPUID instruction then it is too
You can’t perform that action at this time.
0 commit comments