boehm-gc: revert all CACAO-specific modifications; this is now an exact copy of the...
[cacao.git] / src / mm / boehm-gc / libatomic_ops-1.2 / src / atomic_ops / generalize.h
index 0f42b328d1bd6e24176d9b8451b586fd1f2c6102..45950c7ab5e30c34d581fb3bda3899c46f3714d0 100644 (file)
 
 #if defined(AO_HAVE_test_and_set_full) && !defined(AO_HAVE_nop_full)
    AO_INLINE void
-   AO_nop_full()
+   AO_nop_full(void)
    {
      AO_TS_t dummy = AO_TS_INITIALIZER;
      AO_test_and_set_full(&dummy);
 #if defined(AO_HAVE_load) && defined(AO_HAVE_nop_full) && \
     !defined(AO_HAVE_load_acquire)
    AO_INLINE AO_t
-   AO_load_acquire(volatile AO_t *addr)
+   AO_load_acquire(const volatile AO_t *addr)
    {
      AO_t result = AO_load(addr);
      /* Acquire barrier would be useless, since the load could be delayed  */
 #if defined(AO_HAVE_load) && defined(AO_HAVE_nop_read) && \
     !defined(AO_HAVE_load_read)
    AO_INLINE AO_t
-   AO_load_read(volatile AO_t *addr)
+   AO_load_read(const volatile AO_t *addr)
    {
      AO_t result = AO_load(addr);
      /* Acquire barrier would be useless, since the load could be delayed  */
 #  define AO_HAVE_store_full
 #endif
 
+/* NEC LE-IT: Test and set */
+#if defined(AO_HAVE_test_and_set) && \
+       defined(AO_HAVE_nop_full) && \
+    !defined(AO_HAVE_test_and_set_release)
+#      define AO_test_and_set_release(addr) \
+       (AO_nop_full(), AO_test_and_set(addr))
+#  define AO_HAVE_test_and_set_release
+#endif
+
+#if defined(AO_HAVE_test_and_set) && \
+       defined(AO_HAVE_nop_full) && \
+    !defined(AO_HAVE_test_and_set_acquire)
+AO_INLINE AO_TS_t
+AO_test_and_set_acquire(volatile AO_TS_t *addr)
+{
+       AO_TS_t res = AO_test_and_set(addr);
+       AO_nop_full();
+       return res; 
+}  
+#  define AO_HAVE_test_and_set_acquire
+#endif
+
   
 /* Fetch_and_add */
 /* We first try to implement fetch_and_add variants in terms   */
     && !defined(AO_HAVE_compare_and_swap_double_acquire)
    AO_INLINE int
    AO_compare_and_swap_double_acquire(volatile AO_double_t *addr,
-                                            AO_t o1, AO_t o2,
+                                            AO_t o1,
                                             AO_t n1, AO_t n2)
    {
      int result = AO_compare_and_swap_double(addr, o1, n1, n2);
 #    define AO_HAVE_compare_and_swap_double_dd_acquire_read
 #  endif
 #endif
+
+/* NEC LE-IT: Convenience functions for AO_double compare and swap which */
+/* types and reads easier in code                                       */
+#if defined(AO_HAVE_compare_double_and_swap_double_release) && \
+    !defined(AO_HAVE_double_compare_and_swap_release)
+AO_INLINE int
+AO_double_compare_and_swap_release(volatile AO_double_t *addr,
+                                  AO_double_t old_val, AO_double_t new_val) 
+{
+       return AO_compare_double_and_swap_double_release(addr,
+                                                        old_val.AO_val1, old_val.AO_val2,
+                                                        new_val.AO_val1, new_val.AO_val2);
+}
+#define AO_HAVE_double_compare_and_swap_release
+#endif
+
+#if defined(AO_HAVE_compare_double_and_swap_double_acquire) && \
+    !defined(AO_HAVE_double_compare_and_swap_acquire)
+AO_INLINE int
+AO_double_compare_and_swap_acquire(volatile AO_double_t *addr,
+                                  AO_double_t old_val, AO_double_t new_val) 
+{
+       return AO_compare_double_and_swap_double_acquire(addr,
+                                                        old_val.AO_val1, old_val.AO_val2,
+                                                        new_val.AO_val1, new_val.AO_val2);
+}
+#define AO_HAVE_double_compare_and_swap_acquire
+#endif
+
+#if defined(AO_HAVE_compare_double_and_swap_double_full) && \
+    !defined(AO_HAVE_double_compare_and_swap_full)
+AO_INLINE int
+AO_double_compare_and_swap_full(volatile AO_double_t *addr,
+                                        AO_double_t old_val, AO_double_t new_val) 
+{
+       return AO_compare_double_and_swap_double_full(addr,
+                                                     old_val.AO_val1, old_val.AO_val2,
+                                                     new_val.AO_val1, new_val.AO_val2);
+}
+#define AO_HAVE_double_compare_and_swap_full
+#endif