]> granicus.if.org Git - libatomic_ops/commitdiff
Add generalized fetch_and_add_acquire/release (for ARMv6+)
authorIvan Maidanski <ivmai@mail.ru>
Sun, 3 Feb 2013 08:29:25 +0000 (12:29 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sun, 3 Feb 2013 08:29:25 +0000 (12:29 +0400)
* 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.

src/atomic_ops/generalize-arithm.h
src/atomic_ops/generalize-arithm.template

index 2607d6ec839a12aff9eef5c4bd1f8b1696dd970a..e03395a40c4543f07beddb9422c8ff5171775017 100644 (file)
 # 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) \
 # 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) \
 # 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) \
 # 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) \
index 3696782fb034faa6b8e1eb15afba67e065c61be5..8b21912b6eded803d7cecb8df41f85c959781745 100644 (file)
 # 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) \