From: Ingo Molnar Add atomic_xchg() to all the architectures. Needed by the new mutex code. Signed-off-by: Ingo Molnar Signed-off-by: Arjan van de Ven Signed-off-by: Andrew Morton --- include/asm-alpha/atomic.h | 1 + include/asm-arm/atomic.h | 2 ++ include/asm-arm26/atomic.h | 2 ++ include/asm-cris/atomic.h | 2 ++ include/asm-frv/atomic.h | 1 + include/asm-h8300/atomic.h | 2 ++ include/asm-i386/atomic.h | 1 + include/asm-ia64/atomic.h | 1 + include/asm-m32r/atomic.h | 1 + include/asm-m68k/atomic.h | 1 + include/asm-m68knommu/atomic.h | 1 + include/asm-mips/atomic.h | 1 + include/asm-parisc/atomic.h | 1 + include/asm-powerpc/atomic.h | 1 + include/asm-s390/atomic.h | 2 ++ include/asm-sh/atomic.h | 2 ++ include/asm-sh64/atomic.h | 2 ++ include/asm-sparc/atomic.h | 1 + include/asm-sparc64/atomic.h | 1 + include/asm-v850/atomic.h | 2 ++ include/asm-x86_64/atomic.h | 1 + include/asm-xtensa/atomic.h | 1 + 22 files changed, 30 insertions(+) diff -puN include/asm-alpha/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-alpha/atomic.h --- devel/include/asm-alpha/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-alpha/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -176,6 +176,7 @@ static __inline__ long atomic64_sub_retu } #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) #define atomic_add_unless(v, a, u) \ ({ \ diff -puN include/asm-arm26/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-arm26/atomic.h --- devel/include/asm-arm26/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-arm26/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -76,6 +76,8 @@ static inline int atomic_cmpxchg(atomic_ return ret; } +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) + static inline int atomic_add_unless(atomic_t *v, int a, int u) { int ret; diff -puN include/asm-arm/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-arm/atomic.h --- devel/include/asm-arm/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-arm/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -175,6 +175,8 @@ static inline void atomic_clear_mask(uns #endif /* __LINUX_ARM_ARCH__ */ +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) + static inline int atomic_add_unless(atomic_t *v, int a, int u) { int c, old; diff -puN include/asm-cris/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-cris/atomic.h --- devel/include/asm-cris/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-cris/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -136,6 +136,8 @@ static inline int atomic_cmpxchg(atomic_ return ret; } +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) + static inline int atomic_add_unless(atomic_t *v, int a, int u) { int ret; diff -puN include/asm-frv/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-frv/atomic.h --- devel/include/asm-frv/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-frv/atomic.h 2006-01-06 23:14:29.000000000 -0800 @@ -328,6 +328,7 @@ extern uint32_t __cmpxchg_32(uint32_t *v #endif #define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), old, new)) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) #define atomic_add_unless(v, a, u) \ ({ \ diff -puN include/asm-h8300/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-h8300/atomic.h --- devel/include/asm-h8300/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-h8300/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -95,6 +95,8 @@ static inline int atomic_cmpxchg(atomic_ return ret; } +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) + static inline int atomic_add_unless(atomic_t *v, int a, int u) { int ret; diff -puN include/asm-i386/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-i386/atomic.h --- devel/include/asm-i386/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-i386/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -216,6 +216,7 @@ static __inline__ int atomic_sub_return( } #define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new)) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) /** * atomic_add_unless - add unless the number is a given value diff -puN include/asm-ia64/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-ia64/atomic.h --- devel/include/asm-ia64/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-ia64/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -89,6 +89,7 @@ ia64_atomic64_sub (__s64 i, atomic64_t * } #define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new)) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) #define atomic_add_unless(v, a, u) \ ({ \ diff -puN include/asm-m32r/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-m32r/atomic.h --- devel/include/asm-m32r/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-m32r/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -243,6 +243,7 @@ static __inline__ int atomic_dec_return( #define atomic_add_negative(i,v) (atomic_add_return((i), (v)) < 0) #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) /** * atomic_add_unless - add unless the number is a given value diff -puN include/asm-m68k/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-m68k/atomic.h --- devel/include/asm-m68k/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-m68k/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -140,6 +140,7 @@ static inline void atomic_set_mask(unsig } #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) #define atomic_add_unless(v, a, u) \ ({ \ diff -puN include/asm-m68knommu/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-m68knommu/atomic.h --- devel/include/asm-m68knommu/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-m68knommu/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -129,6 +129,7 @@ static inline int atomic_sub_return(int } #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) #define atomic_add_unless(v, a, u) \ ({ \ diff -puN include/asm-mips/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-mips/atomic.h --- devel/include/asm-mips/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-mips/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -289,6 +289,7 @@ static __inline__ int atomic_sub_if_posi } #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) /** * atomic_add_unless - add unless the number is a given value diff -puN include/asm-parisc/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-parisc/atomic.h --- devel/include/asm-parisc/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-parisc/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -165,6 +165,7 @@ static __inline__ int atomic_read(const /* exported interface */ #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) /** * atomic_add_unless - add unless the number is a given value diff -puN include/asm-powerpc/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-powerpc/atomic.h --- devel/include/asm-powerpc/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-powerpc/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -165,6 +165,7 @@ static __inline__ int atomic_dec_return( } #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) /** * atomic_add_unless - add unless the number is a given value diff -puN include/asm-s390/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-s390/atomic.h --- devel/include/asm-s390/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-s390/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -84,6 +84,8 @@ static __inline__ int atomic_cmpxchg(ato return old; } +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) + static __inline__ int atomic_add_unless(atomic_t *v, int a, int u) { int c, old; diff -puN include/asm-sh64/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-sh64/atomic.h --- devel/include/asm-sh64/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-sh64/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -113,6 +113,8 @@ static inline int atomic_cmpxchg(atomic_ return ret; } +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) + static inline int atomic_add_unless(atomic_t *v, int a, int u) { int ret; diff -puN include/asm-sh/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-sh/atomic.h --- devel/include/asm-sh/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-sh/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -101,6 +101,8 @@ static inline int atomic_cmpxchg(atomic_ return ret; } +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) + static inline int atomic_add_unless(atomic_t *v, int a, int u) { int ret; diff -puN include/asm-sparc64/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-sparc64/atomic.h --- devel/include/asm-sparc64/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-sparc64/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -72,6 +72,7 @@ extern int atomic64_sub_ret(int, atomic6 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0) #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) #define atomic_add_unless(v, a, u) \ ({ \ diff -puN include/asm-sparc/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-sparc/atomic.h --- devel/include/asm-sparc/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-sparc/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -20,6 +20,7 @@ typedef struct { volatile int counter; } extern int __atomic_add_return(int, atomic_t *); extern int atomic_cmpxchg(atomic_t *, int, int); +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) extern int atomic_add_unless(atomic_t *, int, int); extern void atomic_set(atomic_t *, int); diff -puN include/asm-v850/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-v850/atomic.h --- devel/include/asm-v850/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-v850/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -104,6 +104,8 @@ static inline int atomic_cmpxchg(atomic_ return ret; } +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) + static inline int atomic_add_unless(atomic_t *v, int a, int u) { int ret; diff -puN include/asm-x86_64/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-x86_64/atomic.h --- devel/include/asm-x86_64/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-x86_64/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -389,6 +389,7 @@ static __inline__ long atomic64_sub_retu #define atomic64_dec_return(v) (atomic64_sub_return(1,v)) #define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new)) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) /** * atomic_add_unless - add unless the number is a given value diff -puN include/asm-xtensa/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches include/asm-xtensa/atomic.h --- devel/include/asm-xtensa/atomic.h~mutex-subsystem-add-atomic_xchg-to-all-arches 2006-01-06 23:13:59.000000000 -0800 +++ devel-akpm/include/asm-xtensa/atomic.h 2006-01-06 23:13:59.000000000 -0800 @@ -224,6 +224,7 @@ static inline int atomic_sub_return(int #define atomic_add_negative(i,v) (atomic_add_return((i),(v)) < 0) #define atomic_cmpxchg(v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n))) +#define atomic_xchg(v, new) (xchg(&((v)->counter), new)) /** * atomic_add_unless - add unless the number is a given value _