Skip to content

Commit 0b9efd4

Browse files
authored
Merge pull request #8789 from ggouaillardet/topic/busted_atomic_revamps
atomic/gcc_builtin: only apply the workaround when required.
2 parents d4077a4 + 711c8c2 commit 0b9efd4

File tree

1 file changed

+9
-3
lines changed
  • opal/include/opal/sys/gcc_builtin

1 file changed

+9
-3
lines changed

opal/include/opal/sys/gcc_builtin/atomic.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,22 @@
5050
#define OPAL_HAVE_ATOMIC_SUB_64 1
5151
#define OPAL_HAVE_ATOMIC_SWAP_64 1
5252

53+
#if (OPAL_ASSEMBLY_ARCH == OPAL_X86_64) && defined (__GNUC__) && !defined(__llvm) && (__GNUC__ < 6)
54+
/* work around a bug in older gcc versions where ACQUIRE seems to get
55+
* treated as a no-op instead */
56+
#define OPAL_BUSTED_ATOMIC_MB 1
57+
#else
58+
#define OPAL_BUSTED_ATOMIC_MB 0
59+
#endif
60+
5361
static inline void opal_atomic_mb(void)
5462
{
5563
__atomic_thread_fence(__ATOMIC_SEQ_CST);
5664
}
5765

5866
static inline void opal_atomic_rmb(void)
5967
{
60-
#if OPAL_ASSEMBLY_ARCH == OPAL_X86_64
61-
/* work around a bug in older gcc versions where ACQUIRE seems to get
62-
* treated as a no-op instead */
68+
#if OPAL_BUSTED_ATOMIC_MB
6369
__asm__ __volatile__("" : : : "memory");
6470
#else
6571
__atomic_thread_fence(__ATOMIC_ACQUIRE);

0 commit comments

Comments
 (0)