use generic-size macros for common implementation of atomic ops
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 9 Jun 2011 14:13:13 +0000 (10:13 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 9 Jun 2011 14:13:13 +0000 (10:13 -0400)
The definition of _uatomic_cmpxchg is different in x86 and other
architectures.  For x86 it is a 4-argument macro, for other
architectures it is a 3-argument function.  This patch makes it easier
to implement atomic operations incrementally (first as a generic version
and then in machine-specific code), which aids testing and
bisectability.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
urcu/uatomic_generic.h

index cef58f382180ba1061b1bb2e37c7cc87c0b7f354..337fe4098bf8337649f9a6bb52af4f9359453091 100644 (file)
@@ -395,7 +395,8 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
                oldt = uatomic_read((unsigned char *)addr);
                do {
                        old = oldt;
-                       oldt = _uatomic_cmpxchg(addr, old, old + val, 1);
+                       oldt = uatomic_cmpxchg((unsigned char *)addr,
+                                               old, old + val);
                } while (oldt != old);
 
                return old + val;
@@ -409,7 +410,8 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
                oldt = uatomic_read((unsigned short *)addr);
                do {
                        old = oldt;
-                       oldt = _uatomic_cmpxchg(addr, old, old + val, 2);
+                       oldt = uatomic_cmpxchg((unsigned short *)addr,
+                                               old, old + val);
                } while (oldt != old);
 
                return old + val;
@@ -422,7 +424,8 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
                oldt = uatomic_read((unsigned int *)addr);
                do {
                        old = oldt;
-                       oldt = _uatomic_cmpxchg(addr, old, old + val, 4);
+                       oldt = uatomic_cmpxchg((unsigned int *)addr,
+                                               old, old + val);
                } while (oldt != old);
 
                return old + val;
@@ -435,7 +438,8 @@ unsigned long _uatomic_add_return(void *addr, unsigned long val, int len)
                oldt = uatomic_read((unsigned long *)addr);
                do {
                        old = oldt;
-                       oldt = _uatomic_cmpxchg(addr, old, old + val, 8);
+                       oldt = uatomic_cmpxchg((unsigned long *)addr,
+                                               old, old + val);
                } while (oldt != old);
 
                return old + val;
@@ -467,7 +471,8 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
                oldt = uatomic_read((unsigned char *)addr);
                do {
                        old = oldt;
-                       oldt = _uatomic_cmpxchg(addr, old, val, 1);
+                       oldt = uatomic_cmpxchg((unsigned char *)addr,
+                                               old, val);
                } while (oldt != old);
 
                return old;
@@ -481,7 +486,8 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
                oldt = uatomic_read((unsigned short *)addr);
                do {
                        old = oldt;
-                       oldt = _uatomic_cmpxchg(addr, old, val, 2);
+                       oldt = uatomic_cmpxchg((unsigned short *)addr,
+                                               old, val);
                } while (oldt != old);
 
                return old;
@@ -494,7 +500,8 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
                oldt = uatomic_read((unsigned int *)addr);
                do {
                        old = oldt;
-                       oldt = _uatomic_cmpxchg(addr, old, val, 4);
+                       oldt = uatomic_cmpxchg((unsigned int *)addr,
+                                               old, val);
                } while (oldt != old);
 
                return old;
@@ -507,7 +514,8 @@ unsigned long _uatomic_exchange(void *addr, unsigned long val, int len)
                oldt = uatomic_read((unsigned long *)addr);
                do {
                        old = oldt;
-                       oldt = _uatomic_cmpxchg(addr, old, val, 8);
+                       oldt = uatomic_cmpxchg((unsigned long *)addr,
+                                               old, val);
                } while (oldt != old);
 
                return old;
This page took 0.027205 seconds and 4 git commands to generate.