summaryrefslogtreecommitdiff
path: root/Utilities/cmlibuv/src/unix/atomic-ops.h
diff options
context:
space:
mode:
Diffstat (limited to 'Utilities/cmlibuv/src/unix/atomic-ops.h')
-rw-r--r--Utilities/cmlibuv/src/unix/atomic-ops.h40
1 files changed, 3 insertions, 37 deletions
diff --git a/Utilities/cmlibuv/src/unix/atomic-ops.h b/Utilities/cmlibuv/src/unix/atomic-ops.h
index 9dac2557f..995aca63a 100644
--- a/Utilities/cmlibuv/src/unix/atomic-ops.h
+++ b/Utilities/cmlibuv/src/unix/atomic-ops.h
@@ -20,11 +20,9 @@
#if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
#include <atomic.h>
-#define __sync_val_compare_and_swap(p, o, n) atomic_cas_ptr(p, o, n)
#endif
UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval));
-UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval));
UV_UNUSED(static void cpu_relax(void));
/* Prefer hand-rolled assembly over the gcc builtins because the latter also
@@ -38,7 +36,7 @@ UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) {
: "r" (newval), "0" (oldval)
: "memory");
return out;
-#elif defined(_AIX) && defined(__xlC__)
+#elif defined(_AIX) && (defined(__xlC__) || defined(__ibmxl__))
const int out = (*(volatile int*) ptr);
__compare_and_swap(ptr, &oldval, newval);
return out;
@@ -49,40 +47,8 @@ UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) {
return oldval;
else
return op4;
-#else
- return __sync_val_compare_and_swap(ptr, oldval, newval);
-#endif
-}
-
-UV_UNUSED(static long cmpxchgl(long* ptr, long oldval, long newval)) {
-#if defined(__i386__) || defined(__x86_64__)
- long out;
- __asm__ __volatile__ ("lock; cmpxchg %2, %1;"
- : "=a" (out), "+m" (*(volatile long*) ptr)
- : "r" (newval), "0" (oldval)
- : "memory");
- return out;
-#elif defined(_AIX) && defined(__xlC__)
- const long out = (*(volatile int*) ptr);
-# if defined(__64BIT__)
- __compare_and_swaplp(ptr, &oldval, newval);
-# else
- __compare_and_swap(ptr, &oldval, newval);
-# endif /* if defined(__64BIT__) */
- return out;
-#elif defined (__MVS__)
-#ifdef _LP64
- unsigned long long op4;
- if (__plo_CSSTGR(ptr, (unsigned long long*) &oldval, newval,
- (unsigned long long*) ptr, *ptr, &op4))
-#else
- unsigned long op4;
- if (__plo_CSST(ptr, (unsigned int*) &oldval, newval,
- (unsigned int*) ptr, *ptr, &op4))
-#endif
- return oldval;
- else
- return op4;
+#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+ return atomic_cas_uint((uint_t *)ptr, (uint_t)oldval, (uint_t)newval);
#else
return __sync_val_compare_and_swap(ptr, oldval, newval);
#endif