Skip to content

Commit

Permalink
feat: add pause support for riscv
Browse files Browse the repository at this point in the history
  • Loading branch information
XieJiSS committed Feb 28, 2024
1 parent 3660086 commit 2780c18
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions external/atomic_queue/include/atomic_queue/defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ static inline void spin_loop_pause() noexcept {
defined(__ARM_ARCH_8A__) || \
defined(__aarch64__))
asm volatile ("yield" ::: "memory");
#elif defined(__riscv)
#if defined(__riscv_zihintpause)
asm volatile ("pause" ::: "memory");
#else
/* Encoding of the pause instruction, will be treated as nop if not supported by hardware */
asm volatile (".4byte 0x100000F");
#else
asm volatile ("nop" ::: "memory");
#endif
Expand Down

0 comments on commit 2780c18

Please sign in to comment.