Skip to content

Commit 79d17fb

Browse files
authored
Rollup merge of rust-lang#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 4daa737 + 4fec8c4 commit 79d17fb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

core/src/hint.rs

Lines changed: 5 additions & 0 deletions
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

stdarch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit cfba59fccd90b3b52a614120834320f764ab08d1
1+
Subproject commit b70ae88ef2a6c83acad0a1e83d5bd78f9655fd05

0 commit comments

Comments
 (0)