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