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