File tree 1 file changed +19
-0
lines changed
crates/std_detect/src/detect
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,12 @@ const fn test_bit(x: u64, bit: u32) -> bool {
23
23
x & ( 1 << bit) != 0
24
24
}
25
25
26
+ /// Unset the `bit of `x`.
27
+ #[ inline]
28
+ const fn unset_bit ( x : u64 , bit : u32 ) -> u64 {
29
+ x & !( 1 << bit)
30
+ }
31
+
26
32
/// Maximum number of features that can be cached.
27
33
const CACHE_CAPACITY : u32 = 63 ;
28
34
@@ -63,6 +69,19 @@ impl Initializer {
63
69
let v = self . 0 ;
64
70
self . 0 = set_bit ( v, bit) ;
65
71
}
72
+
73
+ /// Unsets the `bit` of the cache.
74
+ #[ inline]
75
+ pub ( crate ) fn unset ( & mut self , bit : u32 ) {
76
+ // FIXME: this way of making sure that the cache is large enough is
77
+ // brittle.
78
+ debug_assert ! (
79
+ bit < CACHE_CAPACITY ,
80
+ "too many features, time to increase the cache size!"
81
+ ) ;
82
+ let v = self . 0 ;
83
+ self . 0 = unset_bit ( v, bit) ;
84
+ }
66
85
}
67
86
68
87
/// This global variable is a cache of the features supported by the CPU.
You can’t perform that action at this time.
0 commit comments