aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2021-06-19 05:47:24 +0200
committerGitHub <noreply@github.com>2021-06-18 23:47:24 -0400
commit963ecc82d0988f9bbaef07a6939d774dfd027b7c (patch)
tree0d24c11fc187a5e415562b2ab960ceee7230d0be
parent9918a1743816dc49d6c664e41641d78ffd4a0705 (diff)
downloadlibuv-963ecc82d0988f9bbaef07a6939d774dfd027b7c.tar.gz
libuv-963ecc82d0988f9bbaef07a6939d774dfd027b7c.zip
unix: implement cpu_relax() on ppc64
We also tell the compiler it is not allowed to reorder the PAUSE instruction relative to other instructions. It is a mostly theoretical issue, but better safe than sorry. PR-URL: https://github.com/libuv/libuv/pull/2590 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Jameson Nash <vtjnash@gmail.com>
-rw-r--r--src/unix/atomic-ops.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/unix/atomic-ops.h b/src/unix/atomic-ops.h
index 347d1936..c48d0584 100644
--- a/src/unix/atomic-ops.h
+++ b/src/unix/atomic-ops.h
@@ -52,9 +52,11 @@ UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) {
UV_UNUSED(static void cpu_relax(void)) {
#if defined(__i386__) || defined(__x86_64__)
- __asm__ __volatile__ ("rep; nop"); /* a.k.a. PAUSE */
+ __asm__ __volatile__ ("rep; nop" ::: "memory"); /* a.k.a. PAUSE */
#elif (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__)
- __asm__ volatile("yield");
+ __asm__ __volatile__ ("yield" ::: "memory");
+#elif defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__)
+ __asm__ __volatile__ ("or 1,1,1; or 2,2,2" ::: "memory");
#endif
}