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

Go to the source code of this file.

Macros

#define ATOMIC_INIT(i)   { (i) }
 
#define ATOMIC64_INIT(i)   { (i) }
 
#define atomic_read(v)   (*(volatile int *)&(v)->counter)
 
#define atomic64_read(v)   (*(volatile long *)&(v)->counter)
 
#define atomic_set(v, i)   (((v)->counter) = (i))
 
#define atomic64_set(v, i)   (((v)->counter) = (i))
 
#define atomic_cmpxchg(v, old, new)   (cmpxchg(&((v)->counter), old, new))
 
#define atomic_xchg(v, new)   (xchg(&((v)->counter), new))
 
#define atomic64_cmpxchg(v, old, new)   (cmpxchg(&((v)->counter), old, new))
 
#define atomic64_xchg(v, new)   (xchg(&((v)->counter), new))
 
#define atomic64_inc_not_zero(v)   atomic64_add_unless((v), 1, 0)
 
#define atomic_add_return(i, v)
 
#define atomic64_add_return(i, v)
 
#define atomic_sub_return(i, v)
 
#define atomic64_sub_return(i, v)
 
#define atomic_dec_return(v)   atomic_sub_return(1, (v))
 
#define atomic_inc_return(v)   atomic_add_return(1, (v))
 
#define atomic64_dec_return(v)   atomic64_sub_return(1, (v))
 
#define atomic64_inc_return(v)   atomic64_add_return(1, (v))
 
#define atomic_sub_and_test(i, v)   (atomic_sub_return((i), (v)) == 0)
 
#define atomic_dec_and_test(v)   (atomic_sub_return(1, (v)) == 0)
 
#define atomic_inc_and_test(v)   (atomic_add_return(1, (v)) == 0)
 
#define atomic64_sub_and_test(i, v)   (atomic64_sub_return((i), (v)) == 0)
 
#define atomic64_dec_and_test(v)   (atomic64_sub_return(1, (v)) == 0)
 
#define atomic64_inc_and_test(v)   (atomic64_add_return(1, (v)) == 0)
 
#define atomic_add(i, v)   atomic_add_return((i), (v))
 
#define atomic_sub(i, v)   atomic_sub_return((i), (v))
 
#define atomic_inc(v)   atomic_add(1, (v))
 
#define atomic_dec(v)   atomic_sub(1, (v))
 
#define atomic64_add(i, v)   atomic64_add_return((i), (v))
 
#define atomic64_sub(i, v)   atomic64_sub_return((i), (v))
 
#define atomic64_inc(v)   atomic64_add(1, (v))
 
#define atomic64_dec(v)   atomic64_sub(1, (v))
 
#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 atomic64_add (   i,
  v 
)    atomic64_add_return((i), (v))

Definition at line 206 of file atomic.h.

#define atomic64_add_return (   i,
  v 
)
Value:
({ \
long __ia64_aar_i = (i); \
(__builtin_constant_p(i) \
&& ( (__ia64_aar_i == 1) || (__ia64_aar_i == 4) \
|| (__ia64_aar_i == 8) || (__ia64_aar_i == 16) \
|| (__ia64_aar_i == -1) || (__ia64_aar_i == -4) \
|| (__ia64_aar_i == -8) || (__ia64_aar_i == -16))) \
? ia64_fetch_and_add(__ia64_aar_i, &(v)->counter) \
: ia64_atomic64_add(__ia64_aar_i, v); \
})

Definition at line 137 of file atomic.h.

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

Definition at line 88 of file atomic.h.

#define atomic64_dec (   v)    atomic64_sub(1, (v))

Definition at line 209 of file atomic.h.

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

Definition at line 198 of file atomic.h.

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

Definition at line 191 of file atomic.h.

#define atomic64_inc (   v)    atomic64_add(1, (v))

Definition at line 208 of file atomic.h.

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

Definition at line 199 of file atomic.h.

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

Definition at line 123 of file atomic.h.

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

Definition at line 192 of file atomic.h.

#define ATOMIC64_INIT (   i)    { (i) }

Definition at line 21 of file atomic.h.

#define atomic64_read (   v)    (*(volatile long *)&(v)->counter)

Definition at line 24 of file atomic.h.

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

Definition at line 27 of file atomic.h.

#define atomic64_sub (   i,
  v 
)    atomic64_sub_return((i), (v))

Definition at line 207 of file atomic.h.

#define atomic64_sub_and_test (   i,
  v 
)    (atomic64_sub_return((i), (v)) == 0)

Definition at line 197 of file atomic.h.

#define atomic64_sub_return (   i,
  v 
)
Value:
({ \
long __ia64_asr_i = (i); \
(__builtin_constant_p(i) \
&& ( (__ia64_asr_i == 1) || (__ia64_asr_i == 4) \
|| (__ia64_asr_i == 8) || (__ia64_asr_i == 16) \
|| (__ia64_asr_i == -1) || (__ia64_asr_i == -4) \
|| (__ia64_asr_i == -8) || (__ia64_asr_i == -16))) \
? ia64_fetch_and_add(-__ia64_asr_i, &(v)->counter) \
: ia64_atomic64_sub(__ia64_asr_i, v); \
})

Definition at line 177 of file atomic.h.

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

Definition at line 90 of file atomic.h.

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

Definition at line 201 of file atomic.h.

#define atomic_add_return (   i,
  v 
)
Value:
({ \
int __ia64_aar_i = (i); \
(__builtin_constant_p(i) \
&& ( (__ia64_aar_i == 1) || (__ia64_aar_i == 4) \
|| (__ia64_aar_i == 8) || (__ia64_aar_i == 16) \
|| (__ia64_aar_i == -1) || (__ia64_aar_i == -4) \
|| (__ia64_aar_i == -8) || (__ia64_aar_i == -16))) \
? ia64_fetch_and_add(__ia64_aar_i, &(v)->counter) \
: ia64_atomic_add(__ia64_aar_i, v); \
})

Definition at line 125 of file atomic.h.

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

Definition at line 85 of file atomic.h.

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

Definition at line 204 of file atomic.h.

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

Definition at line 195 of file atomic.h.

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

Definition at line 189 of file atomic.h.

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

Definition at line 203 of file atomic.h.

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

Definition at line 196 of file atomic.h.

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

Definition at line 190 of file atomic.h.

#define ATOMIC_INIT (   i)    { (i) }

Definition at line 20 of file atomic.h.

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

Definition at line 23 of file atomic.h.

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

Definition at line 26 of file atomic.h.

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

Definition at line 202 of file atomic.h.

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

Definition at line 194 of file atomic.h.

#define atomic_sub_return (   i,
  v 
)
Value:
({ \
int __ia64_asr_i = (i); \
(__builtin_constant_p(i) \
&& ( (__ia64_asr_i == 1) || (__ia64_asr_i == 4) \
|| (__ia64_asr_i == 8) || (__ia64_asr_i == 16) \
|| (__ia64_asr_i == -1) || (__ia64_asr_i == -4) \
|| (__ia64_asr_i == -8) || (__ia64_asr_i == -16))) \
? ia64_fetch_and_add(-__ia64_asr_i, &(v)->counter) \
: ia64_atomic_sub(__ia64_asr_i, v); \
})

Definition at line 165 of file atomic.h.

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

Definition at line 86 of file atomic.h.

#define smp_mb__after_atomic_dec ( )    barrier()

Definition at line 213 of file atomic.h.

#define smp_mb__after_atomic_inc ( )    barrier()

Definition at line 215 of file atomic.h.

#define smp_mb__before_atomic_dec ( )    barrier()

Definition at line 212 of file atomic.h.

#define smp_mb__before_atomic_inc ( )    barrier()

Definition at line 214 of file atomic.h.