1b4dd7d09SAndy Fiddaman/* : : generated from contrib/ast/src/lib/libast/features/aso by iffe version 2012-07-17 : : */ 2b4dd7d09SAndy Fiddaman#ifndef _def_aso_ast 3b4dd7d09SAndy Fiddaman#define _def_aso_ast 1 4b4dd7d09SAndy Fiddaman#define _sys_types 1 /* #include <sys/types.h> ok */ 5*4f7d552cSAndy Fiddaman 6*4f7d552cSAndy Fiddaman#if defined (__GNUC__) && (__GNUC__ == 4) 7*4f7d552cSAndy Fiddaman/* <atomic.h> atomic_cas_64 */ 8*4f7d552cSAndy Fiddaman#include <atomic.h> 9*4f7d552cSAndy Fiddaman#define _aso_cas8(p,o,n) atomic_cas_8(p,o,n) 10*4f7d552cSAndy Fiddaman#define _aso_inc8(p) (atomic_add_8_nv(p,1)-1) 11*4f7d552cSAndy Fiddaman#define _aso_dec8(p) (atomic_add_8_nv(p,-1)+1) 12*4f7d552cSAndy Fiddaman#define _aso_cas16(p,o,n) atomic_cas_16(p,o,n) 13*4f7d552cSAndy Fiddaman#define _aso_inc16(p) (atomic_add_16_nv(p,1)-1) 14*4f7d552cSAndy Fiddaman#define _aso_dec16(p) (atomic_add_16_nv(p,-1)+1) 15*4f7d552cSAndy Fiddaman#define _aso_cas32(p,o,n) atomic_cas_32(p,o,n) 16*4f7d552cSAndy Fiddaman#define _aso_inc32(p) (atomic_add_32_nv(p,1)-1) 17*4f7d552cSAndy Fiddaman#define _aso_dec32(p) (atomic_add_32_nv(p,-1)+1) 18*4f7d552cSAndy Fiddaman#define _aso_cas64(p,o,n) atomic_cas_64(p,o,n) 19*4f7d552cSAndy Fiddaman#define _aso_inc64(p) (atomic_add_64_nv(p,1)-1) 20*4f7d552cSAndy Fiddaman#define _aso_dec64(p) (atomic_add_64_nv(p,-1)+1) 21*4f7d552cSAndy Fiddaman#if _ast_sizeof_pointer == 8 22*4f7d552cSAndy Fiddaman#define _aso_casptr(p,o,n) ((void*)atomic_cas_64((uint64_t*)p,(uint64_t)o,(uint64_t)n)) 23*4f7d552cSAndy Fiddaman#else 24*4f7d552cSAndy Fiddaman#define _aso_casptr(p,o,n) ((void*)atomic_cas_32((uint32_t*)p,(uint32_t)o,(uint32_t)n)) 25*4f7d552cSAndy Fiddaman#endif 26*4f7d552cSAndy Fiddaman 27*4f7d552cSAndy Fiddaman#else /* __GNUC__ == 4 */ 28*4f7d552cSAndy Fiddaman 29b4dd7d09SAndy Fiddaman/* gcc 4.1+ 64 bit memory atomic operations model */ 30b4dd7d09SAndy Fiddaman#define _aso_cas8(p,o,n) __sync_val_compare_and_swap(p,o,n) 31b4dd7d09SAndy Fiddaman#define _aso_inc8(p) __sync_fetch_and_add(p,1) 32b4dd7d09SAndy Fiddaman#define _aso_dec8(p) __sync_fetch_and_sub(p,1) 33b4dd7d09SAndy Fiddaman#define _aso_cas16(p,o,n) __sync_val_compare_and_swap(p,o,n) 34b4dd7d09SAndy Fiddaman#define _aso_inc16(p) __sync_fetch_and_add(p,1) 35b4dd7d09SAndy Fiddaman#define _aso_dec16(p) __sync_fetch_and_sub(p,1) 36b4dd7d09SAndy Fiddaman#define _aso_cas32(p,o,n) __sync_val_compare_and_swap(p,o,n) 37b4dd7d09SAndy Fiddaman#define _aso_inc32(p) __sync_fetch_and_add(p,1) 38b4dd7d09SAndy Fiddaman#define _aso_dec32(p) __sync_fetch_and_sub(p,1) 39b4dd7d09SAndy Fiddaman#define _aso_cas64(p,o,n) __sync_val_compare_and_swap(p,o,n) 40b4dd7d09SAndy Fiddaman#define _aso_inc64(p) __sync_fetch_and_add(p,1) 41b4dd7d09SAndy Fiddaman#define _aso_dec64(p) __sync_fetch_and_sub(p,1) 42b4dd7d09SAndy Fiddaman#if _ast_sizeof_pointer == 8 43b4dd7d09SAndy Fiddaman#define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,(uint64_t)o,(uint64_t)n)) 44b4dd7d09SAndy Fiddaman#else 45b4dd7d09SAndy Fiddaman#define _aso_casptr(p,o,n) ((void*)__sync_val_compare_and_swap(p,(uint32_t)o,(uint32_t)n)) 46b4dd7d09SAndy Fiddaman#endif 47b4dd7d09SAndy Fiddaman 48*4f7d552cSAndy Fiddaman#endif /* __GNUC__ == 4 */ 49*4f7d552cSAndy Fiddaman 50b4dd7d09SAndy Fiddaman#endif 51