Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 260453
b: refs/heads/master
c: 7505cb6
h: refs/heads/master
i:
  260451: a094d1c
v: v3
  • Loading branch information
Mike Frysinger authored and Linus Torvalds committed Jul 26, 2011
1 parent 9a517c6 commit d6df50f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 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: 00b3c28bd753afb46fb26b2f9e21dd27dacd80d4
refs/heads/master: 7505cb60c2d26301630b052852d484decf07aef1
16 changes: 15 additions & 1 deletion trunk/include/asm-generic/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
#define __ASM_GENERIC_ATOMIC_H

#ifdef CONFIG_SMP
#error not SMP safe
/* Force people to define core atomics */
# if !defined(atomic_add_return) || !defined(atomic_sub_return) || \
!defined(atomic_clear_mask) || !defined(atomic_set_mask)
# error "SMP requires a little arch-specific magic"
# endif
#endif

/*
Expand All @@ -34,7 +38,9 @@
*
* Atomically reads the value of @v.
*/
#ifndef atomic_read
#define atomic_read(v) (*(volatile int *)&(v)->counter)
#endif

/**
* atomic_set - set atomic variable
Expand All @@ -55,6 +61,7 @@
*
* Atomically adds @i to @v and returns the result
*/
#ifndef atomic_add_return
static inline int atomic_add_return(int i, atomic_t *v)
{
unsigned long flags;
Expand All @@ -68,6 +75,7 @@ static inline int atomic_add_return(int i, atomic_t *v)

return temp;
}
#endif

/**
* atomic_sub_return - subtract integer from atomic variable
Expand All @@ -76,6 +84,7 @@ static inline int atomic_add_return(int i, atomic_t *v)
*
* Atomically subtracts @i from @v and returns the result
*/
#ifndef atomic_sub_return
static inline int atomic_sub_return(int i, atomic_t *v)
{
unsigned long flags;
Expand All @@ -89,6 +98,7 @@ static inline int atomic_sub_return(int i, atomic_t *v)

return temp;
}
#endif

static inline int atomic_add_negative(int i, atomic_t *v)
{
Expand Down Expand Up @@ -147,6 +157,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
*
* Atomically clears the bits set in @mask from @v
*/
#ifndef atomic_clear_mask
static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
{
unsigned long flags;
Expand All @@ -156,6 +167,7 @@ static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
v->counter &= mask;
raw_local_irq_restore(flags);
}
#endif

/**
* atomic_set_mask - Atomically set bits in atomic variable
Expand All @@ -164,6 +176,7 @@ static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
*
* Atomically sets the bits set in @mask in @v
*/
#ifndef atomic_set_mask
static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
{
unsigned long flags;
Expand All @@ -172,6 +185,7 @@ static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
v->counter |= mask;
raw_local_irq_restore(flags);
}
#endif

/* Assume that atomic operations are already serializing */
#define smp_mb__before_atomic_dec() barrier()
Expand Down

0 comments on commit d6df50f

Please sign in to comment.