@@ -37,8 +37,8 @@ pub fn getauxval_hwcap() -> u64 {
37
37
unsafe { libc:: getauxval ( libc:: AT_HWCAP ) }
38
38
}
39
39
40
- // MacOS runtime detection of target CPU features using `sysctlbyname`.
41
- #[ cfg( target_os = "macos " ) ]
40
+ // Apple platform's runtime detection of target CPU features using `sysctlbyname`.
41
+ #[ cfg( target_vendor = "apple " ) ]
42
42
#[ macro_export]
43
43
#[ doc( hidden) ]
44
44
macro_rules! __detect_target_features {
@@ -87,7 +87,7 @@ pub mod hwcaps {
87
87
pub const SHA3 : c_ulong = libc:: HWCAP_SHA3 | libc:: HWCAP_SHA512 ;
88
88
}
89
89
90
- // macOS `check!` macro.
90
+ // Apple OS ( macOS, iOS, watchOS, and tvOS) `check!` macro.
91
91
//
92
92
// NOTE: several of these instructions (e.g. `aes`, `sha2`) can be assumed to
93
93
// be present on all Apple ARM64 hardware.
@@ -98,7 +98,7 @@ pub mod hwcaps {
98
98
//
99
99
// See discussion on this issue for more information:
100
100
// <https://github.com/RustCrypto/utils/issues/378>
101
- #[ cfg( target_os = "macos " ) ]
101
+ #[ cfg( target_vendor = "apple " ) ]
102
102
#[ macro_export]
103
103
#[ doc( hidden) ]
104
104
macro_rules! check {
@@ -117,8 +117,8 @@ macro_rules! check {
117
117
} ;
118
118
}
119
119
120
- /// macOS helper function for calling `sysctlbyname`.
121
- #[ cfg( target_os = "macos " ) ]
120
+ /// Apple helper function for calling `sysctlbyname`.
121
+ #[ cfg( target_vendor = "apple " ) ]
122
122
pub unsafe fn sysctlbyname ( name : & [ u8 ] ) -> bool {
123
123
assert_eq ! (
124
124
name. last( ) . cloned( ) ,
@@ -143,36 +143,8 @@ pub unsafe fn sysctlbyname(name: &[u8]) -> bool {
143
143
value != 0
144
144
}
145
145
146
- // iOS `check!` macro.
147
- //
148
- // Unfortunately iOS does not provide access to the `sysctl(3)` API which means
149
- // we can only return static values for CPU features which can be assumed to
150
- // be present on all Apple ARM64 hardware.
151
- //
152
- // See discussion on this issue for more information:
153
- // <https://github.com/RustCrypto/utils/issues/378>
154
- #[ cfg( target_os = "ios" ) ]
155
- #[ macro_export]
156
- #[ doc( hidden) ]
157
- macro_rules! check {
158
- ( "aes" ) => {
159
- true
160
- } ;
161
- ( "sha2" ) => {
162
- true
163
- } ;
164
- ( "sha3" ) => {
165
- false
166
- } ;
167
- }
168
-
169
146
// On other targets, runtime CPU feature detection is unavailable
170
- #[ cfg( not( any(
171
- target_os = "ios" ,
172
- target_os = "linux" ,
173
- target_os = "android" ,
174
- target_os = "macos"
175
- ) ) ) ]
147
+ #[ cfg( not( any( target_vendor = "apple" , target_os = "linux" , target_os = "android" , ) ) ) ]
176
148
#[ macro_export]
177
149
#[ doc( hidden) ]
178
150
macro_rules! __detect_target_features {
0 commit comments