Skip to content

Commit 2356936

Browse files
authored
Rollup merge of #91548 - luojia65:hint-spin-loop-riscv, r=Amanieu
Add spin_loop hint for RISC-V architecture This commit uses the PAUSE instruction (rust-lang/stdarch#1262) to implement RISC-V spin loop, and updates `stdarch` submodule to use the merged PAUSE instruction.
2 parents b3d402e + 0ccf58b commit 2356936

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: library/core/src/hint.rs

+5
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ pub fn spin_loop() {
137137
unsafe { crate::arch::arm::__yield() };
138138
}
139139
}
140+
141+
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
142+
{
143+
crate::arch::riscv::pause();
144+
}
140145
}
141146

142147
/// An identity function that *__hints__* to the compiler to be maximally pessimistic about what

Diff for: library/stdarch

Submodule stdarch updated 39 files

0 commit comments

Comments
 (0)