From: Ivan Maidanski Date: Sun, 3 Feb 2013 08:29:25 +0000 (+0400) Subject: Add generalized fetch_and_add_acquire/release (for ARMv6+) X-Git-Tag: libatomic_ops-7_4_0~48^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=76e589081ea588b9c830cf125b1efdcd796583eb;p=libatomic_ops Add generalized fetch_and_add_acquire/release (for ARMv6+) * src/atomic_ops/generalize-arithm.template (AO_XSIZE_fetch_and_add_acquire, AO_XSIZE_fetch_and_add_release): Add generalized template primitives based on AO_XSIZE_fetch_and_add. * src/atomic_ops/generalize-arithm.h: Regenerate. --- diff --git a/src/atomic_ops/generalize-arithm.h b/src/atomic_ops/generalize-arithm.h index 2607d6e..e03395a 100644 --- a/src/atomic_ops/generalize-arithm.h +++ b/src/atomic_ops/generalize-arithm.h @@ -226,6 +226,24 @@ # endif #endif /* AO_HAVE_char_fetch_and_add_full */ +#if defined(AO_HAVE_char_fetch_and_add) && defined(AO_HAVE_nop_full) \ + && !defined(AO_HAVE_char_fetch_and_add_acquire) + AO_INLINE unsigned/**/char + AO_char_fetch_and_add_acquire(volatile unsigned/**/char *addr, unsigned/**/char incr) + { + unsigned/**/char result = AO_char_fetch_and_add(addr, incr); + AO_nop_full(); + return result; + } +# define AO_HAVE_char_fetch_and_add_acquire +#endif +#if defined(AO_HAVE_char_fetch_and_add) && defined(AO_HAVE_nop_full) \ + && !defined(AO_HAVE_char_fetch_and_add_release) +# define AO_char_fetch_and_add_release(addr, incr) \ + (AO_nop_full(), AO_char_fetch_and_add(addr, incr)) +# define AO_HAVE_char_fetch_and_add_release +#endif + #if !defined(AO_HAVE_char_fetch_and_add) \ && defined(AO_HAVE_char_fetch_and_add_release) # define AO_char_fetch_and_add(addr, val) \ @@ -1053,6 +1071,24 @@ # endif #endif /* AO_HAVE_short_fetch_and_add_full */ +#if defined(AO_HAVE_short_fetch_and_add) && defined(AO_HAVE_nop_full) \ + && !defined(AO_HAVE_short_fetch_and_add_acquire) + AO_INLINE unsigned/**/short + AO_short_fetch_and_add_acquire(volatile unsigned/**/short *addr, unsigned/**/short incr) + { + unsigned/**/short result = AO_short_fetch_and_add(addr, incr); + AO_nop_full(); + return result; + } +# define AO_HAVE_short_fetch_and_add_acquire +#endif +#if defined(AO_HAVE_short_fetch_and_add) && defined(AO_HAVE_nop_full) \ + && !defined(AO_HAVE_short_fetch_and_add_release) +# define AO_short_fetch_and_add_release(addr, incr) \ + (AO_nop_full(), AO_short_fetch_and_add(addr, incr)) +# define AO_HAVE_short_fetch_and_add_release +#endif + #if !defined(AO_HAVE_short_fetch_and_add) \ && defined(AO_HAVE_short_fetch_and_add_release) # define AO_short_fetch_and_add(addr, val) \ @@ -1880,6 +1916,24 @@ # endif #endif /* AO_HAVE_int_fetch_and_add_full */ +#if defined(AO_HAVE_int_fetch_and_add) && defined(AO_HAVE_nop_full) \ + && !defined(AO_HAVE_int_fetch_and_add_acquire) + AO_INLINE unsigned + AO_int_fetch_and_add_acquire(volatile unsigned *addr, unsigned incr) + { + unsigned result = AO_int_fetch_and_add(addr, incr); + AO_nop_full(); + return result; + } +# define AO_HAVE_int_fetch_and_add_acquire +#endif +#if defined(AO_HAVE_int_fetch_and_add) && defined(AO_HAVE_nop_full) \ + && !defined(AO_HAVE_int_fetch_and_add_release) +# define AO_int_fetch_and_add_release(addr, incr) \ + (AO_nop_full(), AO_int_fetch_and_add(addr, incr)) +# define AO_HAVE_int_fetch_and_add_release +#endif + #if !defined(AO_HAVE_int_fetch_and_add) \ && defined(AO_HAVE_int_fetch_and_add_release) # define AO_int_fetch_and_add(addr, val) \ @@ -2707,6 +2761,24 @@ # endif #endif /* AO_HAVE_fetch_and_add_full */ +#if defined(AO_HAVE_fetch_and_add) && defined(AO_HAVE_nop_full) \ + && !defined(AO_HAVE_fetch_and_add_acquire) + AO_INLINE AO_t + AO_fetch_and_add_acquire(volatile AO_t *addr, AO_t incr) + { + AO_t result = AO_fetch_and_add(addr, incr); + AO_nop_full(); + return result; + } +# define AO_HAVE_fetch_and_add_acquire +#endif +#if defined(AO_HAVE_fetch_and_add) && defined(AO_HAVE_nop_full) \ + && !defined(AO_HAVE_fetch_and_add_release) +# define AO_fetch_and_add_release(addr, incr) \ + (AO_nop_full(), AO_fetch_and_add(addr, incr)) +# define AO_HAVE_fetch_and_add_release +#endif + #if !defined(AO_HAVE_fetch_and_add) \ && defined(AO_HAVE_fetch_and_add_release) # define AO_fetch_and_add(addr, val) \ diff --git a/src/atomic_ops/generalize-arithm.template b/src/atomic_ops/generalize-arithm.template index 3696782..8b21912 100644 --- a/src/atomic_ops/generalize-arithm.template +++ b/src/atomic_ops/generalize-arithm.template @@ -226,6 +226,24 @@ # endif #endif /* AO_HAVE_XSIZE_fetch_and_add_full */ +#if defined(AO_HAVE_XSIZE_fetch_and_add) && defined(AO_HAVE_nop_full) \ + && !defined(AO_HAVE_XSIZE_fetch_and_add_acquire) + AO_INLINE XCTYPE + AO_XSIZE_fetch_and_add_acquire(volatile XCTYPE *addr, XCTYPE incr) + { + XCTYPE result = AO_XSIZE_fetch_and_add(addr, incr); + AO_nop_full(); + return result; + } +# define AO_HAVE_XSIZE_fetch_and_add_acquire +#endif +#if defined(AO_HAVE_XSIZE_fetch_and_add) && defined(AO_HAVE_nop_full) \ + && !defined(AO_HAVE_XSIZE_fetch_and_add_release) +# define AO_XSIZE_fetch_and_add_release(addr, incr) \ + (AO_nop_full(), AO_XSIZE_fetch_and_add(addr, incr)) +# define AO_HAVE_XSIZE_fetch_and_add_release +#endif + #if !defined(AO_HAVE_XSIZE_fetch_and_add) \ && defined(AO_HAVE_XSIZE_fetch_and_add_release) # define AO_XSIZE_fetch_and_add(addr, val) \