From 02a28f1d4451839abfc38e0c437cda438811172f Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 7 Apr 2020 07:39:38 -0400 Subject: libuv: Restore compilation with XLClang 16.1 on AIX libuv upstream commit `4a972bf0` (aix: Fix broken cmpxchgi() XL C++ specialization., 2019-09-06, v1.32.0~5) broke compilation with this compiler. According to https://www.ibm.com/support/knowledgecenter/SSGH3R_16.1.0/com.ibm.xlcpp161.aix.doc/migrate/migrate_to_xlclang.html XLClang 16.1 for AIX does not support `__sync_val_compare_and_swap`. The documentation suggests using C++11 atomic operations instead, but this is C code. For now fall back to the non-atomic equivalent used before so we can at least compile. Add a FIXME comment for this. --- Utilities/cmlibuv/src/unix/atomic-ops.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Utilities/cmlibuv/src/unix/atomic-ops.h b/Utilities/cmlibuv/src/unix/atomic-ops.h index bc37c0d..7efed02 100644 --- a/Utilities/cmlibuv/src/unix/atomic-ops.h +++ b/Utilities/cmlibuv/src/unix/atomic-ops.h @@ -36,6 +36,12 @@ UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) { : "r" (newval), "0" (oldval) : "memory"); return out; +#elif defined(_AIX) && defined(__ibmxl__) + /* FIXME: This is not actually atomic but XLClang 16.1 for AIX + does not provide __sync_val_compare_and_swap or an equivalent. + Its documentation suggests using C++11 atomics but this is C. */ + __compare_and_swap((volatile int*)ptr, &oldval, newval); + return oldval; #elif defined(__MVS__) unsigned int op4; if (__plo_CSST(ptr, (unsigned int*) &oldval, newval, -- cgit v0.12