Home | History | Annotate | Download | only in asm
      1 /****************************************************************************
      2  ****************************************************************************
      3  ***
      4  ***   This header was automatically generated from a Linux kernel header
      5  ***   of the same name, to make information necessary for userspace to
      6  ***   call into the kernel available to libc.  It contains only constants,
      7  ***   structures, and macros generated from the original header, and thus,
      8  ***   contains no copyrightable information.
      9  ***
     10  ****************************************************************************
     11  ****************************************************************************/
     12 #ifndef __ARCH_I386_ATOMIC__
     13 #define __ARCH_I386_ATOMIC__
     14 
     15 #include <linux/compiler.h>
     16 #include <asm/processor.h>
     17 #include <asm/cmpxchg.h>
     18 
     19 typedef struct { int counter; } atomic_t;
     20 
     21 #define ATOMIC_INIT(i) { (i) }
     22 
     23 #define atomic_read(v) ((v)->counter)
     24 
     25 #define atomic_set(v,i) (((v)->counter) = (i))
     26 
     27 #define atomic_cmpxchg(v, old, new) (cmpxchg(&((v)->counter), (old), (new)))
     28 #define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
     29 #define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
     30 #define atomic_inc_return(v) (atomic_add_return(1,v))
     31 #define atomic_dec_return(v) (atomic_sub_return(1,v))
     32 #define atomic_clear_mask(mask, addr)  __asm__ __volatile__(LOCK_PREFIX "andl %0,%1"  : : "r" (~(mask)),"m" (*addr) : "memory")
     33 #define atomic_set_mask(mask, addr)  __asm__ __volatile__(LOCK_PREFIX "orl %0,%1"  : : "r" (mask),"m" (*(addr)) : "memory")
     34 #define smp_mb__before_atomic_dec() barrier()
     35 #define smp_mb__after_atomic_dec() barrier()
     36 #define smp_mb__before_atomic_inc() barrier()
     37 #define smp_mb__after_atomic_inc() barrier()
     38 #include <asm-generic/atomic.h>
     39 #endif
     40