Skip to content

Commit bca0a0a

Browse files
std_detect on Darwin: add new-style detection for FEAT_CRC32
Now that this feature has a standard identifier, Darwin has started exposing it accordingly, in addition to the existing less-standard way. Check both, and enable the `crc` feature if either identifier for it is present to ensure backwards and forwards compatibility.
1 parent 7ad23f4 commit bca0a0a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

library/std_detect/src/detect/os/darwin/aarch64.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,14 @@ pub(crate) fn detect_features() -> cache::Initializer {
3737
// Armv8.0 features not using the standard identifiers
3838
let fp = _sysctlbyname(c"hw.optional.floatingpoint");
3939
let asimd = _sysctlbyname(c"hw.optional.AdvSIMD");
40-
let crc = _sysctlbyname(c"hw.optional.armv8_crc32");
40+
let crc_old = _sysctlbyname(c"hw.optional.armv8_crc32");
4141

4242
// Armv8 and Armv9 features using the standard identifiers
4343
let aes = _sysctlbyname(c"hw.optional.arm.FEAT_AES");
4444
let bf16 = _sysctlbyname(c"hw.optional.arm.FEAT_BF16");
4545
let bti = _sysctlbyname(c"hw.optional.arm.FEAT_BTI");
4646
let cssc = _sysctlbyname(c"hw.optional.arm.FEAT_CSSC");
47+
let crc = _sysctlbyname(c"hw.optional.arm.FEAT_CRC32");
4748
let dit = _sysctlbyname(c"hw.optional.arm.FEAT_DIT");
4849
let dpb = _sysctlbyname(c"hw.optional.arm.FEAT_DPB");
4950
let dpb2 = _sysctlbyname(c"hw.optional.arm.FEAT_DPB2");
@@ -111,7 +112,7 @@ pub(crate) fn detect_features() -> cache::Initializer {
111112
enable_feature(Feature::asimd, asimd);
112113
enable_feature(Feature::bf16, bf16);
113114
enable_feature(Feature::bti, bti);
114-
enable_feature(Feature::crc, crc);
115+
enable_feature(Feature::crc, crc_old || crc);
115116
enable_feature(Feature::cssc, cssc);
116117
enable_feature(Feature::dit, dit);
117118
enable_feature(Feature::dotprod, dotprod);

0 commit comments

Comments
 (0)