Skip to content

Commit

Permalink
[PATCH] mutex subsystem, add atomic_xchg() to all arches
Browse files Browse the repository at this point in the history
add atomic_xchg() to all the architectures. Needed by the new mutex code.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Arjan van de Ven <arjan@infradead.org>
  • Loading branch information
Ingo Molnar authored and Ingo Molnar committed Jan 9, 2006
1 parent f17578d commit ffbf670
Show file tree
Hide file tree
Showing 22 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/asm-alpha/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
}

#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) \
({ \
Expand Down
2 changes: 2 additions & 0 deletions include/asm-arm/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)

#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;
Expand Down
2 changes: 2 additions & 0 deletions include/asm-arm26/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
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;
Expand Down
2 changes: 2 additions & 0 deletions include/asm-cris/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
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;
Expand Down
1 change: 1 addition & 0 deletions include/asm-frv/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ extern uint32_t __cmpxchg_32(uint32_t *v, uint32_t test, uint32_t new);
#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) \
({ \
Expand Down
2 changes: 2 additions & 0 deletions include/asm-h8300/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
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;
Expand Down
1 change: 1 addition & 0 deletions include/asm-i386/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t *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
Expand Down
1 change: 1 addition & 0 deletions include/asm-ia64/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ ia64_atomic64_sub (__s64 i, atomic64_t *v)
}

#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) \
({ \
Expand Down
1 change: 1 addition & 0 deletions include/asm-m32r/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ static __inline__ int atomic_dec_return(atomic_t *v)
#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
Expand Down
1 change: 1 addition & 0 deletions include/asm-m68k/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ static inline void atomic_set_mask(unsigned long mask, unsigned long *v)
}

#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) \
({ \
Expand Down
1 change: 1 addition & 0 deletions include/asm-m68knommu/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ static inline int atomic_sub_return(int i, atomic_t * v)
}

#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) \
({ \
Expand Down
1 change: 1 addition & 0 deletions include/asm-mips/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
}

#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
Expand Down
1 change: 1 addition & 0 deletions include/asm-parisc/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ static __inline__ int atomic_read(const atomic_t *v)

/* 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
Expand Down
1 change: 1 addition & 0 deletions include/asm-powerpc/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ static __inline__ int atomic_dec_return(atomic_t *v)
}

#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
Expand Down
2 changes: 2 additions & 0 deletions include/asm-s390/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ static __inline__ void atomic_set_mask(unsigned long mask, atomic_t * v)
__CS_LOOP(v, mask, "or");
}

#define atomic_xchg(v, new) (xchg(&((v)->counter), new))

static __inline__ int atomic_cmpxchg(atomic_t *v, int old, int new)
{
__asm__ __volatile__(" cs %0,%3,0(%2)\n"
Expand Down
2 changes: 2 additions & 0 deletions include/asm-sh/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
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;
Expand Down
2 changes: 2 additions & 0 deletions include/asm-sh64/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
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;
Expand Down
1 change: 1 addition & 0 deletions include/asm-sparc/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ typedef struct { volatile int counter; } atomic_t;

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);

Expand Down
1 change: 1 addition & 0 deletions include/asm-sparc64/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ extern int atomic64_sub_ret(int, atomic64_t *);
#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) \
({ \
Expand Down
2 changes: 2 additions & 0 deletions include/asm-v850/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
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;
Expand Down
1 change: 1 addition & 0 deletions include/asm-x86_64/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
#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
Expand Down
1 change: 1 addition & 0 deletions include/asm-xtensa/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ static inline int atomic_sub_return(int i, atomic_t * v)
#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
Expand Down

0 comments on commit ffbf670

Please sign in to comment.