1906afcb8SAndy Fiddaman/* : : generated from contrib/ast/src/lib/libast/features/aso by iffe version 2012-07-17 : : */ 2906afcb8SAndy Fiddaman#ifndef _def_aso_ast 3906afcb8SAndy Fiddaman#define _def_aso_ast 1 4906afcb8SAndy Fiddaman#define _sys_types 1 /* #include <sys/types.h> ok */ 5*d8bd5113SAndy Fiddaman 6*d8bd5113SAndy Fiddaman#if defined (__GNUC__) && (__GNUC__ == 4) 7*d8bd5113SAndy Fiddaman/* <atomic.h> atomic_cas_64 */ 8*d8bd5113SAndy Fiddaman#include <atomic.h> 9*d8bd5113SAndy Fiddaman#define _aso_cas8(p,o,n) atomic_cas_8(p,o,n) 10*d8bd5113SAndy Fiddaman#define _aso_inc8(p) (atomic_add_8_nv(p,1)-1) 11*d8bd5113SAndy Fiddaman#define _aso_dec8(p) (atomic_add_8_nv(p,-1)+1) 12*d8bd5113SAndy Fiddaman#define _aso_cas16(p,o,n) atomic_cas_16(p,o,n) 13*d8bd5113SAndy Fiddaman#define _aso_inc16(p) (atomic_add_16_nv(p,1)-1) 14*d8bd5113SAndy Fiddaman#define _aso_dec16(p) (atomic_add_16_nv(p,-1)+1) 15*d8bd5113SAndy Fiddaman#define _aso_cas32(p,o,n) atomic_cas_32(p,o,n) 16*d8bd5113SAndy Fiddaman#define _aso_inc32(p) (atomic_add_32_nv(p,1)-1) 17*d8bd5113SAndy Fiddaman#define _aso_dec32(p) (atomic_add_32_nv(p,-1)+1) 18*d8bd5113SAndy Fiddaman#define _aso_cas64(p,o,n) atomic_cas_64(p,o,n) 19*d8bd5113SAndy Fiddaman#define _aso_inc64(p) (atomic_add_64_nv(p,1)-1) 20*d8bd5113SAndy Fiddaman#define _aso_dec64(p) (atomic_add_64_nv(p,-1)+1) 21*d8bd5113SAndy Fiddaman#if _ast_sizeof_pointer == 8 22*d8bd5113SAndy Fiddaman#define _aso_casptr(p,o,n) ((void*)atomic_cas_64((uint64_t*)p,(uint64_t)o,(uint64_t)n)) 23*d8bd5113SAndy Fiddaman#else 24*d8bd5113SAndy Fiddaman#define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) 25*d8bd5113SAndy Fiddaman#endif 26*d8bd5113SAndy Fiddaman 27*d8bd5113SAndy Fiddaman#else /* __GNUC__ == 4 */ 28*d8bd5113SAndy Fiddaman 29906afcb8SAndy Fiddaman/* gcc 4.1+ 64 bit memory atomic operations model */ 30906afcb8SAndy Fiddaman#define _aso_cas8(p,o,n) __sync_val_compare_and_swap(p,o,n) 31906afcb8SAndy Fiddaman#define _aso_inc8(p) __sync_fetch_and_add(p,1) 32906afcb8SAndy Fiddaman#define _aso_dec8(p) __sync_fetch_and_sub(p,1) 33906afcb8SAndy Fiddaman#define _aso_cas16(p,o,n) __sync_val_compare_and_swap(p,o,n) 34906afcb8SAndy Fiddaman#define _aso_inc16(p) __sync_fetch_and_add(p,1) 35906afcb8SAndy Fiddaman#define _aso_dec16(p) __sync_fetch_and_sub(p,1) 36906afcb8SAndy Fiddaman#define _aso_cas32(p,o,n) __sync_val_compare_and_swap(p,o,n) 37906afcb8SAndy Fiddaman#define _aso_inc32(p) __sync_fetch_and_add(p,1) 38906afcb8SAndy Fiddaman#define _aso_dec32(p) __sync_fetch_and_sub(p,1) 39906afcb8SAndy Fiddaman#define _aso_cas64(p,o,n) __sync_val_compare_and_swap(p,o,n) 40906afcb8SAndy Fiddaman#define _aso_inc64(p) __sync_fetch_and_add(p,1) 41906afcb8SAndy Fiddaman#define _aso_dec64(p) __sync_fetch_and_sub(p,1) 42906afcb8SAndy Fiddaman#if _ast_sizeof_pointer == 8 43906afcb8SAndy Fiddaman#define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,(uint64_t)o,(uint64_t)n)) 44906afcb8SAndy Fiddaman#else 45906afcb8SAndy Fiddaman#define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,(uint32_t)o,(uint32_t)n)) 46906afcb8SAndy Fiddaman#endif 47906afcb8SAndy Fiddaman 48*d8bd5113SAndy Fiddaman#endif /* __GNUC__ == 4 */ 49*d8bd5113SAndy Fiddaman 50906afcb8SAndy Fiddaman#endif 51