]> granicus.if.org Git - libatomic_ops/commitdiff
Use generalized load/store if AO_PREFER_GENERALIZED (gcc/generic)
authorIvan Maidanski <ivmai@mail.ru>
Fri, 27 Jan 2017 16:35:20 +0000 (19:35 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Fri, 27 Jan 2017 16:35:20 +0000 (19:35 +0300)
Note: AO_PREFER_GENERALIZED macro is for testing generalize.h mainly.

* src/atomic_ops/sysdeps/gcc/generic-small.template (AO_XSIZE_load,
AO_XSIZE_load_acquire, AO_XSIZE_store, AO_XSIZE_store_release): Do not
define if AO_GCC_HAVE_XSIZE_SYNC_CAS and AO_PREFER_GENERALIZED.
* src/atomic_ops/sysdeps/gcc/generic-small.h: Regenerate.
* src/atomic_ops/sysdeps/gcc/generic.h [AO_HAVE_DOUBLE_PTR_STORAGE]
(AO_GCC_HAVE_double_SYNC_CAS): Move the definition upper to be before
AO_double_load.
* src/atomic_ops/sysdeps/gcc/generic.h [AO_HAVE_DOUBLE_PTR_STORAGE]
(AO_double_load, AO_double_load_acquire, AO_double_store,
AO_double_store_release): Do not define if AO_GCC_HAVE_double_SYNC_CAS
and AO_PREFER_GENERALIZED.

src/atomic_ops/sysdeps/gcc/generic-small.h
src/atomic_ops/sysdeps/gcc/generic-small.template
src/atomic_ops/sysdeps/gcc/generic.h

index c9b3fbc83bbef7f4d4e0d1fd5ea1df297071e441..fb78a75b8769b8691c62bce9e20079e04ac7e82d 100644 (file)
@@ -15,6 +15,8 @@
  *
  */
 
+#if !defined(AO_GCC_HAVE_char_SYNC_CAS) || !defined(AO_PREFER_GENERALIZED)
+
 AO_INLINE unsigned/**/char
 AO_char_load(const volatile unsigned/**/char *addr)
 {
@@ -62,6 +64,8 @@ AO_char_load_acquire(const volatile unsigned/**/char *addr)
 # define AO_HAVE_char_store_release
 #endif
 
+#endif /* !AO_GCC_HAVE_char_SYNC_CAS || !AO_PREFER_GENERALIZED */
+
 #ifdef AO_GCC_HAVE_char_SYNC_CAS
 
   AO_INLINE unsigned/**/char
@@ -169,6 +173,8 @@ AO_char_load_acquire(const volatile unsigned/**/char *addr)
  *
  */
 
+#if !defined(AO_GCC_HAVE_short_SYNC_CAS) || !defined(AO_PREFER_GENERALIZED)
+
 AO_INLINE unsigned/**/short
 AO_short_load(const volatile unsigned/**/short *addr)
 {
@@ -216,6 +222,8 @@ AO_short_load_acquire(const volatile unsigned/**/short *addr)
 # define AO_HAVE_short_store_release
 #endif
 
+#endif /* !AO_GCC_HAVE_short_SYNC_CAS || !AO_PREFER_GENERALIZED */
+
 #ifdef AO_GCC_HAVE_short_SYNC_CAS
 
   AO_INLINE unsigned/**/short
@@ -323,6 +331,8 @@ AO_short_load_acquire(const volatile unsigned/**/short *addr)
  *
  */
 
+#if !defined(AO_GCC_HAVE_int_SYNC_CAS) || !defined(AO_PREFER_GENERALIZED)
+
 AO_INLINE unsigned
 AO_int_load(const volatile unsigned *addr)
 {
@@ -370,6 +380,8 @@ AO_int_load_acquire(const volatile unsigned *addr)
 # define AO_HAVE_int_store_release
 #endif
 
+#endif /* !AO_GCC_HAVE_int_SYNC_CAS || !AO_PREFER_GENERALIZED */
+
 #ifdef AO_GCC_HAVE_int_SYNC_CAS
 
   AO_INLINE unsigned
@@ -477,6 +489,8 @@ AO_int_load_acquire(const volatile unsigned *addr)
  *
  */
 
+#if !defined(AO_GCC_HAVE_SYNC_CAS) || !defined(AO_PREFER_GENERALIZED)
+
 AO_INLINE AO_t
 AO_load(const volatile AO_t *addr)
 {
@@ -524,6 +538,8 @@ AO_load_acquire(const volatile AO_t *addr)
 # define AO_HAVE_store_release
 #endif
 
+#endif /* !AO_GCC_HAVE_SYNC_CAS || !AO_PREFER_GENERALIZED */
+
 #ifdef AO_GCC_HAVE_SYNC_CAS
 
   AO_INLINE AO_t
index d4f270b3641693b2523af07866a1b5e38495ad84..7c2f738f34d39320440ab1d00b1bb4728e469682 100644 (file)
@@ -15,6 +15,8 @@
  *
  */
 
+#if !defined(AO_GCC_HAVE_XSIZE_SYNC_CAS) || !defined(AO_PREFER_GENERALIZED)
+
 AO_INLINE XCTYPE
 AO_XSIZE_load(const volatile XCTYPE *addr)
 {
@@ -62,6 +64,8 @@ AO_XSIZE_load_acquire(const volatile XCTYPE *addr)
 # define AO_HAVE_XSIZE_store_release
 #endif
 
+#endif /* !AO_GCC_HAVE_XSIZE_SYNC_CAS || !AO_PREFER_GENERALIZED */
+
 #ifdef AO_GCC_HAVE_XSIZE_SYNC_CAS
 
   AO_INLINE XCTYPE
index 59b2edf0d1c44eb1fa7dff41e882be64c2ecc61a..1c96578946097a41f64f9ee06fadb8f746b2e8bc 100644 (file)
 
 #ifdef AO_HAVE_DOUBLE_PTR_STORAGE
 
+# if ((__SIZEOF_SIZE_T__ == 4 \
+       && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)) \
+      || (__SIZEOF_SIZE_T__ == 8 /* half of AO_double_t */ \
+          && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16))) \
+     && !defined(AO_SKIPATOMIC_double_compare_and_swap_ANY)
+#   define AO_GCC_HAVE_double_SYNC_CAS
+# endif
+
+# if !defined(AO_GCC_HAVE_double_SYNC_CAS) || !defined(AO_PREFER_GENERALIZED)
+
 # if !defined(AO_HAVE_double_load) && !defined(AO_SKIPATOMIC_double_load)
     AO_INLINE AO_double_t
     AO_double_load(const volatile AO_double_t *addr)
 #   define AO_HAVE_double_store_release
 # endif
 
-# if ((__SIZEOF_SIZE_T__ == 4 \
-       && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)) \
-      || (__SIZEOF_SIZE_T__ == 8 /* half of AO_double_t */ \
-          && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16))) \
-     && !defined(AO_SKIPATOMIC_double_compare_and_swap_ANY)
-#   define AO_GCC_HAVE_double_SYNC_CAS
-# endif
+#endif /* !AO_GCC_HAVE_double_SYNC_CAS || !AO_PREFER_GENERALIZED */
 
 #endif /* AO_HAVE_DOUBLE_PTR_STORAGE */