From: Ivan Maidanski Date: Fri, 27 Jan 2017 16:35:20 +0000 (+0300) Subject: Use generalized load/store if AO_PREFER_GENERALIZED (gcc/generic) X-Git-Tag: v7.6.0~112 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7c02f314b10d3db3ff23f8adb13b85d753f477d7;p=libatomic_ops Use generalized load/store if AO_PREFER_GENERALIZED (gcc/generic) 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. --- diff --git a/src/atomic_ops/sysdeps/gcc/generic-small.h b/src/atomic_ops/sysdeps/gcc/generic-small.h index c9b3fbc..fb78a75 100644 --- a/src/atomic_ops/sysdeps/gcc/generic-small.h +++ b/src/atomic_ops/sysdeps/gcc/generic-small.h @@ -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 diff --git a/src/atomic_ops/sysdeps/gcc/generic-small.template b/src/atomic_ops/sysdeps/gcc/generic-small.template index d4f270b..7c2f738 100644 --- a/src/atomic_ops/sysdeps/gcc/generic-small.template +++ b/src/atomic_ops/sysdeps/gcc/generic-small.template @@ -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 diff --git a/src/atomic_ops/sysdeps/gcc/generic.h b/src/atomic_ops/sysdeps/gcc/generic.h index 59b2edf..1c96578 100644 --- a/src/atomic_ops/sysdeps/gcc/generic.h +++ b/src/atomic_ops/sysdeps/gcc/generic.h @@ -122,6 +122,16 @@ #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) @@ -166,13 +176,7 @@ # 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 */