Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 14647
b: refs/heads/master
c: 7c72aaf
h: refs/heads/master
i:
  14645: c6e73f0
  14643: 92412be
  14639: 8b84283
v: v3
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Nov 24, 2005
1 parent c12e433 commit feb7d2e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7ce774b4808c019c2f143ff5dea1a1b094ff01e1
refs/heads/master: 7c72aaf29621d29ed19fd68c44edb45321645049
7 changes: 5 additions & 2 deletions trunk/include/asm-alpha/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ static __inline__ long atomic_add_return(int i, atomic_t * v)
return result;
}

#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)

static __inline__ long atomic64_add_return(long i, atomic64_t * v)
{
long temp, result;
Expand Down Expand Up @@ -189,6 +187,9 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
})
#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)

#define atomic_add_negative(a, v) (atomic_add_return((a), (v)) < 0)
#define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)

#define atomic_dec_return(v) atomic_sub_return(1,(v))
#define atomic64_dec_return(v) atomic64_sub_return(1,(v))

Expand All @@ -199,6 +200,8 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
#define atomic64_sub_and_test(i,v) (atomic64_sub_return((i), (v)) == 0)

#define atomic_inc_and_test(v) (atomic_add_return(1, (v)) == 0)
#define atomic64_inc_and_test(v) (atomic64_add_return(1, (v)) == 0)

#define atomic_dec_and_test(v) (atomic_sub_return(1, (v)) == 0)
#define atomic64_dec_and_test(v) (atomic64_sub_return(1, (v)) == 0)

Expand Down
1 change: 1 addition & 0 deletions trunk/include/asm-sparc64/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ extern int atomic64_sub_ret(int, atomic64_t *);
* other cases.
*/
#define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
#define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)

#define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
#define atomic64_sub_and_test(i, v) (atomic64_sub_ret(i, v) == 0)
Expand Down
51 changes: 38 additions & 13 deletions trunk/include/asm-x86_64/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ static __inline__ int atomic_inc_and_test(atomic_t *v)

/**
* atomic_add_negative - add and test if negative
* @v: pointer of type atomic_t
* @i: integer value to add
* @v: pointer of type atomic_t
*
* Atomically adds @i to @v and returns true
* if the result is negative, or false when
Expand All @@ -178,6 +178,31 @@ static __inline__ int atomic_add_negative(int i, atomic_t *v)
return c;
}

/**
* atomic_add_return - add and return
* @i: integer value to add
* @v: pointer of type atomic_t
*
* Atomically adds @i to @v and returns @i + @v
*/
static __inline__ int atomic_add_return(int i, atomic_t *v)
{
int __i = i;
__asm__ __volatile__(
LOCK "xaddl %0, %1;"
:"=r"(i)
:"m"(v->counter), "0"(i));
return i + __i;
}

static __inline__ int atomic_sub_return(int i, atomic_t *v)
{
return atomic_add_return(-i,v);
}

#define atomic_inc_return(v) (atomic_add_return(1,v))
#define atomic_dec_return(v) (atomic_sub_return(1,v))

/* An 64bit atomic type */

typedef struct { volatile long counter; } atomic64_t;
Expand Down Expand Up @@ -320,14 +345,14 @@ static __inline__ int atomic64_inc_and_test(atomic64_t *v)

/**
* atomic64_add_negative - add and test if negative
* @v: pointer to atomic64_t
* @i: integer value to add
* @v: pointer to type atomic64_t
*
* Atomically adds @i to @v and returns true
* if the result is negative, or false when
* result is greater than or equal to zero.
*/
static __inline__ long atomic64_add_negative(long i, atomic64_t *v)
static __inline__ int atomic64_add_negative(long i, atomic64_t *v)
{
unsigned char c;

Expand All @@ -339,27 +364,30 @@ static __inline__ long atomic64_add_negative(long i, atomic64_t *v)
}

/**
* atomic_add_return - add and return
* @v: pointer of type atomic_t
* atomic64_add_return - add and return
* @i: integer value to add
* @v: pointer to type atomic64_t
*
* Atomically adds @i to @v and returns @i + @v
*/
static __inline__ int atomic_add_return(int i, atomic_t *v)
static __inline__ long atomic64_add_return(long i, atomic64_t *v)
{
int __i = i;
long __i = i;
__asm__ __volatile__(
LOCK "xaddl %0, %1;"
LOCK "xaddq %0, %1;"
:"=r"(i)
:"m"(v->counter), "0"(i));
return i + __i;
}

static __inline__ int atomic_sub_return(int i, atomic_t *v)
static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
{
return atomic_add_return(-i,v);
return atomic64_add_return(-i,v);
}

#define atomic64_inc_return(v) (atomic64_add_return(1,v))
#define atomic64_dec_return(v) (atomic64_sub_return(1,v))

#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))

/**
Expand All @@ -381,9 +409,6 @@ static __inline__ int atomic_sub_return(int i, atomic_t *v)
})
#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)

#define atomic_inc_return(v) (atomic_add_return(1,v))
#define atomic_dec_return(v) (atomic_sub_return(1,v))

/* These are x86-specific, used by some header files */
#define atomic_clear_mask(mask, addr) \
__asm__ __volatile__(LOCK "andl %0,%1" \
Expand Down

0 comments on commit feb7d2e

Please sign in to comment.