Skip to content

Commit

Permalink
x86 atomic operations: atomic_or_long() atomic_inc_short()
Browse files Browse the repository at this point in the history
Provide atomic operations for increment of a 16-bit integer and
logical OR into a 64-bit integer.

Signed-off-by: Cliff Wickman <cpw@sgi.com>
Reviewed-by: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Cliff Wickman authored and Ingo Molnar committed Jul 8, 2008
1 parent 1812924 commit 73e991f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions include/asm-x86/atomic_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,32 @@ static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
return c != (u);
}

/**
* atomic_inc_short - increment of a short integer
* @v: pointer to type int
*
* Atomically adds 1 to @v
* Returns the new value of @u
*/
static inline short int atomic_inc_short(short int *v)
{
asm(LOCK_PREFIX "addw $1, %0" : "+m" (*v));
return *v;
}

/**
* atomic_or_long - OR of two long integers
* @v1: pointer to type unsigned long
* @v2: pointer to type unsigned long
*
* Atomically ORs @v1 and @v2
* Returns the result of the OR
*/
static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
{
asm(LOCK_PREFIX "orq %1, %0" : "+m" (*v1) : "r" (v2));
}

#define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)

/* These are x86-specific, used by some header files */
Expand Down

0 comments on commit 73e991f

Please sign in to comment.