23 #ifndef STM_COMMON_PLATFORM_ICC_FIXES_HPP
24 #define STM_COMMON_PLATFORM_ICC_FIXES_HPP
28 # error "icc-sync.hpp included incorrectly"
45 #define __sync_synchronize() \
46 asm volatile("mfence":::"memory")
48 #define __sync_bool_compare_and_swap(p, f, t) \
49 stm::iccsync::bool_compare_and_swap(p, f, t)
51 #define __sync_val_compare_and_swap(p, f, t) \
52 stm::iccsync::val_compare_and_swap(p, f, t)
54 #define __sync_lock_test_and_set(p, v) \
55 stm::iccsync::lock_test_and_set(p, v)
57 #define __sync_fetch_and_add(p, a) \
58 stm::iccsync::fetch_and_add(p, a)
81 size_t W =
sizeof(
void*),
88 template <
typename T,
size_t W>
91 static T
swap(
volatile T* address, T value)
93 asm volatile(
"lock xchgb %[value], %[address]"
94 : [value]
"+q" (value),
95 [address]
"+m" (*address)
106 template <
typename T,
size_t W>
112 template <
typename T,
size_t W>
115 static T
swap(
volatile T* address, T value)
117 asm volatile(
"lock xchgl %[value], %[address]"
118 : [value]
"+r" (value),
119 [address]
"+m" (*address)
126 static T
cas(
volatile T* addr, T from, T to)
128 asm volatile(
"lock cmpxchgl %[to], %[addr]"
137 static bool bcas(
volatile T* addr, T from, T to)
140 asm volatile(
"lock cmpxchgl %[to], %[addr]\n\t"
142 : [result]
"=q" (result),
154 template <
typename T>
159 static T
swap(
volatile T* address, T value)
165 while (!bcas(address, mem, value))
181 static bool bcas(
volatile T* addr, T from, T to)
190 asm volatile(
"xchgl %%ebx, %[to_low]\n\t"
191 "lock cmpxchg8b\t%[addr]\n\t"
192 "movl %[to_low], %%ebx\n\t"
195 [result]
"=q" (result),
197 : [to_high]
"c" (cast.to[1]),
198 [to_low]
"g" (cast.to[0])
201 asm volatile(
"lock cmpxchg8b %[addr]\n\t"
204 [result]
"=q" (result),
217 template <
typename T>
220 static T
swap(
volatile T* address, T value)
222 asm volatile(
"lock xchgq %[value], %[address]"
223 : [value]
"+r" (value),
224 [address]
"+m" (*address)
231 static T
cas(
volatile T* addr, T from, T to)
233 asm volatile(
"lock cmpxchgq %[to], %[addr]"
241 static bool bcas(
volatile T* addr, T from, T to)
244 asm volatile(
"lock cmpxchgq %[to], %[addr]\n\t"
246 : [result]
"=q" (result),
259 template <
typename T>
275 template <
typename T,
typename S,
size_t D =
sizeof(T) /
sizeof(S)>
278 static T
cas(
volatile T* address, S from, S to)
284 static bool bcas(
volatile T* address, S from, S to)
292 template <
typename T>
295 static T
cas(
volatile T* address, T from, T to)
300 static bool bcas(
volatile T* address, T from, T to)
312 template <
typename T,
typename S>
320 template <
typename T,
typename S,
size_t D =
sizeof(T) /
sizeof(S)>
323 static T
swap(
volatile T* address, S value)
330 template <
typename T>
333 static T
swap(
volatile T* address, T value)
343 template <
typename T,
typename S>
346 static T
swap(
volatile T* address, S value)
356 template <
typename T,
typename S>
359 static T
swap(
volatile T* address, S value)
369 template <
typename T,
typename S>
379 template <
typename T,
typename S>
389 template <
typename T,
typename S>
400 template <
typename T,
typename S>
412 #endif // STM_COMMON_PLATFORM_ICC_FIXES_HPP
static bool bcas(volatile T *addr, T from, T to)
Definition: icc-sync.hpp:137
static T swap(volatile T *address, T value)
Definition: icc-sync.hpp:220
Definition: icc-sync.hpp:83
Definition: stm_fraser.c:61
static bool bcas(volatile T *address, S from, S to)
Definition: icc-sync.hpp:284
static T swap(volatile T *address, S value)
Definition: icc-sync.hpp:359
static T cas(volatile T *address, T from, T to)
Definition: icc-sync.hpp:295
static bool bcas(volatile T *addr, T from, T to)
Definition: icc-sync.hpp:181
static bool bcas(volatile T *addr, T from, T to)
Definition: icc-sync.hpp:241
static bool bcas(volatile T *address, T from, T to)
Definition: icc-sync.hpp:300
#define N
Definition: mt19937ar.h:135
static T swap(volatile T *address, T value)
Definition: icc-sync.hpp:159
static T swap(volatile T *address, T value)
Definition: icc-sync.hpp:115
static T cas(volatile T *addr, T from, T to)
Definition: icc-sync.hpp:126
Definition: icc-sync.hpp:321
static T swap(volatile T *address, S value)
Definition: icc-sync.hpp:323
static T cas(volatile T *address, S from, S to)
Definition: icc-sync.hpp:278
T lock_test_and_set(volatile T *address, S value)
Definition: icc-sync.hpp:370
static T cas(volatile T *addr, T from, T to)
Definition: icc-sync.hpp:231
T val_compare_and_swap(volatile T *address, S from, S to)
Definition: icc-sync.hpp:390
static T swap(volatile T *address, S value)
Definition: icc-sync.hpp:346
bool bool_compare_and_swap(volatile T *address, S from, S to)
Definition: icc-sync.hpp:380
static T swap(volatile T *address, T value)
Definition: icc-sync.hpp:333
static void swap(char *a, char *b, unsigned width)
Definition: sort.c:112
Definition: icc-sync.hpp:276
static T swap(volatile T *address, T value)
Definition: icc-sync.hpp:91
T fetch_and_add(volatile T *address, S value)
Definition: icc-sync.hpp:401