2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
6 * Copyright (c) 2017 Andrey Semashev
9 * \file atomic/detail/extra_ops_gcc_ppc.hpp
11 * This header contains implementation of the extra atomic operations for PowerPC.
14 #ifndef BOOST_ATOMIC_DETAIL_EXTRA_OPS_GCC_PPC_HPP_INCLUDED_
15 #define BOOST_ATOMIC_DETAIL_EXTRA_OPS_GCC_PPC_HPP_INCLUDED_
18 #include <boost/memory_order.hpp>
19 #include <boost/atomic/detail/config.hpp>
20 #include <boost/atomic/detail/storage_type.hpp>
21 #include <boost/atomic/detail/extra_operations_fwd.hpp>
22 #include <boost/atomic/detail/extra_ops_generic.hpp>
23 #include <boost/atomic/detail/ops_gcc_ppc_common.hpp>
24 #include <boost/atomic/capabilities.hpp>
26 #ifdef BOOST_HAS_PRAGMA_ONCE
34 #if defined(BOOST_ATOMIC_DETAIL_PPC_HAS_LBARX_STBCX)
36 template< typename Base, bool Signed >
37 struct extra_operations< Base, 1u, Signed > :
38 public generic_extra_operations< Base, 1u, Signed >
40 typedef generic_extra_operations< Base, 1u, Signed > base_type;
41 typedef typename base_type::storage_type storage_type;
43 static BOOST_FORCEINLINE storage_type fetch_negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
45 gcc_ppc_operations_base::fence_before(order);
46 storage_type original, tmp;
54 : "=&b" (original), "=&b" (tmp), "+Z" (storage)
56 : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC
58 gcc_ppc_operations_base::fence_after(order);
62 static BOOST_FORCEINLINE storage_type fetch_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
64 gcc_ppc_operations_base::fence_before(order);
65 storage_type original, tmp;
73 : "=&b" (original), "=&b" (tmp), "+Z" (storage)
75 : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC
77 gcc_ppc_operations_base::fence_after(order);
81 static BOOST_FORCEINLINE void opaque_negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
83 fetch_negate(storage, order);
86 static BOOST_FORCEINLINE void opaque_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
88 fetch_complement(storage, order);
92 #endif // defined(BOOST_ATOMIC_DETAIL_PPC_HAS_LBARX_STBCX)
94 #if defined(BOOST_ATOMIC_DETAIL_PPC_HAS_LHARX_STHCX)
96 template< typename Base, bool Signed >
97 struct extra_operations< Base, 2u, Signed > :
98 public generic_extra_operations< Base, 2u, Signed >
100 typedef generic_extra_operations< Base, 2u, Signed > base_type;
101 typedef typename base_type::storage_type storage_type;
103 static BOOST_FORCEINLINE storage_type fetch_negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
105 gcc_ppc_operations_base::fence_before(order);
106 storage_type original, tmp;
114 : "=&b" (original), "=&b" (tmp), "+Z" (storage)
116 : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC
118 gcc_ppc_operations_base::fence_after(order);
122 static BOOST_FORCEINLINE storage_type fetch_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
124 gcc_ppc_operations_base::fence_before(order);
125 storage_type original, tmp;
133 : "=&b" (original), "=&b" (tmp), "+Z" (storage)
135 : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC
137 gcc_ppc_operations_base::fence_after(order);
141 static BOOST_FORCEINLINE void opaque_negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
143 fetch_negate(storage, order);
146 static BOOST_FORCEINLINE void opaque_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
148 fetch_complement(storage, order);
152 #endif // defined(BOOST_ATOMIC_DETAIL_PPC_HAS_LHARX_STHCX)
154 template< typename Base, bool Signed >
155 struct extra_operations< Base, 4u, Signed > :
156 public generic_extra_operations< Base, 4u, Signed >
158 typedef generic_extra_operations< Base, 4u, Signed > base_type;
159 typedef typename base_type::storage_type storage_type;
161 static BOOST_FORCEINLINE storage_type fetch_negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
163 gcc_ppc_operations_base::fence_before(order);
164 storage_type original, tmp;
172 : "=&b" (original), "=&b" (tmp), "+Z" (storage)
174 : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC
176 gcc_ppc_operations_base::fence_after(order);
180 static BOOST_FORCEINLINE storage_type fetch_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
182 gcc_ppc_operations_base::fence_before(order);
183 storage_type original, tmp;
191 : "=&b" (original), "=&b" (tmp), "+Z" (storage)
193 : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC
195 gcc_ppc_operations_base::fence_after(order);
199 static BOOST_FORCEINLINE void opaque_negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
201 fetch_negate(storage, order);
204 static BOOST_FORCEINLINE void opaque_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
206 fetch_complement(storage, order);
210 #if defined(BOOST_ATOMIC_DETAIL_PPC_HAS_LDARX_STDCX)
212 template< typename Base, bool Signed >
213 struct extra_operations< Base, 8u, Signed > :
214 public generic_extra_operations< Base, 8u, Signed >
216 typedef generic_extra_operations< Base, 8u, Signed > base_type;
217 typedef typename base_type::storage_type storage_type;
219 static BOOST_FORCEINLINE storage_type fetch_negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
221 gcc_ppc_operations_base::fence_before(order);
222 storage_type original, tmp;
230 : "=&b" (original), "=&b" (tmp), "+Z" (storage)
232 : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC
234 gcc_ppc_operations_base::fence_after(order);
238 static BOOST_FORCEINLINE storage_type fetch_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
240 gcc_ppc_operations_base::fence_before(order);
241 storage_type original, tmp;
249 : "=&b" (original), "=&b" (tmp), "+Z" (storage)
251 : BOOST_ATOMIC_DETAIL_ASM_CLOBBER_CC
253 gcc_ppc_operations_base::fence_after(order);
257 static BOOST_FORCEINLINE void opaque_negate(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
259 fetch_negate(storage, order);
262 static BOOST_FORCEINLINE void opaque_complement(storage_type volatile& storage, memory_order order) BOOST_NOEXCEPT
264 fetch_complement(storage, order);
268 #endif // defined(BOOST_ATOMIC_DETAIL_PPC_HAS_LDARX_STDCX)
270 } // namespace detail
271 } // namespace atomics
274 #endif // BOOST_ATOMIC_DETAIL_EXTRA_OPS_GCC_ARM_PPC_INCLUDED_