00db10
Backporting the C11 atomic support will allow future algorithms
00db10
to be more easily backported to RHEL7. This is initially backported
00db10
to support the new semaphore algorithm which is now in RHEL7
00db10
(rhbz#1027348).
00db10
00db10
commit 1ea339b69725cb2f30b5a84cb7ca96111c9a637b
00db10
Author: Torvald Riegel <triegel@redhat.com>
00db10
Date:   Sat Oct 18 01:02:59 2014 +0200
00db10
00db10
    Add arch-specific configuration for C11 atomics support.
00db10
    
00db10
    This sets __HAVE_64B_ATOMICS if provided.  It also sets
00db10
    USE_ATOMIC_COMPILER_BUILTINS to true if the existing atomic ops use the
00db10
    __atomic* builtins (aarch64, mips partially) or if this has been
00db10
    tested (x86_64); otherwise, this is set to false so that C11 atomics will
00db10
    be based on the existing atomic operations.
00db10
00db10
Index: glibc-2.17-c758a686/ports/sysdeps/aarch64/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/ports/sysdeps/aarch64/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/ports/sysdeps/aarch64/bits/atomic.h
00db10
@@ -36,6 +36,8 @@ typedef uintptr_t uatomicptr_t;
00db10
 typedef intmax_t atomic_max_t;
00db10
 typedef uintmax_t uatomic_max_t;
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 1
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 1
00db10
 
00db10
 /* Compare and exchange.
00db10
    For all "bool" routines, we return FALSE if exchange succesful.  */
00db10
Index: glibc-2.17-c758a686/ports/sysdeps/alpha/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/ports/sysdeps/alpha/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/ports/sysdeps/alpha/bits/atomic.h
00db10
@@ -42,6 +42,9 @@ typedef uintptr_t uatomicptr_t;
00db10
 typedef intmax_t atomic_max_t;
00db10
 typedef uintmax_t uatomic_max_t;
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 1
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 
00db10
 #ifdef UP
00db10
 # define __MB		/* nothing */
00db10
Index: glibc-2.17-c758a686/ports/sysdeps/arm/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/ports/sysdeps/arm/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/ports/sysdeps/arm/bits/atomic.h
00db10
@@ -33,6 +33,9 @@ typedef uintptr_t uatomicptr_t;
00db10
 typedef intmax_t atomic_max_t;
00db10
 typedef uintmax_t uatomic_max_t;
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 0
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 void __arm_link_error (void);
00db10
 
00db10
 /* Use the atomic builtins provided by GCC in case the backend provides
00db10
Index: glibc-2.17-c758a686/sysdeps/i386/i486/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/sysdeps/i386/i486/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/sysdeps/i386/i486/bits/atomic.h
00db10
@@ -54,6 +54,9 @@ typedef uintmax_t uatomic_max_t;
00db10
 # endif
00db10
 #endif
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 0
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 
00db10
 #define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
00db10
   __sync_val_compare_and_swap (mem, oldval, newval)
00db10
Index: glibc-2.17-c758a686/ports/sysdeps/ia64/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/ports/sysdeps/ia64/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/ports/sysdeps/ia64/bits/atomic.h
00db10
@@ -43,6 +43,9 @@ typedef uintptr_t uatomicptr_t;
00db10
 typedef intmax_t atomic_max_t;
00db10
 typedef uintmax_t uatomic_max_t;
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 1
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 
00db10
 #define __arch_compare_and_exchange_bool_8_acq(mem, newval, oldval) \
00db10
   (abort (), 0)
00db10
Index: glibc-2.17-c758a686/ports/sysdeps/m68k/coldfire/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/ports/sysdeps/m68k/coldfire/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/ports/sysdeps/m68k/coldfire/bits/atomic.h
00db10
@@ -49,6 +49,10 @@ typedef uintptr_t uatomicptr_t;
00db10
 typedef intmax_t atomic_max_t;
00db10
 typedef uintmax_t uatomic_max_t;
00db10
 
00db10
+/* If we have just non-atomic operations, we can as well make them wide.  */
00db10
+#define __HAVE_64B_ATOMICS 1
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 /* The only basic operation needed is compare and exchange.  */
00db10
 #define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
00db10
   ({ __typeof (mem) __gmemp = (mem);				      \
00db10
Index: glibc-2.17-c758a686/ports/sysdeps/m68k/m680x0/m68020/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/ports/sysdeps/m68k/m680x0/m68020/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/ports/sysdeps/m68k/m680x0/m68020/bits/atomic.h
00db10
@@ -44,6 +44,9 @@ typedef uintptr_t uatomicptr_t;
00db10
 typedef intmax_t atomic_max_t;
00db10
 typedef uintmax_t uatomic_max_t;
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 1
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 #define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
00db10
   ({ __typeof (*(mem)) __ret;						      \
00db10
      __asm __volatile ("cas%.b %0,%2,%1"				      \
00db10
Index: glibc-2.17-c758a686/ports/sysdeps/mips/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/ports/sysdeps/mips/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/ports/sysdeps/mips/bits/atomic.h
00db10
@@ -43,6 +43,12 @@ typedef uintmax_t uatomic_max_t;
00db10
 #define MIPS_PUSH_MIPS2
00db10
 #endif
00db10
 
00db10
+#if _MIPS_SIM == _ABIO32
00db10
+#define __HAVE_64B_ATOMICS 0
00db10
+#else
00db10
+#define __HAVE_64B_ATOMICS 1
00db10
+#endif
00db10
+
00db10
 /* See the comments in <sys/asm.h> about the use of the sync instruction.  */
00db10
 #ifndef MIPS_SYNC
00db10
 # define MIPS_SYNC	sync
00db10
@@ -82,6 +88,8 @@ typedef uintmax_t uatomic_max_t;
00db10
 /* The __atomic_* builtins are available in GCC 4.7 and later, but MIPS
00db10
    support for their efficient implementation was added only in GCC 4.8.  */
00db10
 
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 1
00db10
+
00db10
 /* Compare and exchange.
00db10
    For all "bool" routines, we return FALSE if exchange succesful.  */
00db10
 
00db10
@@ -204,6 +212,8 @@ typedef uintmax_t uatomic_max_t;
00db10
 /* This implementation using inline assembly will be removed once glibc
00db10
    requires GCC 4.8 or later to build.  */
00db10
 
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 /* Compare and exchange.  For all of the "xxx" routines, we expect a
00db10
    "__prev" and a "__cmp" variable to be provided by the enclosing scope,
00db10
    in which values are returned.  */
00db10
Index: glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/sysdeps/powerpc/powerpc32/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/bits/atomic.h
00db10
@@ -33,6 +33,9 @@
00db10
 # define MUTEX_HINT_REL
00db10
 #endif
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 0
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 /*
00db10
  * The 32-bit exchange_bool is different on powerpc64 because the subf
00db10
  * does signed 64-bit arthmatic while the lwarx is 32-bit unsigned
00db10
Index: glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/sysdeps/powerpc/powerpc64/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/bits/atomic.h
00db10
@@ -33,6 +33,9 @@
00db10
 # define MUTEX_HINT_REL
00db10
 #endif
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 1
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 /* The 32-bit exchange_bool is different on powerpc64 because the subf
00db10
    does signed 64-bit arthmatic while the lwarx is 32-bit unsigned
00db10
    (a load word and zero (high 32) form) load.
00db10
Index: glibc-2.17-c758a686/sysdeps/s390/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/sysdeps/s390/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/sysdeps/s390/bits/atomic.h
00db10
@@ -43,6 +43,8 @@ typedef uintptr_t uatomicptr_t;
00db10
 typedef intmax_t atomic_max_t;
00db10
 typedef uintmax_t uatomic_max_t;
00db10
 
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 
00db10
 #define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
00db10
   (abort (), (__typeof (*mem)) 0)
00db10
@@ -59,6 +61,7 @@ typedef uintmax_t uatomic_max_t;
00db10
      __archold; })
00db10
 
00db10
 #ifdef __s390x__
00db10
+# define __HAVE_64B_ATOMICS 1
00db10
 # define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \
00db10
   ({ __typeof (mem) __archmem = (mem);					      \
00db10
      __typeof (*mem) __archold = (oldval);				      \
00db10
@@ -67,6 +70,7 @@ typedef uintmax_t uatomic_max_t;
00db10
 		       : "d" ((long) (newval)), "m" (*__archmem) : "cc", "memory" );    \
00db10
      __archold; })
00db10
 #else
00db10
+# define __HAVE_64B_ATOMICS 0
00db10
 /* For 31 bit we do not really need 64-bit compare-and-exchange. We can
00db10
    implement them by use of the csd instruction. The straightforward
00db10
    implementation causes warnings so we skip the definition for now.  */
00db10
Index: glibc-2.17-c758a686/sysdeps/sparc/sparc32/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/sysdeps/sparc/sparc32/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/sysdeps/sparc/sparc32/bits/atomic.h
00db10
@@ -47,6 +47,9 @@ typedef uintptr_t uatomicptr_t;
00db10
 typedef intmax_t atomic_max_t;
00db10
 typedef uintmax_t uatomic_max_t;
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 0
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 
00db10
 /* We have no compare and swap, just test and set.
00db10
    The following implementation contends on 64 global locks
00db10
Index: glibc-2.17-c758a686/sysdeps/sparc/sparc32/sparcv9/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/sysdeps/sparc/sparc32/sparcv9/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/sysdeps/sparc/sparc32/sparcv9/bits/atomic.h
00db10
@@ -44,6 +44,9 @@ typedef uintptr_t uatomicptr_t;
00db10
 typedef intmax_t atomic_max_t;
00db10
 typedef uintmax_t uatomic_max_t;
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 0
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 
00db10
 #define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
00db10
   (abort (), (__typeof (*mem)) 0)
00db10
Index: glibc-2.17-c758a686/sysdeps/sparc/sparc64/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/sysdeps/sparc/sparc64/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/sysdeps/sparc/sparc64/bits/atomic.h
00db10
@@ -44,6 +44,9 @@ typedef uintptr_t uatomicptr_t;
00db10
 typedef intmax_t atomic_max_t;
00db10
 typedef uintmax_t uatomic_max_t;
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 1
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 
00db10
 #define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \
00db10
   (abort (), (__typeof (*mem)) 0)
00db10
Index: glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/ports/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/ports/sysdeps/unix/sysv/linux/hppa/bits/atomic.h
00db10
@@ -44,6 +44,9 @@ typedef uintptr_t uatomicptr_t;
00db10
 typedef intmax_t atomic_max_t;
00db10
 typedef uintmax_t uatomic_max_t;
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 0
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+
00db10
 /* prev = *addr;
00db10
    if (prev == old)
00db10
      *addr = new;
00db10
Index: glibc-2.17-c758a686/sysdeps/x86_64/bits/atomic.h
00db10
===================================================================
00db10
--- glibc-2.17-c758a686.orig/sysdeps/x86_64/bits/atomic.h
00db10
+++ glibc-2.17-c758a686/sysdeps/x86_64/bits/atomic.h
00db10
@@ -55,6 +55,12 @@ typedef uintmax_t uatomic_max_t;
00db10
 # endif
00db10
 #endif
00db10
 
00db10
+#define __HAVE_64B_ATOMICS 1
00db10
+#if __GNUC_PREREQ (4, 7)
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 1
00db10
+#else
00db10
+#define USE_ATOMIC_COMPILER_BUILTINS 0
00db10
+#endif
00db10
 
00db10
 #define atomic_compare_and_exchange_val_acq(mem, newval, oldval) \
00db10
   __sync_val_compare_and_swap (mem, oldval, newval)