Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
_atomic-sparc.h
Go to the documentation of this file.
1
34
35#define _RWSTD_NO_CHAR_ATOMIC_OPS
36#define _RWSTD_NO_SHORT_ATOMIC_OPS
37#define _RWSTD_NO_LLONG_ATOMIC_OPS
38
39extern "C" {
40
41// define in assembler file "atomic-sparc.s" and "atomic-sparc64.s"
42// exchange returns the original value, and add returns the incremented
43// value
44
45int __rw_atomic_xchg32 (int*, int);
46int __rw_atomic_add32 (int*, int);
47
48# if defined (__sparcv9) || defined (__sparcv9__)
49
50long __rw_atomic_xchg64 (long*, long);
51long __rw_atomic_add64 (long*, long);
52
53# endif
54
55} // extern "C"
56
57
58inline int
59__rw_atomic_preincrement (int &__x, bool)
60{
61 _RWSTD_COMPILE_ASSERT (4 == sizeof (int));
62 return __rw_atomic_add32 (&__x, 1);
63}
64
65
66inline unsigned
67__rw_atomic_preincrement (unsigned &__x, bool)
68{
69 _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned));
70 return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (int*, &__x), 1);
71}
72
73
74inline int
75__rw_atomic_predecrement (int &__x, bool)
76{
77 _RWSTD_COMPILE_ASSERT (4 == sizeof (int));
78 return __rw_atomic_add32 (&__x, -1);
79}
80
81
82inline unsigned
83__rw_atomic_predecrement (unsigned &__x, bool)
84{
85 _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned));
86 return __rw_atomic_add32 (_RWSTD_REINTERPRET_CAST (int*, &__x), -1);
87}
88
89
90inline int
91__rw_atomic_exchange (int &__x, int __y, bool)
92{
93 _RWSTD_COMPILE_ASSERT (4 == sizeof (int));
94 return __rw_atomic_xchg32 (&__x, __y);
95}
96
97
98inline unsigned
99__rw_atomic_exchange (unsigned &__x, unsigned __y, bool)
100{
101 _RWSTD_COMPILE_ASSERT (4 == sizeof (unsigned));
102 return __rw_atomic_xchg32 (_RWSTD_REINTERPRET_CAST (int*, &__x),
103 _RWSTD_STATIC_CAST (int, __y));
104}
105
106# if _RWSTD_INT_SIZE < _RWSTD_LONG_SIZE
107
108inline long
109__rw_atomic_preincrement (long &__x, bool)
110{
111 _RWSTD_COMPILE_ASSERT (8 == sizeof (long));
112 return __rw_atomic_add64 (&__x, 1);
113}
114
115
116inline unsigned long
117__rw_atomic_preincrement (unsigned long &__x, bool)
118{
119 _RWSTD_COMPILE_ASSERT (8 == sizeof (unsigned long));
120 return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (long*, &__x), 1);
121}
122
123
124inline long
125__rw_atomic_predecrement (long &__x, bool)
126{
127 _RWSTD_COMPILE_ASSERT (8 == sizeof (long));
128 return __rw_atomic_add64 (&__x, -1);
129}
130
131
132inline unsigned long
133__rw_atomic_predecrement (unsigned long &__x, bool)
134{
135 _RWSTD_COMPILE_ASSERT (8 == sizeof (unsigned long));
136 return __rw_atomic_add64 (_RWSTD_REINTERPRET_CAST (long*, &__x), -1);
137}
138
139
140inline long
141__rw_atomic_exchange (long &__x, long __y, bool)
142{
143 _RWSTD_COMPILE_ASSERT (8 == sizeof (long));
144 return __rw_atomic_xchg64 (&__x, __y);
145}
146
147
148inline unsigned long
149__rw_atomic_exchange (unsigned long &__x, unsigned long __y, bool)
150{
151 _RWSTD_COMPILE_ASSERT (8 == sizeof (unsigned long));
152 return __rw_atomic_xchg64 (_RWSTD_REINTERPRET_CAST (long*, &__x),
153 _RWSTD_STATIC_CAST (long, __y));
154}
155
156# else // _RWSTD_INT_SIZE == _RWSTD_LONG_SIZE
157# define _RWSTD_NO_LONG_ATOMIC_OPS
158# endif // _RWSTD_INT_SIZE < _RWSTD_LONG_SIZE
159
160} // 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
#define _RWSTD_COMPILE_ASSERT(const_expr)