1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
From 114c42fba3fc86119710e8dd1bb2b7a9e39e3064 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Thu, 17 Jun 2021 19:35:01 -0700
Subject: [PATCH] replace old sync with new atomic builtin equivalents
Helps compiling with gcc on newer arches e.g. riscv32 where these
__sync* builtins are not implemented atleast for 64bit values
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Upstream-Status: Pending
.../range/range_tree/lib/portability/toku_atomic.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
--- a/utilities/transactions/lock/range/range_tree/lib/portability/toku_atomic.h
+++ b/utilities/transactions/lock/range/range_tree/lib/portability/toku_atomic.h
@@ -77,37 +77,37 @@ template <typename T, typename U>
__attribute__((always_inline)) static inline T toku_sync_fetch_and_add(T *addr,
U diff) {
paranoid_invariant(!crosses_boundary(addr, sizeof *addr));
- return __sync_fetch_and_add(addr, diff);
+ return __atomic_fetch_add(addr, diff, 5);
}
template <typename T, typename U>
__attribute__((always_inline)) static inline T toku_sync_add_and_fetch(T *addr,
U diff) {
paranoid_invariant(!crosses_boundary(addr, sizeof *addr));
- return __sync_add_and_fetch(addr, diff);
+ return __atomic_add_fetch(addr, diff, 5);
}
template <typename T, typename U>
__attribute__((always_inline)) static inline T toku_sync_fetch_and_sub(T *addr,
U diff) {
paranoid_invariant(!crosses_boundary(addr, sizeof *addr));
- return __sync_fetch_and_sub(addr, diff);
+ return __atomic_fetch_sub(addr, diff, 5);
}
template <typename T, typename U>
__attribute__((always_inline)) static inline T toku_sync_sub_and_fetch(T *addr,
U diff) {
paranoid_invariant(!crosses_boundary(addr, sizeof *addr));
- return __sync_sub_and_fetch(addr, diff);
+ return __atomic_sub_fetch(addr, diff, 5);
}
template <typename T, typename U, typename V>
__attribute__((always_inline)) static inline T toku_sync_val_compare_and_swap(
T *addr, U oldval, V newval) {
paranoid_invariant(!crosses_boundary(addr, sizeof *addr));
- return __sync_val_compare_and_swap(addr, oldval, newval);
+ return __atomic_compare_exchange(addr, oldval, newval);
}
template <typename T, typename U, typename V>
__attribute__((always_inline)) static inline bool
toku_sync_bool_compare_and_swap(T *addr, U oldval, V newval) {
paranoid_invariant(!crosses_boundary(addr, sizeof *addr));
- return __sync_bool_compare_and_swap(addr, oldval, newval);
+ return static_cast<bool>(__atomic_compare_exchange(addr, oldval, newval));
}
// in case you include this but not toku_portability.h
|