mutex subsystem, add atomic_*_call_if_*() defaults to the remaining arches
Subsystems (2)
PATCH 5/8 mutex subsystem, add atomic_*_call_if_*() defaults to the remaining arches
add asm-generic/atomic-call-if.h, and make all remaining arches use it.
Signed-off-by Ingo Molnar <[email protected]>
----
include/asm-alpha/atomic.h | 11 ++++++++++ include/asm-arm/atomic.h | 11 ++++++++++ include/asm-arm26/atomic.h | 11 ++++++++++ include/asm-cris/atomic.h | 11 ++++++++++ include/asm-frv/atomic.h | 11 ++++++++++ include/asm-generic/atomic-call-if.h | 37 +++++++++++++++++++++++++++++++++++ include/asm-h8300/atomic.h | 11 ++++++++++ include/asm-ia64/atomic.h | 11 ++++++++++ include/asm-m32r/atomic.h | 11 ++++++++++ include/asm-m68k/atomic.h | 11 ++++++++++ include/asm-m68knommu/atomic.h | 11 ++++++++++ include/asm-mips/atomic.h | 11 ++++++++++ include/asm-parisc/atomic.h | 11 ++++++++++ include/asm-powerpc/atomic.h | 22 ++++++++++++++++++++ include/asm-s390/atomic.h | 11 ++++++++++ include/asm-sh/atomic.h | 11 ++++++++++ include/asm-sh64/atomic.h | 11 ++++++++++ include/asm-sparc/atomic.h | 12 +++++++++++ include/asm-sparc64/atomic.h | 11 ++++++++++ include/asm-v850/atomic.h | 11 ++++++++++ include/asm-xtensa/atomic.h | 11 ++++++++++ 21 files changed, 269 insertions(+)
include/asm-alpha/atomic.h +11 -0
@@ -178,6 +178,17 @@ 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)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-arm/atomic.h +11 -0
@@ -101,6 +101,17 @@ static inline int atomic_cmpxchg(atomic_#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +static inline void atomic_clear_mask (unsigned long mask,unsigned long *addr) {unsigned long tmp, tmp2;
include/asm-arm26/atomic.h +11 -0
@@ -78,6 +78,17 @@ static inline int atomic_cmpxchg(atomic_#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +static inline int atomic_add_unless (atomic_t *v,int a,int u) {int ret;
include/asm-cris/atomic.h +11 -0
@@ -138,6 +138,17 @@ static inline int atomic_cmpxchg(atomic_#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +static inline int atomic_add_unless (atomic_t *v,int a,int u) {int ret;
include/asm-frv/atomic.h +11 -0
@@ -417,6 +417,17 @@ extern uint32_t __cmpxchg_32(uint32_t *v#define atomic_cmpxchg (v, old, new) ((int)cmpxchg(&((v)->counter), old, new))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-generic/atomic-call-if.h new file +37 -0
@@ -0,0 +1,37 @@ +/* +* asm-generic/atomic-call-if.h +* +* Generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(), based on atomic_dec_return() +* and atomic_inc_return(). +*/ +#ifndef _ASM_GENERIC_ATOMIC_CALL_IF_H +#define _ASM_GENERIC_ATOMIC_CALL_IF_H + +/** +* atomic_dec_call_if_negative - decrement and call function if negative +* @v: pointer of type atomic_t +* @fn: function to call if the result is negative +* +* Atomically decrements @v and calls a function if the result is negative. +*/ +#define atomic_dec_call_if_negative (v, fn_name) \ +do { \ + if (atomic_dec_return(v) < 0) \ + fn_name(v); \ +} while (0) + +/** +* atomic_inc_call_if_nonpositive - increment and call function if nonpositive +* @v: pointer of type atomic_t +* @fn: function to call if the result is nonpositive +* +* Atomically increments @v and calls a function if the result is nonpositive. +*/ +#define atomic_inc_call_if_nonpositive (v, fn_name) \ +do { \ + if (atomic_inc_return(v) <= 0) \ + fn_name(v); \ +} while (0) + +#endif
include/asm-h8300/atomic.h +11 -0
@@ -97,6 +97,17 @@ static inline int atomic_cmpxchg(atomic_#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +static inline int atomic_add_unless (atomic_t *v,int a,int u) {int ret;
include/asm-ia64/atomic.h +11 -0
@@ -91,6 +91,17 @@ 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)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-m32r/atomic.h +11 -0
@@ -245,6 +245,17 @@ 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)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +/** * atomic_add_unless - add unless the number is a given value * @v: pointer of type atomic_t
include/asm-m68k/atomic.h +11 -0
@@ -142,6 +142,17 @@ 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)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-m68knommu/atomic.h +11 -0
@@ -131,6 +131,17 @@ 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)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-mips/atomic.h +11 -0
@@ -291,6 +291,17 @@ 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)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +/** * atomic_add_unless - add unless the number is a given value * @v: pointer of type atomic_t
include/asm-parisc/atomic.h +11 -0
@@ -167,6 +167,17 @@ static __inline__ int atomic_read(const#define atomic_cmpxchg (v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +/** * atomic_add_unless - add unless the number is a given value * @v: pointer of type atomic_t
include/asm-powerpc/atomic.h +22 -0
@@ -121,6 +121,17 @@ static __inline__ int atomic_inc_return( }/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> + +/* * atomic_inc_and_test - increment and test * @v: pointer of type atomic_t *
@@ -167,6 +178,17 @@ 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)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +/** * atomic_add_unless - add unless the number is a given value * @v: pointer of type atomic_t
include/asm-s390/atomic.h +11 -0
@@ -201,6 +201,17 @@ atomic_compare_and_swap(int expected_old#define atomic_cmpxchg (v, o, n) (atomic_compare_and_swap((o), (n), &((v)->counter)))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-sh/atomic.h +11 -0
@@ -103,6 +103,17 @@ static inline int atomic_cmpxchg(atomic_#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +static inline int atomic_add_unless (atomic_t *v,int a,int u) {int ret;
include/asm-sh64/atomic.h +11 -0
@@ -115,6 +115,17 @@ static inline int atomic_cmpxchg(atomic_#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +static inline int atomic_add_unless (atomic_t *v,int a,int u) {int ret;
include/asm-sparc/atomic.h +12 -0
@@ -21,6 +21,18 @@ 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)) + +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +extern int atomic_add_unless (atomic_t *,int ,int );extern void atomic_set (atomic_t *,int );
include/asm-sparc64/atomic.h +11 -0
@@ -74,6 +74,17 @@ extern int atomic64_sub_ret(int, atomic6#define atomic_cmpxchg (v, o, n) ((int)cmpxchg(&((v)->counter), (o), (n)))#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +#define atomic_add_unless (v, a, u) \ ({ \ int c, old; \
include/asm-v850/atomic.h +11 -0
@@ -106,6 +106,17 @@ static inline int atomic_cmpxchg(atomic_#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +static inline int atomic_add_unless (atomic_t *v,int a,int u) {int ret;
include/asm-xtensa/atomic.h +11 -0
@@ -226,6 +226,17 @@ 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)) +/* +* Pull in the generic wrappers for atomic_dec_call_if_negative() and +* atomic_inc_call_if_nonpositive(). +* +* TODO: implement optimized primitives instead, or leave the generic +* implementation in place, or use the ARCH_IMPLEMENTS_MUTEX_FASTPATH +* mechanism to override the generic mutex_lock()/mutex_unlock() +* functions. +*/ +#include <asm-generic/atomic-call-if.h> +/** * atomic_add_unless - add unless the number is a given value * @v: pointer of type atomic_t