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