Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros
atomic.h File Reference
#include <linux/types.h>
#include <asm/assembler.h>
#include <asm/cmpxchg.h>
#include <asm/dcache_clear.h>

Go to the source code of this file.

Macros

#define ATOMIC_INIT(i)   { (i) }
 
#define atomic_read(v)   (*(volatile int *)&(v)->counter)
 
#define atomic_set(v, i)   (((v)->counter) = (i))
 
#define atomic_add(i, v)   ((void) atomic_add_return((i), (v)))
 
#define atomic_sub(i, v)   ((void) atomic_sub_return((i), (v)))
 
#define atomic_sub_and_test(i, v)   (atomic_sub_return((i), (v)) == 0)
 
#define atomic_inc(v)   ((void)atomic_inc_return(v))
 
#define atomic_dec(v)   ((void)atomic_dec_return(v))
 
#define atomic_inc_and_test(v)   (atomic_inc_return(v) == 0)
 
#define atomic_dec_and_test(v)   (atomic_dec_return(v) == 0)
 
#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))
 
#define smp_mb__before_atomic_dec()   barrier()
 
#define smp_mb__after_atomic_dec()   barrier()
 
#define smp_mb__before_atomic_inc()   barrier()
 
#define smp_mb__after_atomic_inc()   barrier()
 

Macro Definition Documentation

#define atomic_add (   i,
  v 
)    ((void) atomic_add_return((i), (v)))

atomic_add - add integer to atomic variable : integer value to add : pointer of type atomic_t

Atomically adds to .

Definition at line 110 of file atomic.h.

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

atomic_add_negative - add and test if negative : pointer of type atomic_t : integer value to add

Atomically adds to and returns true if the result is negative, or false when result is greater than or equal to zero.

Definition at line 237 of file atomic.h.

#define atomic_cmpxchg (   v,
  o,
  n 
)    ((int)cmpxchg(&((v)->counter), (o), (n)))

Definition at line 239 of file atomic.h.

#define atomic_dec (   v)    ((void)atomic_dec_return(v))

atomic_dec - decrement atomic variable : pointer of type atomic_t

Atomically decrements by 1.

Definition at line 206 of file atomic.h.

#define atomic_dec_and_test (   v)    (atomic_dec_return(v) == 0)

atomic_dec_and_test - decrement and test : pointer of type atomic_t

Atomically decrements by 1 and returns true if the result is 0, or false for all other cases.

Definition at line 226 of file atomic.h.

#define atomic_inc (   v)    ((void)atomic_inc_return(v))

atomic_inc - increment atomic variable : pointer of type atomic_t

Atomically increments by 1.

Definition at line 198 of file atomic.h.

#define atomic_inc_and_test (   v)    (atomic_inc_return(v) == 0)

atomic_inc_and_test - increment and test : pointer of type atomic_t

Atomically increments by 1 and returns true if the result is zero, or false for all other cases.

Definition at line 216 of file atomic.h.

#define ATOMIC_INIT (   i)    { (i) }

Definition at line 22 of file atomic.h.

#define atomic_read (   v)    (*(volatile int *)&(v)->counter)

atomic_read - read atomic variable : pointer of type atomic_t

Atomically reads the value of .

Definition at line 30 of file atomic.h.

#define atomic_set (   v,
  i 
)    (((v)->counter) = (i))

atomic_set - set atomic variable : pointer of type atomic_t : required value

Atomically sets the value of to .

Definition at line 39 of file atomic.h.

#define atomic_sub (   i,
  v 
)    ((void) atomic_sub_return((i), (v)))

atomic_sub - subtract the atomic variable : integer value to subtract : pointer of type atomic_t

Atomically subtracts from .

Definition at line 119 of file atomic.h.

#define atomic_sub_and_test (   i,
  v 
)    (atomic_sub_return((i), (v)) == 0)

atomic_sub_and_test - subtract value from variable and test result : integer value to subtract : pointer of type atomic_t

Atomically subtracts from and returns true if the result is zero, or false for all other cases.

Definition at line 130 of file atomic.h.

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

Definition at line 240 of file atomic.h.

#define smp_mb__after_atomic_dec ( )    barrier()

Definition at line 313 of file atomic.h.

#define smp_mb__after_atomic_inc ( )    barrier()

Definition at line 315 of file atomic.h.

#define smp_mb__before_atomic_dec ( )    barrier()

Definition at line 312 of file atomic.h.

#define smp_mb__before_atomic_inc ( )    barrier()

Definition at line 314 of file atomic.h.