import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm64 / include / asm / cmpxchg.h
index 8a8ce0e73a38234968e4cde566455284af5887a6..a03583d47b34088f8efec77d060c654f4ea37e70 100644 (file)
@@ -71,7 +71,12 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
 }
 
 #define xchg(ptr,x) \
-       ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
+({ \
+       __typeof__(*(ptr)) __ret; \
+       __ret = (__typeof__(*(ptr))) \
+               __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))); \
+       __ret; \
+})
 
 static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
                                      unsigned long new, int size)
@@ -158,17 +163,23 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
        return ret;
 }
 
-#define cmpxchg(ptr,o,n)                                               \
-       ((__typeof__(*(ptr)))__cmpxchg_mb((ptr),                        \
-                                         (unsigned long)(o),           \
-                                         (unsigned long)(n),           \
-                                         sizeof(*(ptr))))
-
-#define cmpxchg_local(ptr,o,n)                                         \
-       ((__typeof__(*(ptr)))__cmpxchg((ptr),                           \
-                                      (unsigned long)(o),              \
-                                      (unsigned long)(n),              \
-                                      sizeof(*(ptr))))
+#define cmpxchg(ptr, o, n) \
+({ \
+       __typeof__(*(ptr)) __ret; \
+       __ret = (__typeof__(*(ptr))) \
+               __cmpxchg_mb((ptr), (unsigned long)(o), (unsigned long)(n), \
+                            sizeof(*(ptr))); \
+       __ret; \
+})
+
+#define cmpxchg_local(ptr, o, n) \
+({ \
+       __typeof__(*(ptr)) __ret; \
+       __ret = (__typeof__(*(ptr))) \
+               __cmpxchg((ptr), (unsigned long)(o), \
+                         (unsigned long)(n), sizeof(*(ptr))); \
+       __ret; \
+})
 
 #define cmpxchg64(ptr,o,n)             cmpxchg((ptr),(o),(n))
 #define cmpxchg64_local(ptr,o,n)       cmpxchg_local((ptr),(o),(n))