From b9f1ac6e7498384a9eb2d5b1a52d5b9f5f7b6218 Mon Sep 17 00:00:00 2001 From: Dan Heidinga Date: Thu, 23 May 2019 09:10:07 -0400 Subject: [PATCH] Reorder defines so xlC16 finds the xlc before gnu xlC16 appears to be based on clang and now recognizes the __GNUC__ defines. Reorder this code so that the compiler sees the __xlC__-specific case first. issue: #3775 Signed-off-by: Dan Heidinga --- include_core/AtomicSupport.hpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/include_core/AtomicSupport.hpp b/include_core/AtomicSupport.hpp index 32b12c58dfc..6ca1671cb79 100644 --- a/include_core/AtomicSupport.hpp +++ b/include_core/AtomicSupport.hpp @@ -396,7 +396,10 @@ class VM_AtomicSupport #if defined(OMRZTPF) cs((cs_t *)&oldValue, (cs_t *)address, (cs_t)newValue); return oldValue; -#elif defined(__GNUC__) /* defined(OMRZTPF) */ +#elif defined(__xlC__) /* defined(OMRZTPF) */ + __compare_and_swap((volatile int*)address, (int*)&oldValue, (int)newValue); + return oldValue; +#elif defined(__GNUC__) /* defined(__xlC__) */ /* Assume GCC >= 4.2 */ return __sync_val_compare_and_swap(address, oldValue, newValue); #elif defined(_MSC_VER) /* defined(__GNUC__) */ @@ -410,7 +413,7 @@ class VM_AtomicSupport #elif defined(__xlC__) /* defined(J9ZOS390) */ __compare_and_swap((volatile int*)address, (int*)&oldValue, (int)newValue); return oldValue; -#else /* defined(__xlC__) */ +#else /* defined(J9ZOS390) */ #error "lockCompareExchangeU32(): unsupported platform!" #endif /* defined(__xlC__) */ #endif /* defined(ATOMIC_SUPPORT_STUB) */ @@ -453,7 +456,10 @@ class VM_AtomicSupport #elif defined(OMRZTPF) /* defined(OMR_ARCH_POWER) && !defined(OMR_ENV_DATA64) */ csg((csg_t *)&oldValue, (csg_t *)address, (csg_t)newValue); return oldValue; -#elif defined(__GNUC__) /* defined(OMRZTPF) */ +#elif defined(__xlC__) /* defined(OMRZTPF) */ + __compare_and_swaplp((volatile long*)address, (long*)&oldValue, (long)newValue); + return oldValue; +#elif defined(__GNUC__) /* defined(__xlC__) */ /* Assume GCC >= 4.2 */ return __sync_val_compare_and_swap(address, oldValue, newValue); #elif defined(_MSC_VER) /* defined(__GNUC__) */ @@ -470,10 +476,7 @@ class VM_AtomicSupport cds((cds_t*)&old, (cds_t*)address, *(cds_t*)&newValue); return old; #endif /* defined(OMR_ENV_DATA64) */ -#elif defined(__xlC__) /* defined(J9ZOS390) */ - __compare_and_swaplp((volatile long*)address, (long*)&oldValue, (long)newValue); - return oldValue; -#else /* defined(__xlC__) */ +#else /* defined(J9ZOS390) */ #error "lockCompareExchangeU64(): unsupported platform!" #endif /* defined(__xlC__) */ #endif /* defined(ATOMIC_SUPPORT_STUB) */