BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsls_atomicoperations_sparc32_sun_cc.h
Go to the documentation of this file.
1/// @file bsls_atomicoperations_sparc32_sun_cc.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bsls_atomicoperations_sparc32_sun_cc.h -*-C++-*-
8#ifndef INCLUDED_BSLS_ATOMICOPERATIONS_SPARC32_SUN_CC
9#define INCLUDED_BSLS_ATOMICOPERATIONS_SPARC32_SUN_CC
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bsls_atomicoperations_sparc32_sun_cc bsls_atomicoperations_sparc32_sun_cc
15/// @brief Provide implementations of atomic operations for Sparc/Sun (32bit).
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bsls
19/// @{
20/// @addtogroup bsls_atomicoperations_sparc32_sun_cc
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bsls_atomicoperations_sparc32_sun_cc-purpose"> Purpose</a>
25/// * <a href="#bsls_atomicoperations_sparc32_sun_cc-classes"> Classes </a>
26/// * <a href="#bsls_atomicoperations_sparc32_sun_cc-description"> Description </a>
27///
28/// # Purpose {#bsls_atomicoperations_sparc32_sun_cc-purpose}
29/// Provide implementations of atomic operations for Sparc/Sun (32bit).
30///
31/// # Classes {#bsls_atomicoperations_sparc32_sun_cc-classes}
32///
33/// - bsls::AtomicOperations_SPARC32_SUN_CC: atomics for Sparc32/Sun.
34///
35/// # Description {#bsls_atomicoperations_sparc32_sun_cc-description}
36/// This component provides classes necessary to implement atomics
37/// on the Sun Sparc platform in 32bit mode with SunCC compiler. The classes
38/// are for private use only. See @ref bsls_atomicoperations and @ref bsls_atomic for
39/// the public interface to atomics.
40/// @}
41/** @} */
42/** @} */
43
44/** @addtogroup bsl
45 * @{
46 */
47/** @addtogroup bsls
48 * @{
49 */
50/** @addtogroup bsls_atomicoperations_sparc32_sun_cc
51 * @{
52 */
53
54#include <bsls_atomicoperations_default.h>
56#include <bsls_platform.h>
57#include <bsls_types.h>
58
59#if defined(BSLS_PLATFORM_CPU_SPARC_32) \
60 && (defined(BSLS_PLATFORM_CMP_GNU) || defined(BSLS_PLATFORM_CMP_SUN))
61
62
63
64extern "C"
65{
66 // *** 64 bit operations ***
67
68 bsls::Types::Int64 bsls_AtomicOperations_Sparc32_GetInt64(
69 const volatile bsls::Types::Int64 *atomicInt);
70
71 bsls::Types::Int64 bsls_AtomicOperations_Sparc32_GetInt64Relaxed(
72 const volatile bsls::Types::Int64 *atomicInt);
73
74 void bsls_AtomicOperations_Sparc32_SetInt64(
75 volatile bsls::Types::Int64 *atomicInt, bsls::Types::Int64 value);
76
77 void bsls_AtomicOperations_Sparc32_SetInt64Relaxed(
78 volatile bsls::Types::Int64 *atomicInt, bsls::Types::Int64 value);
79
80 bsls::Types::Int64 bsls_AtomicOperations_Sparc32_SwapInt64(
81 volatile bsls::Types::Int64 *atomicInt,
82 bsls::Types::Int64 swapValue);
83
84 bsls::Types::Int64 bsls_AtomicOperations_Sparc32_SwapInt64AcqRel(
85 volatile bsls::Types::Int64 *atomicInt,
86 bsls::Types::Int64 swapValue);
87
88 bsls::Types::Int64 bsls_AtomicOperations_Sparc32_TestAndSwapInt64(
89 volatile bsls::Types::Int64 *atomicInt,
90 bsls::Types::Int64 compareValue,
91 bsls::Types::Int64 swapValue);
92
93 bsls::Types::Int64 bsls_AtomicOperations_Sparc32_TestAndSwapInt64AcqRel(
94 volatile bsls::Types::Int64 *atomicInt,
95 bsls::Types::Int64 compareValue,
96 bsls::Types::Int64 swapValue);
97
98 bsls::Types::Int64 bsls_AtomicOperations_Sparc32_AddInt64(
99 volatile bsls::Types::Int64 *atomicInt, bsls::Types::Int64 value);
100
101 bsls::Types::Int64 bsls_AtomicOperations_Sparc32_AddInt64Relaxed(
102 volatile bsls::Types::Int64 *atomicInt, bsls::Types::Int64 value);
103}
104
105namespace bsls {
106
107struct AtomicOperations_SPARC32_SUN_CC;
108typedef AtomicOperations_SPARC32_SUN_CC AtomicOperations_Imp;
109
110 // ==================================================
111 // Atomic_TypeTraits<AtomicOperations_SPARC32_SUN_CC>
112 // ==================================================
113
114template <>
115struct Atomic_TypeTraits<AtomicOperations_SPARC32_SUN_CC>
116{
117 struct Int
118 {
119#ifdef BSLS_PLATFORM_CMP_GNU
120 volatile int d_value __attribute__((__aligned__(sizeof(int))));
121#else
122# pragma align 4 (d_value)
123 volatile int d_value;
124#endif
125 };
126
127 struct Int64
128 {
129#ifdef BSLS_PLATFORM_CMP_GNU
130 volatile Types::Int64 d_value
131 __attribute__((__aligned__(sizeof(Types::Int64))));
132#else
133# pragma align 8 (d_value)
134 volatile Types::Int64 d_value;
135#endif
136 };
137
138 struct Uint
139 {
140#ifdef BSLS_PLATFORM_CMP_GNU
141 volatile unsigned int d_value
142 __attribute__((__aligned__(sizeof(unsigned int))));
143#else
144# pragma align 4 (d_value)
145 volatile unsigned int d_value;
146#endif
147 };
148
149 struct Uint64
150 {
151#ifdef BSLS_PLATFORM_CMP_GNU
152 volatile Types::Uint64 d_value
153 __attribute__((__aligned__(sizeof(Types::Uint64))));
154#else
155# pragma align 8 (d_value)
156 volatile Types::Uint64 d_value;
157#endif
158 };
159
160 struct Pointer
161 {
162#ifdef BSLS_PLATFORM_CMP_GNU
163 void * volatile d_value __attribute__((__aligned__(sizeof(void *))));
164#else
165# pragma align 4 (d_value)
166 void * volatile d_value;
167#endif
168 };
169};
170
171 // ======================================
172 // struct AtomicOperations_SPARC32_SUN_CC
173 // ======================================
174
175struct AtomicOperations_SPARC32_SUN_CC
176 : AtomicOperations_SPARC_SUN_CC_Default32<AtomicOperations_SPARC32_SUN_CC>
177{
178 typedef Atomic_TypeTraits<AtomicOperations_SPARC32_SUN_CC> AtomicTypes;
179
180 // *** atomic functions for Int64 ***
181
182 static Types::Int64 getInt64(const AtomicTypes::Int64 *atomicInt);
183
184 static Types::Int64 getInt64Relaxed(const AtomicTypes::Int64 *atomicInt);
185
186 static Types::Int64 getInt64Acquire(const AtomicTypes::Int64 *atomicInt);
187
188 static void setInt64(AtomicTypes::Int64 *atomicInt, Types::Int64 value);
189
190 static void setInt64Relaxed(AtomicTypes::Int64 *atomicInt,
191 Types::Int64 value);
192
193 static void setInt64Release(AtomicTypes::Int64 *atomicInt,
194 Types::Int64 value);
195
196 static Types::Int64 swapInt64(AtomicTypes::Int64 *atomicInt,
197 Types::Int64 swapValue);
198
199 static Types::Int64 swapInt64AcqRel(AtomicTypes::Int64 *atomicInt,
200 Types::Int64 swapValue);
201
202 static Types::Int64 testAndSwapInt64(AtomicTypes::Int64 *atomicInt,
203 Types::Int64 compareValue,
204 Types::Int64 swapValue);
205
206 static Types::Int64 testAndSwapInt64AcqRel(AtomicTypes::Int64 *atomicInt,
207 Types::Int64 compareValue,
208 Types::Int64 swapValue);
209
210 static Types::Int64 addInt64Nv(AtomicTypes::Int64 *atomicInt,
211 Types::Int64 value);
212
213 static Types::Int64 addInt64NvRelaxed(AtomicTypes::Int64 *atomicInt,
214 Types::Int64 value);
215
216 static Types::Int64 addInt64NvAcqRel(AtomicTypes::Int64 *atomicInt,
217 Types::Int64 value);
218};
219
220// ===========================================================================
221// INLINE FUNCTION DEFINITIONS
222// ===========================================================================
223
224 // --------------------------------------
225 // struct AtomicOperations_SPARC32_SUN_CC
226 // --------------------------------------
227
228inline
229Types::Int64 AtomicOperations_SPARC32_SUN_CC::
230 getInt64(const AtomicTypes::Int64 *atomicInt)
231{
232 return bsls_AtomicOperations_Sparc32_GetInt64(&atomicInt->d_value);
233}
234
235inline
236Types::Int64 AtomicOperations_SPARC32_SUN_CC::
237 getInt64Relaxed(const AtomicTypes::Int64 *atomicInt)
238{
239 return bsls_AtomicOperations_Sparc32_GetInt64Relaxed(&atomicInt->d_value);
240}
241
242inline
243Types::Int64 AtomicOperations_SPARC32_SUN_CC::
244 getInt64Acquire(const AtomicTypes::Int64 *atomicInt)
245{
246 return getInt64Relaxed(atomicInt);
247}
248
249inline
250void AtomicOperations_SPARC32_SUN_CC::
251 setInt64(AtomicTypes::Int64 *atomicInt, Types::Int64 value)
252{
253 bsls_AtomicOperations_Sparc32_SetInt64(&atomicInt->d_value, value);
254}
255
256inline
257void AtomicOperations_SPARC32_SUN_CC::
258 setInt64Relaxed(AtomicTypes::Int64 *atomicInt, Types::Int64 value)
259{
260 bsls_AtomicOperations_Sparc32_SetInt64Relaxed(&atomicInt->d_value, value);
261}
262
263inline
264void AtomicOperations_SPARC32_SUN_CC::
265 setInt64Release(AtomicTypes::Int64 *atomicInt, Types::Int64 value)
266{
267 setInt64Relaxed(atomicInt, value);
268}
269
270inline
271Types::Int64 AtomicOperations_SPARC32_SUN_CC::
272 swapInt64(AtomicTypes::Int64 *atomicInt,
273 Types::Int64 swapValue)
274{
275 return bsls_AtomicOperations_Sparc32_SwapInt64(&atomicInt->d_value,
276 swapValue);
277}
278
279inline
280Types::Int64 AtomicOperations_SPARC32_SUN_CC::
281 swapInt64AcqRel(AtomicTypes::Int64 *atomicInt,
282 Types::Int64 swapValue)
283{
284 return bsls_AtomicOperations_Sparc32_SwapInt64AcqRel(&atomicInt->d_value,
285 swapValue);
286}
287
288inline
289Types::Int64 AtomicOperations_SPARC32_SUN_CC::
290 testAndSwapInt64(AtomicTypes::Int64 *atomicInt,
291 Types::Int64 compareValue,
292 Types::Int64 swapValue)
293{
294 return bsls_AtomicOperations_Sparc32_TestAndSwapInt64(&atomicInt->d_value,
295 compareValue,
296 swapValue);
297}
298
299inline
300Types::Int64 AtomicOperations_SPARC32_SUN_CC::
301 testAndSwapInt64AcqRel(AtomicTypes::Int64 *atomicInt,
302 Types::Int64 compareValue,
303 Types::Int64 swapValue)
304{
305 return bsls_AtomicOperations_Sparc32_TestAndSwapInt64AcqRel(
306 &atomicInt->d_value,
307 compareValue,
308 swapValue);
309}
310
311inline
312Types::Int64 AtomicOperations_SPARC32_SUN_CC::
313 addInt64Nv(AtomicTypes::Int64 *atomicInt,
314 Types::Int64 value)
315{
316 return bsls_AtomicOperations_Sparc32_AddInt64(&atomicInt->d_value, value);
317}
318
319inline
320Types::Int64 AtomicOperations_SPARC32_SUN_CC::
321 addInt64NvRelaxed(AtomicTypes::Int64 *atomicInt,
322 Types::Int64 value)
323{
324 return bsls_AtomicOperations_Sparc32_AddInt64Relaxed(&atomicInt->d_value,
325 value);
326}
327
328inline
329Types::Int64 AtomicOperations_SPARC32_SUN_CC::
330 addInt64NvAcqRel(AtomicTypes::Int64 *atomicInt,
331 Types::Int64 value)
332{
333 return addInt64NvRelaxed(atomicInt, value);
334}
335
336} // close package namespace
337
338
339
340#endif // SPARC_32 && (GNU || SUN)
341
342#endif
343
344// ----------------------------------------------------------------------------
345// Copyright 2013 Bloomberg Finance L.P.
346//
347// Licensed under the Apache License, Version 2.0 (the "License");
348// you may not use this file except in compliance with the License.
349// You may obtain a copy of the License at
350//
351// http://www.apache.org/licenses/LICENSE-2.0
352//
353// Unless required by applicable law or agreed to in writing, software
354// distributed under the License is distributed on an "AS IS" BASIS,
355// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
356// See the License for the specific language governing permissions and
357// limitations under the License.
358// ----------------------------- END-OF-FILE ----------------------------------
359
360/** @} */
361/** @} */
362/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlt_iso8601util.h:691
long long Int64
Definition bsls_types.h:132