Skip to content

Commit

Permalink
Rollup merge of rust-lang#91548 - luojia65:hint-spin-loop-riscv, r=Am…
Browse files Browse the repository at this point in the history
…anieu

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.
  • Loading branch information
matthiaskrgr authored Dec 8, 2021
2 parents a713341 + 70855b2 commit 22afb94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions library/core/src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ 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
Expand Down

0 comments on commit 22afb94

Please sign in to comment.