From 841edfcd40fb2243ca434f7b87c0e10d1a40c7c1 Mon Sep 17 00:00:00 2001 From: John Barboza Date: Sun, 21 Aug 2016 13:53:29 -0400 Subject: [PATCH] zos: use PLO instruction for atomic operations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use builtins provided that perform compare and swap operations using the PLO instruction. PR-URL: https://github.com/libuv/libuv/pull/1008 Reviewed-By: Ben Noordhuis Reviewed-By: Saúl Ibarra Corretgé --- src/unix/atomic-ops.h | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/unix/atomic-ops.h b/src/unix/atomic-ops.h index 334c343e..815e3552 100644 --- a/src/unix/atomic-ops.h +++ b/src/unix/atomic-ops.h @@ -43,9 +43,8 @@ UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) { __compare_and_swap(ptr, &oldval, newval); return out; #elif defined(__MVS__) - const int out = (*(volatile int*) ptr); - cs((cs_t*)&oldval, (cs_t*)ptr, *(cs_t*)(&newval)); - return out; + return __plo_CS(ptr, (unsigned int*) ptr, + oldval, (unsigned int*) &newval); #else return __sync_val_compare_and_swap(ptr, oldval, newval); #endif @@ -68,13 +67,13 @@ UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)) { # endif /* if defined(__64BIT__) */ return out; #elif defined (__MVS__) - const long out = (*(volatile int*) ptr); # ifdef _LP64 - cds((cds_t*)(&oldval), (cds_t*)ptr, *(cds_t*)(&newval)); + return __plo_CSGR(ptr, (unsigned long long*) ptr, + oldval, (unsigned long long*) &newval); # else - cs((cs_t*)&oldval, (cs_t*)ptr, *(cs_t*)(&newval)); + return __plo_CS(ptr, (unsigned int*) ptr, + oldval, (unsigned int*) &newval); # endif - return out; #else return __sync_val_compare_and_swap(ptr, oldval, newval); #endif