sysbench: use __atomic builtins to fix ppc32 to utilize libatomic
This commit is contained in:
parent
0a8c9fa6bc
commit
32d44c9dfe
1 changed files with 42 additions and 0 deletions
42
srcpkgs/sysbench/patches/atomics.patch
Normal file
42
srcpkgs/sysbench/patches/atomics.patch
Normal file
|
@ -0,0 +1,42 @@
|
|||
Use C11 style atomic builtins instead of the legacy __sync primitives
|
||||
|
||||
This is because unlike legacy __sync stuff, __atomic_* can make use of
|
||||
libatomic on any arbitrary platform, while on e.g. ppc32 and mips,
|
||||
__sync_val_compare_and_swap_8 and so on are not available at all.
|
||||
|
||||
--- src/sb_ck_pr.h
|
||||
+++ src/sb_ck_pr.h
|
||||
@@ -118,7 +118,8 @@ CK_PR_LOAD_S(64, uint64_t)
|
||||
ck_pr_cas_##S(M *target, T compare, T set) \
|
||||
{ \
|
||||
bool z; \
|
||||
- z = __sync_bool_compare_and_swap((T *)target, compare, set); \
|
||||
+ z = __atomic_compare_exchange((T *)target, &compare, &set, \
|
||||
+ false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \
|
||||
return z; \
|
||||
}
|
||||
|
||||
@@ -133,9 +134,11 @@ CK_PR_CAS_S(64, uint64_t)
|
||||
CK_CC_INLINE static bool \
|
||||
ck_pr_cas_##S##_value(T *target, T compare, T set, T *v) \
|
||||
{ \
|
||||
- set = __sync_val_compare_and_swap(target, compare, set);\
|
||||
- *v = set; \
|
||||
- return (set == compare); \
|
||||
+ bool z; \
|
||||
+ z = __atomic_compare_exchange(target, &compare, &set, false, \
|
||||
+ __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); \
|
||||
+ *v = compare; \
|
||||
+ return z; \
|
||||
}
|
||||
|
||||
CK_PR_CAS_O(64, uint64_t)
|
||||
@@ -149,7 +152,7 @@ CK_PR_CAS_O(64, uint64_t)
|
||||
CK_CC_INLINE static void \
|
||||
ck_pr_##K##_##S(M *target, T d) \
|
||||
{ \
|
||||
- d = __sync_fetch_and_##K((T *)target, d); \
|
||||
+ d = __atomic_fetch_##K((T *)target, d, __ATOMIC_SEQ_CST); \
|
||||
return; \
|
||||
}
|
||||
|
Loading…
Reference in a new issue