Make atomic types' internal values non-mutable

This resulted from confusion previously...
This commit is contained in:
Behdad Esfahbod 2018-11-13 11:45:12 -05:00
parent c52d5bcd94
commit 9579ed9755
2 changed files with 6 additions and 6 deletions

View File

@ -267,14 +267,14 @@ inline void *hb_atomic_ptr_impl_get (void **P) { void *v = *P; _hb_memory_r_barr
#define HB_ATOMIC_INT_INIT(V) {V} #define HB_ATOMIC_INT_INIT(V) {V}
struct hb_atomic_int_t struct hb_atomic_int_t
{ {
inline void set_relaxed (int v_) const { hb_atomic_int_impl_set_relaxed (&v, v_); } inline void set_relaxed (int v_) { hb_atomic_int_impl_set_relaxed (&v, v_); }
inline void set (int v_) const { hb_atomic_int_impl_set (&v, v_); } inline void set (int v_) { hb_atomic_int_impl_set (&v, v_); }
inline int get_relaxed (void) const { return hb_atomic_int_impl_get_relaxed (&v); } inline int get_relaxed (void) const { return hb_atomic_int_impl_get_relaxed (&v); }
inline int get (void) const { return hb_atomic_int_impl_get (&v); } inline int get (void) const { return hb_atomic_int_impl_get (&v); }
inline int inc (void) { return hb_atomic_int_impl_add (&v, 1); } inline int inc (void) { return hb_atomic_int_impl_add (&v, 1); }
inline int dec (void) { return hb_atomic_int_impl_add (&v, -1); } inline int dec (void) { return hb_atomic_int_impl_add (&v, -1); }
mutable int v; int v;
}; };
@ -285,7 +285,7 @@ struct hb_atomic_ptr_t
typedef typename hb_remove_pointer<P>::value T; typedef typename hb_remove_pointer<P>::value T;
inline void init (T* v_ = nullptr) { set_relaxed (v_); } inline void init (T* v_ = nullptr) { set_relaxed (v_); }
inline void set_relaxed (T* v_) const { hb_atomic_ptr_impl_set_relaxed (&v, v_); } inline void set_relaxed (T* v_) { hb_atomic_ptr_impl_set_relaxed (&v, v_); }
inline T *get_relaxed (void) const { return (T *) hb_atomic_ptr_impl_get_relaxed (&v); } inline T *get_relaxed (void) const { return (T *) hb_atomic_ptr_impl_get_relaxed (&v); }
inline T *get (void) const { return (T *) hb_atomic_ptr_impl_get ((void **) &v); } inline T *get (void) const { return (T *) hb_atomic_ptr_impl_get ((void **) &v); }
inline bool cmpexch (const T *old, T *new_) const { return hb_atomic_ptr_impl_cmpexch ((void **) &v, (void *) old, (void *) new_); } inline bool cmpexch (const T *old, T *new_) const { return hb_atomic_ptr_impl_cmpexch ((void **) &v, (void *) old, (void *) new_); }
@ -293,7 +293,7 @@ struct hb_atomic_ptr_t
inline T * operator -> (void) const { return get (); } inline T * operator -> (void) const { return get (); }
template <typename C> inline operator C * (void) const { return get (); } template <typename C> inline operator C * (void) const { return get (); }
mutable T *v; T *v;
}; };

View File

@ -194,7 +194,7 @@ struct hb_user_data_array_t
struct hb_object_header_t struct hb_object_header_t
{ {
hb_reference_count_t ref_count; hb_reference_count_t ref_count;
hb_atomic_int_t writable; mutable hb_atomic_int_t writable;
hb_atomic_ptr_t<hb_user_data_array_t> user_data; hb_atomic_ptr_t<hb_user_data_array_t> user_data;
}; };
#define HB_OBJECT_HEADER_STATIC \ #define HB_OBJECT_HEADER_STATIC \