Module: xenomai-forge
Branch: next
Commit: 1d62c6b5c8dd841f2427a02cf4446df57428b321
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=1d62c6b5c8dd841f2427a02cf4446df57428b321

Author: Philippe Gerum <r...@xenomai.org>
Date:   Sat Jul  6 17:29:15 2013 +0200

copperplate: rebase atomic ops over nocore/atomic.h

---

 include/copperplate/lock.h |   13 +------------
 include/nocore/atomic.h    |   28 +++++++++++++++++++++++-----
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/include/copperplate/lock.h b/include/copperplate/lock.h
index 7f1013c..60a1dac 100644
--- a/include/copperplate/lock.h
+++ b/include/copperplate/lock.h
@@ -20,6 +20,7 @@
 #define _COPPERPLATE_LOCK_H
 
 #include <pthread.h>
+#include <nocore/atomic.h>
 #include <copperplate/wrappers.h>
 #include <copperplate/debug.h>
 
@@ -204,18 +205,6 @@ int __check_cancel_type(const char *locktype);
 #define read_unlock_safe(__lock, __state)      \
        __do_unlock_safe(__lock, __state)
 
-#define barrier()      __asm__ __volatile__("": : :"memory")
-#define membar()       __sync_synchronize()
-#ifdef CONFIG_SMP
-#define smp_membar()   membar()
-#else
-#define smp_membar()   do { } while (0)
-#endif
-
-#define atomic_sub_fetch(v, n) __sync_sub_and_fetch(&(v), n)
-#define atomic_add_fetch(v, n) __sync_add_and_fetch(&(v), n)
-#define atomic_cmp_swap(ptr, old, new)  __sync_val_compare_and_swap(ptr, old, 
new)
-
 #ifdef __cplusplus
 extern "C" {
 #endif
diff --git a/include/nocore/atomic.h b/include/nocore/atomic.h
index 8cd236a..d4101c9 100644
--- a/include/nocore/atomic.h
+++ b/include/nocore/atomic.h
@@ -44,18 +44,36 @@ typedef struct {
                                    (typeof((p)->v))(n))
 #endif
 
-#ifndef smp_mb
-#define smp_mb() __sync_synchronize()
+#ifndef atomic_sub_fetch
+#define atomic_sub_fetch(v, n) _sync_sub_and_fetch(&(v), n)
 #endif
 
-#ifndef smp_rmb
-#define smp_rmb() __sync_synchronize()
+#ifndef atomic_add_fetch
+#define atomic_add_fetch(v, n) __sync_add_and_fetch(&(v), n)
 #endif
 
+#ifndef atomic_cmp_swap
+#define atomic_cmp_swap(ptr, old, new)  __sync_val_compare_and_swap(ptr, old, 
new)
+#endif
+
+#ifdef CONFIG_SMP
+#ifndef smp_mb
+#define smp_mb()       __sync_synchronize()
+#endif
+#ifndef smp_rmb
+#define smp_rmb()      smp_mb()
+#endif
 #ifndef smp_wmb
-#define smp_wmb() __sync_synchronize()
+#define smp_wmb()      smp_mb()
 #endif
+#else  /* !CONFIG_SMP */
+#define smp_mb()       do { } while (0)
+#define smp_rmb()      do { } while (0)
+#define smp_wmb()      do { } while (0)
+#endif /* !CONFIG_SMP */
 
 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
 
+#define barrier()      __asm__ __volatile__("": : :"memory")
+
 #endif /* _NOCORE_ATOMIC_H */


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to