Skip to content

Commit 31de3c9

Browse files
committed
Memory order for atomic locks, needs resolution with upstream
Signed-off-by: Joseph Schuchart <schuchart@icl.utk.edu>
1 parent dd1b58f commit 31de3c9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

opal/include/opal/sys/atomic_stdc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static inline void opal_atomic_wmb(void)
7070

7171
static inline void opal_atomic_rmb(void)
7272
{
73-
# if OPAL_ASSEMBLY_ARCH == OPAL_X86_64
73+
# if OPAL_ASSEMBLY_ARCH == OPAL_X86_64 && defined(PLATFORM_COMPILER_GNU) && __GNUC__ < 8
7474
/* work around a bug in older gcc versions (observed in gcc 6.x)
7575
* where acquire seems to get treated as a no-op instead of being
7676
* equivalent to __asm__ __volatile__("": : :"memory") on x86_64 */
@@ -241,12 +241,12 @@ typedef atomic_flag opal_atomic_lock_t;
241241
*/
242242
static inline void opal_atomic_lock_init(opal_atomic_lock_t *lock, bool value)
243243
{
244-
atomic_flag_clear(lock);
244+
atomic_flag_clear_explicit(lock, memory_order_relaxed);
245245
}
246246

247247
static inline int opal_atomic_trylock(opal_atomic_lock_t *lock)
248248
{
249-
return (int) atomic_flag_test_and_set(lock);
249+
return (int) atomic_flag_test_and_set_explicit(lock, memory_order_acquire);
250250
}
251251

252252
static inline void opal_atomic_lock(opal_atomic_lock_t *lock)
@@ -257,7 +257,7 @@ static inline void opal_atomic_lock(opal_atomic_lock_t *lock)
257257

258258
static inline void opal_atomic_unlock(opal_atomic_lock_t *lock)
259259
{
260-
atomic_flag_clear(lock);
260+
atomic_flag_clear_explicit(lock, memory_order_release);
261261
}
262262

263263
# if OPAL_HAVE_C11_CSWAP_INT128

0 commit comments

Comments
 (0)