Skip to content

Commit

Permalink
Implement pause support for RISC-V
Browse files Browse the repository at this point in the history
  • Loading branch information
XieJiSS authored Oct 24, 2023
1 parent 6ec7f68 commit 38fa369
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/boost/atomic/detail/pause.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ BOOST_FORCEINLINE void pause() BOOST_NOEXCEPT
__asm__ __volatile__("pause;" : : : "memory");
#elif (defined(__ARM_ARCH) && __ARM_ARCH >= 8) || defined(__ARM_ARCH_8A__) || defined(__aarch64__)
__asm__ __volatile__("yield;" : : : "memory");
#elif defined(__riscv) && __riscv_xlen == 64
#if defined(__riscv_zihintpause)
__asm__ __volatile__("pause" : : : "memory");
#elif defined(__riscv_muldiv)
/* In lieu of a halt instruction, induce a long-latency stall. */
__asm__ __volatile__("div %0, %0, zero" : "=r" (dummy));
#else
/* Encoding of the pause instruction */
__asm__ __volatile__ (".4byte 0x100000F");
#endif
#endif
#endif
}
Expand Down

0 comments on commit 38fa369

Please sign in to comment.