From 3edef5a19b5c0f30381ae6fe01c3370ded37f6ca Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 17 Jul 2018 10:50:01 +0200 Subject: [PATCH] Revert "Implement C++11-style GCC builtin atomic ops" This reverts commit 21fa170f0bfb0109c506ed17f5aff8b062564ffa. Is crashing. Oops. --- src/hb-atomic-private.hh | 22 +++------------------- src/hb-object-private.hh | 2 +- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh index 61d33365..14960026 100644 --- a/src/hb-atomic-private.hh +++ b/src/hb-atomic-private.hh @@ -46,37 +46,21 @@ /* Defined externally, i.e. in config.h; must have typedef'ed hb_atomic_int_impl_t as well. */ -#elif !defined(HB_NO_MT) && defined(__ATOMIC_ACQUIRE) - -/* C++11-style GCC primitives. */ - -typedef int hb_atomic_int_impl_t; -#define hb_atomic_int_impl_add(AI, V) __atomic_fetch_add (&(AI), (V), __ATOMIC_ACQ_REL) - -#define hb_atomic_ptr_impl_get(P) __atomic_load_n ((P), __ATOMIC_ACQUIRE) -static inline bool -_hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N) -{ - const void *O = O_; // Need lvalue - return __atomic_compare_exchange_n ((void **) P, (void **) O, (void *) N, true, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED); -} -#define hb_atomic_ptr_impl_cmpexch(P,O,N) (_hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N))) - #elif !defined(HB_NO_MT) && __cplusplus >= 201103L -/* C++11 atomics. */ +/* Prefer C++11 atomics. */ #include typedef int hb_atomic_int_impl_t; -#define hb_atomic_int_impl_add(AI, V) (reinterpret_cast *> (&AI)->fetch_add ((V), std::memory_order_acq_rel)) +#define hb_atomic_int_impl_add(AI, V) (reinterpret_cast *> (&AI)->fetch_add (V, std::memory_order_acq_rel)) #define hb_atomic_ptr_impl_get(P) (reinterpret_cast *> (P)->load (std::memory_order_acquire)) static inline bool _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N) { const void *O = O_; // Need lvalue - return reinterpret_cast *> (P)->compare_exchange_weak (O, N, std::memory_order_acq_rel, std::memory_order_relaxed); + return reinterpret_cast *> (P)->compare_exchange_weak ((O), (N), std::memory_order_acq_rel); } #define hb_atomic_ptr_impl_cmpexch(P,O,N) (_hb_atomic_ptr_impl_cmplexch ((const void **) (P), (O), (N))) diff --git a/src/hb-object-private.hh b/src/hb-object-private.hh index 8199c4b8..fcdc9256 100644 --- a/src/hb-object-private.hh +++ b/src/hb-object-private.hh @@ -94,7 +94,7 @@ struct hb_user_data_array_t struct hb_object_header_t { hb_reference_count_t ref_count; - mutable hb_user_data_array_t *user_data; + hb_user_data_array_t *user_data; #define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INIT, nullptr} -- GitLab