File 1133-Enable-__atomic-aquire-release-barriers-for-Apple-s-.patch of Package erlang

From c9ba20a537056d645025e1c0f574cc093e909b48 Mon Sep 17 00:00:00 2001
From: Rickard Green <rickard@erlang.org>
Date: Thu, 11 Feb 2021 01:54:00 +0100
Subject: [PATCH 3/3] Enable __atomic aquire/release barriers for Apple's clang
 as of v12.0.0

---
 erts/include/internal/gcc/ethread.h | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/erts/include/internal/gcc/ethread.h b/erts/include/internal/gcc/ethread.h
index 12b41f8704..0fb24445d0 100644
--- a/erts/include/internal/gcc/ethread.h
+++ b/erts/include/internal/gcc/ethread.h
@@ -44,6 +44,10 @@
 #undef ETHR_GCC_RELB_VERSIONS__
 #undef ETHR_GCC_RELB_MOD_VERSIONS__
 #undef ETHR_GCC_MB_MOD_VERSIONS__
+#undef ETHR_TRUST_GCC_ATOMIC_BUILTINS_MEMORY_BARRIERS__
+
+#define ETHR_TRUST_GCC_ATOMIC_BUILTINS_MEMORY_BARRIERS__ \
+    ETHR_TRUST_GCC_ATOMIC_BUILTINS_MEMORY_BARRIERS
 
 /*
  * True GNU GCCs before version 4.8 do not emit a memory barrier
@@ -52,15 +56,27 @@
  */
 #undef ETHR___atomic_load_ACQUIRE_barrier_bug
 #if ETHR_GCC_COMPILER != ETHR_GCC_COMPILER_TRUE
+     
+#if ETHR_GCC_COMPILER == ETHR_GCC_COMPILER_CLANG \
+    && defined(__apple_build_version__)          \
+    && __clang_major__ >= 12
+/* Apples clang verified not to have this bug */
+#    define ETHR___atomic_load_ACQUIRE_barrier_bug 0
+/* Also trust builtin barriers */
+#    undef ETHR_TRUST_GCC_ATOMIC_BUILTINS_MEMORY_BARRIERS__
+#    define ETHR_TRUST_GCC_ATOMIC_BUILTINS_MEMORY_BARRIERS__ 1
+#  else
 /*
- * A gcc compatible compiler. We have no information
+ * Another gcc compatible compiler. We have no information
  * about the existence of this bug, but we assume
  * that it is not impossible that it could have
  * been "inherited". Therefore, until we are certain
  * that the bug does not exist, we assume that it
  * does.
  */
-#  define ETHR___atomic_load_ACQUIRE_barrier_bug ETHR_GCC_VERSIONS_MASK__
+#    define ETHR___atomic_load_ACQUIRE_barrier_bug ETHR_GCC_VERSIONS_MASK__
+#  endif
+
 #elif !ETHR_AT_LEAST_GCC_VSN__(4, 8, 0)
 /* True gcc of version < 4.8, i.e., bug exist... */
 #  define ETHR___atomic_load_ACQUIRE_barrier_bug ETHR_GCC_VERSIONS_MASK__
@@ -87,7 +103,7 @@
 #define ETHR_GCC_RELAXED_VERSIONS__ ETHR_GCC_VERSIONS_MASK__
 #define ETHR_GCC_RELAXED_MOD_VERSIONS__ ETHR_GCC_VERSIONS_MASK__
 
-#if ETHR_TRUST_GCC_ATOMIC_BUILTINS_MEMORY_BARRIERS
+#if ETHR_TRUST_GCC_ATOMIC_BUILTINS_MEMORY_BARRIERS__
 #  define ETHR_GCC_ACQB_VERSIONS__ ETHR_GCC_VERSIONS_MASK__
 #  define ETHR_GCC_ACQB_MOD_VERSIONS__ ETHR_GCC_VERSIONS_MASK__
 #  define ETHR_GCC_RELB_VERSIONS__ ETHR_GCC_VERSIONS_MASK__
-- 
2.26.2

openSUSE Build Service is sponsored by