Skip to content

Commit 12bc94b

Browse files
a4lgtaiki-e
andcommitted
RISC-V: tidying: Handling of base ISA
This commit makes handling of the base ISA a separate block. Co-Authored-By: Taiki Endo <[email protected]>
1 parent aec4669 commit 12bc94b

File tree

1 file changed

+14
-10
lines changed
  • crates/std_detect/src/detect/os/linux

1 file changed

+14
-10
lines changed

crates/std_detect/src/detect/os/linux/riscv.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,28 +44,32 @@ pub(crate) fn detect_features() -> cache::Initializer {
4444
&[Feature::f, Feature::zicsr],
4545
bit::test(auxv.hwcap, (b'f' - b'a').into()),
4646
);
47+
enable_feature(
48+
&mut value,
49+
Feature::h,
50+
bit::test(auxv.hwcap, (b'h' - b'a').into()),
51+
);
52+
enable_feature(
53+
&mut value,
54+
Feature::m,
55+
bit::test(auxv.hwcap, (b'm' - b'a').into()),
56+
);
57+
58+
// Handle base ISA.
4759
let has_i = bit::test(auxv.hwcap, (b'i' - b'a').into());
4860
// If future RV128I is supported, implement with `enable_feature` here
4961
#[cfg(target_pointer_width = "64")]
5062
enable_feature(&mut value, Feature::rv64i, has_i);
5163
#[cfg(target_pointer_width = "32")]
5264
enable_feature(&mut value, Feature::rv32i, has_i);
65+
// FIXME: e is not exposed in any of asm/hwcap.h, uapi/asm/hwcap.h, uapi/asm/hwprobe.h
5366
#[cfg(target_pointer_width = "32")]
5467
enable_feature(
5568
&mut value,
5669
Feature::rv32e,
5770
bit::test(auxv.hwcap, (b'e' - b'a').into()),
5871
);
59-
enable_feature(
60-
&mut value,
61-
Feature::h,
62-
bit::test(auxv.hwcap, (b'h' - b'a').into()),
63-
);
64-
enable_feature(
65-
&mut value,
66-
Feature::m,
67-
bit::test(auxv.hwcap, (b'm' - b'a').into()),
68-
);
72+
6973
// FIXME: Auxvec does not show supervisor feature support, but this mode may be useful
7074
// to detect when Rust is used to write Linux kernel modules.
7175
// These should be more than Auxvec way to detect supervisor features.

0 commit comments

Comments
 (0)