Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
_atomic-deccxx.h
Go to the documentation of this file.
1
33// get declarations of __ATOMIC_XXX intrinsics
34# include <machine/builtins.h>
35
36#define _RWSTD_NO_CHAR_ATOMIC_OPS
37#define _RWSTD_NO_SHORT_ATOMIC_OPS
38#define _RWSTD_NO_LLONG_ATOMIC_OPS
39
41
42// __ATOMIC_[DE|IN]CREMENT_[LONG|QUAD] and __ATOMIC_EXCH_[LONG|QUAD] are
43// intrinsic functions declared in <machine/builtins.h> that atomically
44// modify their argument and return its original value (__ATOMIC_XXX_LONG
45// is misnamed -- it actually operates on an int, not a long)
46
47inline int
48__rw_atomic_preincrement (int &__x, bool)
49{
50 return 1 + __ATOMIC_INCREMENT_LONG (&__x);
51}
52
53
54inline unsigned
55__rw_atomic_preincrement (unsigned &__x, bool)
56{
57 return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (int&, __x),
58 false);
59}
60
61
62inline long
63__rw_atomic_preincrement (long &__x, bool)
64{
65 return 1 + __ATOMIC_INCREMENT_QUAD (&__x);
66}
67
68
69inline unsigned long
70__rw_atomic_preincrement (unsigned long &__x, bool)
71{
72 return __rw_atomic_preincrement (_RWSTD_REINTERPRET_CAST (long&, __x),
73 false);
74}
75
76
77inline int
78__rw_atomic_predecrement (int &__x, bool)
79{
80 return __ATOMIC_DECREMENT_LONG (&__x) - 1;
81}
82
83
84inline unsigned
85__rw_atomic_predecrement (unsigned &__x, bool)
86{
87 return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (int&, __x),
88 false);
89}
90
91
92inline long
93__rw_atomic_predecrement (long &__x, bool)
94{
95 return __ATOMIC_DECREMENT_QUAD (&__x) - 1;
96}
97
98
99inline unsigned long
100__rw_atomic_predecrement (unsigned long &__x, bool)
101{
102 return __rw_atomic_predecrement (_RWSTD_REINTERPRET_CAST (long&, __x),
103 false);
104}
105
106
107inline int
108__rw_atomic_exchange (int &__x, int __y, bool)
109{
110 return __ATOMIC_EXCH_LONG (&__x, __y);
111}
112
113
114inline unsigned
115__rw_atomic_exchange (unsigned &__x, unsigned __y, bool)
116{
117 return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (unsigned&, __x),
118 _RWSTD_STATIC_CAST (int, __y), false);
119}
120
121
122inline long
123__rw_atomic_exchange (long &__x, long __y, bool)
124{
125 return __ATOMIC_EXCH_QUAD (&__x, __y);
126}
127
128
129inline unsigned long
130__rw_atomic_exchange (unsigned long &__x, unsigned long __y, bool)
131{
132 return __rw_atomic_exchange (_RWSTD_REINTERPRET_CAST (long&, __x),
133 _RWSTD_STATIC_CAST (long, __y), false);
134}
135
136} // namespace __rw
#define _RWSTD_REINTERPRET_CAST(T, x)
Definition _defs.h:535
#define _RWSTD_STATIC_CAST(T, x)
Definition _defs.h:534
#define _RWSTD_NAMESPACE(name)
Definition _defs.h:567