diff --git a/library/core/src/hint.rs b/library/core/src/hint.rs index 003391e52be6b..330c43d294835 100644 --- a/library/core/src/hint.rs +++ b/library/core/src/hint.rs @@ -123,6 +123,21 @@ pub fn spin_loop() { } } + // RISC-V platform spin loop hint implementation + { + // RISC-V RV32 and RV64 share the same PAUSE instruction, but they are located in different + // modules in `core::arch`. + // In this case, here we call `pause` function in each core arch module. + #[cfg(target_arch = "riscv32")] + { + crate::arch::riscv32::pause(); + } + #[cfg(target_arch = "riscv64")] + { + crate::arch::riscv64::pause(); + } + } + #[cfg(any(target_arch = "aarch64", all(target_arch = "arm", target_feature = "v6")))] { #[cfg(target_arch = "aarch64")] @@ -137,11 +152,6 @@ pub fn spin_loop() { unsafe { crate::arch::arm::__yield() }; } } - - #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] - { - crate::arch::riscv::pause(); - } } /// An identity function that *__hints__* to the compiler to be maximally pessimistic about what diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 22e721d79bfed..d5f9d20c426e2 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -556,6 +556,7 @@ pub use std_detect::*; pub use std_detect::{ is_aarch64_feature_detected, is_arm_feature_detected, is_mips64_feature_detected, is_mips_feature_detected, is_powerpc64_feature_detected, is_powerpc_feature_detected, + is_riscv_feature_detected, }; // Re-export macros defined in libcore. diff --git a/library/stdarch b/library/stdarch index 0716b22e90220..2adc17a544261 160000 --- a/library/stdarch +++ b/library/stdarch @@ -1 +1 @@ -Subproject commit 0716b22e902207efabe46879cbf28d0189ab7924 +Subproject commit 2adc17a5442614dbe34626fdd9b32de7c07b8086