Go to the documentation of this file. 1 #ifndef BOOST_DETAIL_ATOMIC_GCC_X86_HPP
2 #define BOOST_DETAIL_ATOMIC_GCC_X86_HPP
10 #define BOOST_ATOMIC_CHAR_LOCK_FREE 2
11 #define BOOST_ATOMIC_CHAR16_T_LOCK_FREE 2
12 #define BOOST_ATOMIC_CHAR32_T_LOCK_FREE 2
13 #define BOOST_ATOMIC_WCHAR_T_LOCK_FREE 2
14 #define BOOST_ATOMIC_SHORT_LOCK_FREE 2
15 #define BOOST_ATOMIC_INT_LOCK_FREE 2
16 #define BOOST_ATOMIC_LONG_LOCK_FREE 2
18 #if defined(__x86_64__)
19 #define BOOST_ATOMIC_LLONG_LOCK_FREE 2
21 #define BOOST_ATOMIC_LLONG_LOCK_FREE 1
24 #define BOOST_ATOMIC_ADDRESS_LOCK_FREE 2
25 #define BOOST_ATOMIC_BOOL_LOCK_FREE 2
29 #if defined(__x86_64__)
30 # define BOOST_ATOMIC_X86_FENCE_INSTR "mfence\n"
32 # define BOOST_ATOMIC_X86_FENCE_INSTR "lock ; addl $0, (%%esp)\n"
35 #define BOOST_ATOMIC_THREAD_FENCE 2
43 __asm__ __volatile__ (
"" :::
"memory");
46 __asm__ __volatile__ (
"" :::
"memory");
49 __asm__ __volatile__ (
"" :::
"memory");
60 #define BOOST_ATOMIC_SIGNAL_FENCE 2
64 __asm__ __volatile__ (
"" :::
"memory");
80 __asm__ __volatile__ (
"" :::
"memory");
84 __asm__ __volatile__ (
"" :::
"memory");
99 __asm__ __volatile__ (
"" :::
"memory");
106 __asm__ __volatile__ (
"" :::
"memory");
122 __asm__ __volatile__ (
"" :::
"memory");
133 template<
typename T,
bool Sign>
134 class base_atomic<T, int, 1, Sign> {
166 "lock ; xaddb %0, %1"
167 :
"+q" (v),
"+m" (
v_)
176 return fetch_add(-v, order);
185 :
"+q" (v),
"+m" (
v_)
201 "lock ; cmpxchgb %2, %1"
202 :
"+a" (previous),
"+m" (
v_)
205 bool success = (previous == expected);
261 template<
typename T,
bool Sign>
294 "lock ; xaddw %0, %1"
295 :
"+q" (v),
"+m" (
v_)
304 return fetch_add(-v, order);
313 :
"+q" (v),
"+m" (
v_)
329 "lock ; cmpxchgw %2, %1"
330 :
"+a" (previous),
"+m" (
v_)
333 bool success = (previous == expected);
389 template<
typename T,
bool Sign>
422 "lock ; xaddl %0, %1"
423 :
"+r" (v),
"+m" (
v_)
432 return fetch_add(-v, order);
441 :
"+r" (v),
"+m" (
v_)
457 "lock ; cmpxchgl %2, %1"
458 :
"+a" (previous),
"+m" (
v_)
461 bool success = (previous == expected);
517 #if defined(__x86_64__)
518 template<
typename T,
bool Sign>
519 class base_atomic<T, int, 8, Sign> {
522 typedef T difference_type;
551 "lock ; xaddq %0, %1"
552 :
"+r" (v),
"+m" (
v_)
561 return fetch_add(-v, order);
570 :
"+r" (v),
"+m" (
v_)
586 "lock ; cmpxchgq %2, %1"
587 :
"+a" (previous),
"+m" (
v_)
590 bool success = (previous == expected);
650 #if !defined(__x86_64__)
653 class base_atomic<void *,
void *, 4, Sign> {
683 :
"+r" (v),
"+m" (v_)
696 "lock ; cmpxchgl %2, %1"
697 :
"+a" (previous),
"+m" (v_)
700 bool success = (previous == expected);
713 return compare_exchange_strong(expected, desired, success_order, failure_order);
729 template<
typename T,
bool Sign>
730 class base_atomic<T *,
void *, 4, Sign> {
763 :
"+r" (v),
"+m" (v_)
779 "lock ; cmpxchgl %2, %1"
780 :
"+a" (previous),
"+m" (v_)
783 bool success = (previous == expected);
799 return compare_exchange_strong(expected, desired, success_order, failure_order);
808 "lock ; xaddl %0, %1"
809 :
"+r" (v),
"+m" (v_)
818 return fetch_add(-v, order);
837 class base_atomic<void *,
void *, 8, Sign> {
838 typedef base_atomic this_type;
839 typedef void * value_type;
841 explicit base_atomic(value_type v) : v_(v) {}
849 const_cast<volatile value_type &
>(v_) = v;
857 value_type v =
const_cast<const volatile value_type &
>(v_);
867 :
"+r" (v),
"+m" (v_)
873 bool compare_exchange_strong(value_type & expected, value_type desired,
877 value_type previous = expected;
880 "lock ; cmpxchgq %2, %1"
881 :
"+a" (previous),
"+m" (v_)
884 bool success = (previous == expected);
893 bool compare_exchange_weak(value_type & expected, value_type desired,
897 return compare_exchange_strong(expected, desired, success_order, failure_order);
901 is_lock_free(
void)
const volatile
908 base_atomic(
const base_atomic &) ;
909 void operator=(
const base_atomic &) ;
913 template<
typename T,
bool Sign>
914 class base_atomic<T *,
void *, 8, Sign> {
915 typedef base_atomic this_type;
916 typedef T * value_type;
917 typedef ptrdiff_t difference_type;
919 explicit base_atomic(value_type v) : v_(v) {}
927 const_cast<volatile value_type &
>(v_) = v;
936 value_type v =
const_cast<const volatile value_type &
>(v_);
947 :
"+r" (v),
"+m" (v_)
954 compare_exchange_strong(
955 value_type & expected,
960 value_type previous = expected;
963 "lock ; cmpxchgq %2, %1"
964 :
"+a" (previous),
"+m" (v_)
967 bool success = (previous == expected);
977 compare_exchange_weak(
978 value_type & expected,
983 return compare_exchange_strong(expected, desired, success_order, failure_order);
992 "lock ; xaddq %0, %1"
993 :
"+r" (v),
"+m" (v_)
996 return reinterpret_cast<value_type
>(v);
1002 return fetch_add(-v, order);
1006 is_lock_free(
void)
const volatile
1013 base_atomic(
const base_atomic &) ;
1014 void operator=(
const base_atomic &) ;
1020 template<
typename T,
bool Sign>
1021 class base_atomic<T, void, 1, Sign> {
1063 :
"+q" (tmp),
"+m" (
v_)
1078 memcpy(&expected_s, &expected,
sizeof(
value_type));
1079 memcpy(&desired_s, &desired,
sizeof(
value_type));
1083 "lock ; cmpxchgb %2, %1"
1084 :
"+a" (previous_s),
"+m" (
v_)
1087 bool success = (previous_s == expected_s);
1092 memcpy(&expected, &previous_s,
sizeof(
value_type));
1119 template<
typename T,
bool Sign>
1120 class base_atomic<T, void, 2, Sign> {
1162 :
"+q" (tmp),
"+m" (
v_)
1177 memcpy(&expected_s, &expected,
sizeof(
value_type));
1178 memcpy(&desired_s, &desired,
sizeof(
value_type));
1182 "lock ; cmpxchgw %2, %1"
1183 :
"+a" (previous_s),
"+m" (
v_)
1186 bool success = (previous_s == expected_s);
1191 memcpy(&expected, &previous_s,
sizeof(
value_type));
1218 template<
typename T,
bool Sign>
1219 class base_atomic<T, void, 4, Sign> {
1261 :
"+q" (tmp),
"+m" (
v_)
1276 memcpy(&expected_s, &expected,
sizeof(
value_type));
1277 memcpy(&desired_s, &desired,
sizeof(
value_type));
1281 "lock ; cmpxchgl %2, %1"
1282 :
"+a" (previous_s),
"+m" (
v_)
1285 bool success = (previous_s == expected_s);
1290 memcpy(&expected, &previous_s,
sizeof(
value_type));
1317 #if defined(__x86_64__)
1318 template<
typename T,
bool Sign>
1319 class base_atomic<T, void, 8, Sign> {
1322 typedef uint64_t storage_type;
1337 const_cast<volatile storage_type &
>(
v_) = tmp;
1346 storage_type tmp =
const_cast<volatile storage_type &
>(
v_);
1361 :
"+q" (tmp),
"+m" (
v_)
1375 storage_type expected_s, desired_s;
1376 memcpy(&expected_s, &expected,
sizeof(
value_type));
1377 memcpy(&desired_s, &desired,
sizeof(
value_type));
1378 storage_type previous_s = expected_s;
1381 "lock ; cmpxchgq %2, %1"
1382 :
"+a" (previous_s),
"+m" (
v_)
1385 bool success = (previous_s == expected_s);
1390 memcpy(&expected, &previous_s,
sizeof(
value_type));
1418 #if defined(__i686__)
1420 template<
typename T>
1422 platform_cmpxchg64_strong(T & expected, T desired,
volatile T * ptr)
1440 __asm__ __volatile__ (
1443 "lock; cmpxchg8b 0(%4)\n"
1445 :
"=A" (prev),
"=m" (scratch)
1446 :
"D" ((
int)desired),
"c" ((
int)(desired >> 32)),
"S" (ptr),
"0" (prev)
1448 bool success = (prev == expected);
1460 #if defined(__i686__)
bool is_lock_free(void) const volatile
void store(value_type v, memory_order order=memory_order_seq_cst) volatile
static void platform_fence_before(memory_order order)
base_atomic(value_type v)
bool compare_exchange_strong(value_type &expected, value_type desired, memory_order, memory_order) volatile
bool compare_exchange_strong(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
bool is_lock_free(void) const volatile
static void atomic_signal_fence(memory_order)
bool is_lock_free(void) const volatile
bool is_lock_free(void) const volatile
base_atomic(value_type v)
value_type load(memory_order order=memory_order_seq_cst) const volatile
value_type load(memory_order order=memory_order_seq_cst) const volatile
value_type exchange(value_type v, memory_order order=memory_order_seq_cst) volatile
#define BOOST_ATOMIC_DECLARE_BASE_OPERATORS
bool compare_exchange_weak(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
value_type fetch_xor(value_type v, memory_order order=memory_order_seq_cst) volatile
void store(value_type v, memory_order order=memory_order_seq_cst) volatile
value_type exchange(value_type v, memory_order order=memory_order_seq_cst) volatile
value_type fetch_sub(value_type v, memory_order order=memory_order_seq_cst) volatile
bool is_lock_free(void) const volatile
bool compare_exchange_strong(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
base_atomic(value_type v)
bool compare_exchange_strong(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
bool compare_exchange_weak(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
value_type fetch_and(value_type v, memory_order order=memory_order_seq_cst) volatile
base_atomic(value_type v)
value_type fetch_add(difference_type v, memory_order order=memory_order_seq_cst) volatile
bool compare_exchange_strong(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
bool is_lock_free(void) const volatile
value_type fetch_add(value_type v, memory_order order=memory_order_seq_cst) volatile
void operator=(const base_atomic &)
base_atomic(value_type v)
value_type load(memory_order order=memory_order_seq_cst) const volatile
void store(value_type v, memory_order order=memory_order_seq_cst) volatile
void store(value_type v, memory_order=memory_order_seq_cst) volatile
bool compare_exchange_strong(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
value_type exchange(value_type v, memory_order order=memory_order_seq_cst) volatile
bool compare_exchange_weak(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
bool compare_exchange_strong(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
value_type load(memory_order order=memory_order_seq_cst) const volatile
void store(value_type v, memory_order order=memory_order_seq_cst) volatile
value_type load(memory_order order=memory_order_seq_cst) const volatile
value_type load(memory_order order=memory_order_seq_cst) const volatile
#define BOOST_ATOMIC_DECLARE_INTEGRAL_OPERATORS
value_type exchange(value_type v, memory_order order=memory_order_seq_cst) volatile
bool is_lock_free(void) const volatile
value_type exchange(value_type v, memory_order=memory_order_seq_cst) volatile
ptrdiff_t difference_type
value_type fetch_and(value_type v, memory_order order=memory_order_seq_cst) volatile
bool compare_exchange_strong(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
value_type fetch_sub(value_type v, memory_order order=memory_order_seq_cst) volatile
#define BOOST_ATOMIC_X86_FENCE_INSTR
void store(value_type v, memory_order order=memory_order_seq_cst) volatile
bool compare_exchange_strong(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
base_atomic(value_type v)
static void platform_fence_after_load(memory_order order)
value_type fetch_or(value_type v, memory_order order=memory_order_seq_cst) volatile
value_type load(memory_order=memory_order_seq_cst) volatile const
base_atomic(value_type v)
#define BOOST_ATOMIC_DECLARE_POINTER_OPERATORS
value_type exchange(value_type v, memory_order order=memory_order_seq_cst) volatile
value_type fetch_or(value_type v, memory_order order=memory_order_seq_cst) volatile
bool compare_exchange_weak(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
bool compare_exchange_weak(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
bool compare_exchange_weak(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
static void platform_fence_after(memory_order order)
bool is_lock_free(void) const volatile
value_type fetch_add(value_type v, memory_order order=memory_order_seq_cst) volatile
bool compare_exchange_weak(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
value_type exchange(value_type v, memory_order order=memory_order_seq_cst) volatile
value_type exchange(value_type v, memory_order order=memory_order_seq_cst) volatile
value_type fetch_sub(difference_type v, memory_order order=memory_order_seq_cst) volatile
value_type load(memory_order order=memory_order_seq_cst) const volatile
void store(value_type v, memory_order order=memory_order_seq_cst) volatile
bool compare_exchange_weak(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
bool compare_exchange_weak(value_type &expected, value_type desired, memory_order success_order, memory_order failure_order) volatile
value_type exchange(value_type v, memory_order order=memory_order_seq_cst) volatile
bool is_lock_free(void) const volatile
void store(value_type v, memory_order order=memory_order_seq_cst) volatile
value_type fetch_add(value_type v, memory_order order=memory_order_seq_cst) volatile
value_type fetch_xor(value_type v, memory_order order=memory_order_seq_cst) volatile
value_type fetch_sub(value_type v, memory_order order=memory_order_seq_cst) volatile
static void atomic_thread_fence(memory_order order)
void store(value_type v, memory_order order=memory_order_seq_cst) volatile
value_type fetch_and(value_type v, memory_order order=memory_order_seq_cst) volatile
base_atomic(value_type v)
value_type fetch_xor(value_type v, memory_order order=memory_order_seq_cst) volatile
value_type load(memory_order order=memory_order_seq_cst) const volatile
value_type fetch_or(value_type v, memory_order order=memory_order_seq_cst) volatile
rosatomic
Author(s): Josh Faust
autogenerated on Wed Mar 2 2022 00:54:12