add uatomic_generic.h, use it for common definitions
[urcu.git] / urcu / uatomic_arch_sparc64.h
index 87deacd1a064366bceb799cf8620485c06ba6206..ec9d8e8d6323784a85efe1e3cc0d0b36de4bc2da 100644 (file)
 #include <urcu/compiler.h>
 #include <urcu/system.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif 
+
 #ifndef __SIZEOF_LONG__
-#if (defined(__sparc_v8__) || defined(__sparc_v9__))
+#ifdef __LP64__
 #define __SIZEOF_LONG__ 8
 #else
 #define __SIZEOF_LONG__ 4
@@ -35,9 +39,6 @@
 #define BITS_PER_LONG  (__SIZEOF_LONG__ * 8)
 #endif
 
-#define uatomic_set(addr, v)   STORE_SHARED(*(addr), (v))
-#define uatomic_read(addr)     LOAD_SHARED(*(addr))
-
 /* cmpxchg */
 
 static inline __attribute__((always_inline))
@@ -90,9 +91,9 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
        switch (len) {
        case 4:
        {
-               unsigned int old;
+               unsigned int old, oldt;
 
-               oldt = uatomic_read(addr);
+               oldt = uatomic_read((unsigned int *)addr);
                do {
                        old = oldt;
                        oldt = _uatomic_cmpxchg(addr, old, val, 4);
@@ -103,9 +104,9 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
 #if (BITS_PER_LONG == 64)
        case 8:
        {
-               unsigned long old;
+               unsigned long old, oldt;
 
-               oldt = uatomic_read(addr);
+               oldt = uatomic_read((unsigned long *)addr);
                do {
                        old = oldt;
                        oldt = _uatomic_cmpxchg(addr, old, val, 8);
@@ -126,15 +127,14 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
 /* uatomic_add_return */
 
 static inline __attribute__((always_inline))
-unsigned long _uatomic_add_return(void *addr, unsigned long val,
-                                int len)
+unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
 {
        switch (len) {
        case 4:
        {
-               unsigned int old;
+               unsigned int old, oldt;
 
-               oldt = uatomic_read(addr);
+               oldt = uatomic_read((unsigned int *)addr);
                do {
                        old = oldt;
                        oldt = _uatomic_cmpxchg(addr, old, old + val, 4);
@@ -145,9 +145,9 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val,
 #if (BITS_PER_LONG == 64)
        case 8:
        {
-               unsigned long old;
+               unsigned long old, oldt;
 
-               oldt = uatomic_read(addr);
+               oldt = uatomic_read((unsigned long *)addr);
                do {
                        old = oldt;
                        oldt = _uatomic_cmpxchg(addr, old, old + val, 8);
@@ -166,17 +166,10 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val,
                                                  (unsigned long)(v),   \
                                                  sizeof(*(addr))))
 
-/* uatomic_sub_return, uatomic_add, uatomic_sub, uatomic_inc, uatomic_dec */
-
-#define uatomic_sub_return(addr, v)    uatomic_add_return((addr), -(v))
-
-#define uatomic_add(addr, v)           (void)uatomic_add_return((addr), (v))
-#define uatomic_sub(addr, v)           (void)uatomic_sub_return((addr), (v))
-
-#define uatomic_inc(addr)              uatomic_add((addr), 1)
-#define uatomic_dec(addr)              uatomic_add((addr), -1)
+#ifdef __cplusplus 
+}
+#endif
 
-#define URCU_CAS_AVAIL()       1
-#define compat_uatomic_cmpxchg(ptr, old, _new) uatomic_cmpxchg(ptr, old, _new)
+#include <urcu/uatomic_generic.h>
 
 #endif /* _URCU_ARCH_UATOMIC_PPC_H */
This page took 0.023933 seconds and 4 git commands to generate.