From 963ecc82d0988f9bbaef07a6939d774dfd027b7c Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Sat, 19 Jun 2021 05:47:24 +0200 Subject: [PATCH] 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 Reviewed-By: Jameson Nash --- src/unix/atomic-ops.h | 6 ++++-- 1 file 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 }