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/cmpxchg.h>

Go to the source code of this file.

Macros

#define ATOMIC_INIT(i)   { (i) }
 
#define atomic_set(v, i)   ((v)->counter = (i))
 
#define atomic_read(v)   ((v)->counter)
 
#define atomic_xchg(v, new)   (xchg(&((v)->counter), (new)))
 
#define atomic_add(i, v)   atomic_add_return(i, (v))
 
#define atomic_sub(i, v)   atomic_sub_return(i, (v))
 
#define atomic_inc_not_zero(v)   atomic_add_unless((v), 1, 0)
 
#define atomic_inc(v)   atomic_add(1, (v))
 
#define atomic_dec(v)   atomic_sub(1, (v))
 
#define atomic_inc_and_test(v)   (atomic_add_return(1, (v)) == 0)
 
#define atomic_dec_and_test(v)   (atomic_sub_return(1, (v)) == 0)
 
#define atomic_sub_and_test(i, v)   (atomic_sub_return(i, (v)) == 0)
 
#define atomic_add_negative(i, v)   (atomic_add_return(i, (v)) < 0)
 
#define atomic_inc_return(v)   (atomic_add_return(1, v))
 
#define atomic_dec_return(v)   (atomic_sub_return(1, v))
 

Macro Definition Documentation

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

Definition at line 100 of file atomic.h.

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

Definition at line 159 of file atomic.h.

#define atomic_dec (   v)    atomic_sub(1, (v))

Definition at line 154 of file atomic.h.

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

Definition at line 157 of file atomic.h.

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

Definition at line 163 of file atomic.h.

#define atomic_inc (   v)    atomic_add(1, (v))

Definition at line 153 of file atomic.h.

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

Definition at line 156 of file atomic.h.

#define atomic_inc_not_zero (   v)    atomic_add_unless((v), 1, 0)

Definition at line 151 of file atomic.h.

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

Definition at line 162 of file atomic.h.

#define ATOMIC_INIT (   i)    { (i) }

Definition at line 28 of file atomic.h.

#define atomic_read (   v)    ((v)->counter)

atomic_read - reads a word, atomically : pointer to atomic value

Assumes all word reads on our architecture are atomic.

Definition at line 37 of file atomic.h.

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

Definition at line 29 of file atomic.h.

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

Definition at line 117 of file atomic.h.

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

Definition at line 158 of file atomic.h.

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

atomic_xchg - atomic : pointer to memory to change : new value (technically passed in a register – see xchg)

Definition at line 44 of file atomic.h.