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