BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bsls_atomicoperations_powerpc_aix_xlc_default.h
Go to the documentation of this file.
1/// @file bsls_atomicoperations_powerpc_aix_xlc_default.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bsls_atomicoperations_powerpc_aix_xlc_default.h -*-C++-*-
8#ifndef INCLUDED_BSLS_ATOMICOPERATIONS_POWERPC_AIX_XLC_DEFAULT
9#define INCLUDED_BSLS_ATOMICOPERATIONS_POWERPC_AIX_XLC_DEFAULT
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bsls_atomicoperations_powerpc_aix_xlc_default bsls_atomicoperations_powerpc_aix_xlc_default
15/// @brief Provide default base implementations of atomics for PowerPC/AIX.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bsls
19/// @{
20/// @addtogroup bsls_atomicoperations_powerpc_aix_xlc_default
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bsls_atomicoperations_powerpc_aix_xlc_default-purpose"> Purpose</a>
25/// * <a href="#bsls_atomicoperations_powerpc_aix_xlc_default-classes"> Classes </a>
26/// * <a href="#bsls_atomicoperations_powerpc_aix_xlc_default-description"> Description </a>
27///
28/// # Purpose {#bsls_atomicoperations_powerpc_aix_xlc_default-purpose}
29/// Provide default base implementations of atomics for PowerPC/AIX.
30///
31/// # Classes {#bsls_atomicoperations_powerpc_aix_xlc_default-classes}
32///
33/// - bsls::AtomicOperations_POWERPC_AIX_XLC_Default32: default base for 32bit.
34/// - bsls::AtomicOperations_POWERPC_AIX_XLC_Default64: default base for 64bit.
35///
36/// # Description {#bsls_atomicoperations_powerpc_aix_xlc_default-description}
37/// This component provides default base classes necessary to
38/// implement atomics on the AIX PowerPC platform with the xlC compiler. The
39/// classes are for private use only. See @ref bsls_atomicoperations and
40/// @ref bsls_atomic for the public interface to atomics.
41/// @}
42/** @} */
43/** @} */
44
45/** @addtogroup bsl
46 * @{
47 */
48/** @addtogroup bsls
49 * @{
50 */
51/** @addtogroup bsls_atomicoperations_powerpc_aix_xlc_default
52 * @{
53 */
54
55#include <bsls_atomicoperations_default.h>
56#include <bsls_platform.h>
57#include <bsls_types.h>
58
59#if defined(BSLS_PLATFORM_CPU_POWERPC) && defined(BSLS_PLATFORM_CMP_IBM)
60#include <builtins.h>
61
62
63
64namespace bsls {
65
66 // *** functions implemented in assembly for both 32bit and 64bit ***
67
68int AtomicOperations_Powerpc_GetInt(const volatile int *atomicInt);
69int AtomicOperations_Powerpc_GetIntAcquire(const volatile int *atomicInt);
70void AtomicOperations_Powerpc_SetInt(volatile int *atomicInt, int value);
71void AtomicOperations_Powerpc_SetIntRelease(volatile int *atomicInt,
72 int value);
73int AtomicOperations_Powerpc_SwapInt(volatile int *atomicInt,
74 int swapValue);
75int AtomicOperations_Powerpc_SwapIntAcqRel(volatile int *atomicInt,
76 int swapValue);
77int AtomicOperations_Powerpc_TestAndSwapInt(volatile int *atomicInt,
78 int compareValue,
79 int swapValue);
80int AtomicOperations_Powerpc_TestAndSwapIntAcqRel(volatile int *atomicInt,
81 int compareValue,
82 int swapValue);
83int AtomicOperations_Powerpc_AddInt(volatile int *atomicInt, int value);
84int AtomicOperations_Powerpc_AddIntAcqRel(volatile int *atomicInt,
85 int value);
86
87 // ==================================================
88 // struct AtomicOperations_POWERPC_AIX_XLC_DefaultInt
89 // ==================================================
90
91template <typename IMP>
92struct AtomicOperations_POWERPC_AIX_XLC_DefaultInt
93 : AtomicOperations_DefaultInt<IMP>
94{
95 typedef Atomic_TypeTraits<IMP> AtomicTypes;
96
97 // *** atomic functions for int ***
98
99 static int getInt(typename AtomicTypes::Int const *atomicInt);
100
101 static int getIntAcquire(typename AtomicTypes::Int const *atomicInt);
102
103 static void setInt(typename AtomicTypes::Int *atomicInt, int value);
104
105 static void setIntRelease(typename AtomicTypes::Int *atomicInt, int value);
106
107 static int swapInt(typename AtomicTypes::Int *atomicInt, int swapValue);
108
109 static int swapIntAcqRel(typename AtomicTypes::Int *atomicInt, int swapValue);
110
111 static int testAndSwapInt(typename AtomicTypes::Int *atomicInt,
112 int compareValue,
113 int swapValue);
114
115 static int testAndSwapIntAcqRel(typename AtomicTypes::Int *atomicInt,
116 int compareValue,
117 int swapValue);
118
119 static int addIntNv(typename AtomicTypes::Int *atomicInt, int value);
120
121 static int addIntNvRelaxed(typename AtomicTypes::Int *atomicInt, int value);
122
123 static int addIntNvAcqRel(typename AtomicTypes::Int *atomicInt, int value);
124};
125
126 // =================================================
127 // struct AtomicOperations_POWERPC_AIX_XLC_Default32
128 // =================================================
129
130template <typename IMP>
131struct AtomicOperations_POWERPC_AIX_XLC_Default32
132 : AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>
133 , AtomicOperations_DefaultInt64<IMP>
134 , AtomicOperations_DefaultUint<IMP>
135 , AtomicOperations_DefaultUint64<IMP>
136 , AtomicOperations_DefaultPointer32<IMP>
137{};
138
139 // =================================================
140 // struct AtomicOperations_POWERPC_AIX_XLC_Default64
141 // =================================================
142
143template <typename IMP>
144struct AtomicOperations_POWERPC_AIX_XLC_Default64
145 : AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>
146 , AtomicOperations_DefaultInt64<IMP>
147 , AtomicOperations_DefaultUint<IMP>
148 , AtomicOperations_DefaultUint64<IMP>
149 , AtomicOperations_DefaultPointer64<IMP>
150{};
151
152// ===========================================================================
153// INLINE FUNCTION DEFINITIONS
154// ===========================================================================
155
156 // --------------------------------------------------
157 // struct AtomicOperations_POWERPC_AIX_XLC_DefaultInt
158 // --------------------------------------------------
159
160template <typename IMP>
161inline
162int AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>::
163 getInt(typename AtomicTypes::Int const *atomicInt)
164{
165 return AtomicOperations_Powerpc_GetInt(&atomicInt->d_value);
166}
167
168template <typename IMP>
169inline
170int AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>::
171 getIntAcquire(typename AtomicTypes::Int const *atomicInt)
172{
173 return AtomicOperations_Powerpc_GetIntAcquire(&atomicInt->d_value);
174}
175
176template <typename IMP>
177inline
178void AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>::
179 setInt(typename AtomicTypes::Int *atomicInt, int value)
180{
181 AtomicOperations_Powerpc_SetInt(&atomicInt->d_value, value);
182}
183
184template <typename IMP>
185inline
186void AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>::
187 setIntRelease(typename AtomicTypes::Int *atomicInt, int value)
188{
189 AtomicOperations_Powerpc_SetIntRelease(&atomicInt->d_value, value);
190}
191
192template <typename IMP>
193inline
194int AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>::
195 swapInt(typename AtomicTypes::Int *atomicInt, int swapValue)
196{
197 return AtomicOperations_Powerpc_SwapInt(&atomicInt->d_value,
198 swapValue);
199}
200
201template <typename IMP>
202inline
203int AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>::
204 swapIntAcqRel(typename AtomicTypes::Int *atomicInt, int swapValue)
205{
206 return AtomicOperations_Powerpc_SwapIntAcqRel(&atomicInt->d_value,
207 swapValue);
208}
209
210template <typename IMP>
211inline
212int AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>::
213 testAndSwapInt(typename AtomicTypes::Int *atomicInt,
214 int compareValue,
215 int swapValue)
216{
217 return AtomicOperations_Powerpc_TestAndSwapInt(&atomicInt->d_value,
218 compareValue,
219 swapValue);
220}
221
222template <typename IMP>
223inline
224int AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>::
225 testAndSwapIntAcqRel(typename AtomicTypes::Int *atomicInt,
226 int compareValue,
227 int swapValue)
228{
229 return AtomicOperations_Powerpc_TestAndSwapIntAcqRel(
230 &atomicInt->d_value,
231 compareValue,
232 swapValue);
233}
234
235template <typename IMP>
236inline
237int AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>::
238 addIntNv(typename AtomicTypes::Int *atomicInt, int value)
239{
240 return AtomicOperations_Powerpc_AddInt(&atomicInt->d_value, value);
241}
242
243template <typename IMP>
244inline
245int AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>::
246 addIntNvRelaxed(typename AtomicTypes::Int *atomicInt, int value)
247{
248 return __fetch_and_add(&atomicInt->d_value, value) + value;
249}
250
251template <typename IMP>
252inline
253int AtomicOperations_POWERPC_AIX_XLC_DefaultInt<IMP>::
254 addIntNvAcqRel(typename AtomicTypes::Int *atomicInt, int value)
255{
256 return AtomicOperations_Powerpc_AddIntAcqRel(&atomicInt->d_value,
257 value);
258}
259
260} // close package namespace
261
262
263
264#endif
265
266#endif
267
268// ----------------------------------------------------------------------------
269// Copyright 2013 Bloomberg Finance L.P.
270//
271// Licensed under the Apache License, Version 2.0 (the "License");
272// you may not use this file except in compliance with the License.
273// You may obtain a copy of the License at
274//
275// http://www.apache.org/licenses/LICENSE-2.0
276//
277// Unless required by applicable law or agreed to in writing, software
278// distributed under the License is distributed on an "AS IS" BASIS,
279// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
280// See the License for the specific language governing permissions and
281// limitations under the License.
282// ----------------------------- END-OF-FILE ----------------------------------
283
284/** @} */
285/** @} */
286/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
Definition bdlt_iso8601util.h:691