Patrick Williams | 03514f1 | 2024-04-05 07:04:11 -0500 | [diff] [blame] | 1 | From 1ba84e1b8d4c9a3ad85dc443b0df4d79c89cca4b Mon Sep 17 00:00:00 2001 |
Andrew Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Thu, 17 Jun 2021 19:35:01 -0700 |
| 4 | Subject: [PATCH] replace old sync with new atomic builtin equivalents |
| 5 | |
| 6 | Helps compiling with gcc on newer arches e.g. riscv32 where these |
| 7 | __sync* builtins are not implemented atleast for 64bit values |
| 8 | |
Patrick Williams | 520786c | 2023-06-25 16:20:36 -0500 | [diff] [blame] | 9 | Upstream-Status: Pending |
| 10 | |
Patrick Williams | 03514f1 | 2024-04-05 07:04:11 -0500 | [diff] [blame] | 11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 12 | --- |
Andrew Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 13 | .../range/range_tree/lib/portability/toku_atomic.h | 12 ++++++------ |
| 14 | 1 file changed, 6 insertions(+), 6 deletions(-) |
| 15 | |
Patrick Williams | 03514f1 | 2024-04-05 07:04:11 -0500 | [diff] [blame] | 16 | diff --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 |
| 17 | index aaa2298faf..9385902808 100644 |
Andrew Geissler | 6972109 | 2021-07-23 12:57:00 -0400 | [diff] [blame] | 18 | --- 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 Williams | 03514f1 | 2024-04-05 07:04:11 -0500 | [diff] [blame] | 64 | -- |
| 65 | 2.25.1 |
| 66 | |