Remove hb_atomic_int_set/get()

We never use them in fact...

I'm just adjusting these as I better understand the requirements of
the code and the guarantees of each operation.
pull/1/head
Behdad Esfahbod 13 years ago
parent 4efdffec09
commit 0558d55bac
  1. 8
      src/hb-atomic-private.hh
  2. 12
      src/hb-object-private.hh

@ -47,8 +47,6 @@
#include <intrin.h>
typedef long hb_atomic_int_t;
#define hb_atomic_int_add(AI, V) _InterlockedExchangeAdd (&(AI), (V))
#define hb_atomic_int_set(AI, V) ((AI) = (V), MemoryBarrier ())
#define hb_atomic_int_get(AI) (MemoryBarrier (), (AI))
#elif !defined(HB_NO_MT) && defined(__APPLE__)
@ -56,8 +54,6 @@ typedef long hb_atomic_int_t;
#include <libkern/OSAtomic.h>
typedef int32_t hb_atomic_int_t;
#define hb_atomic_int_add(AI, V) (OSAtomicAdd32Barrier ((V), &(AI)) - (V))
#define hb_atomic_int_set(AI, V) ((AI) = (V), OSMemoryBarrier ())
#define hb_atomic_int_get(AI) (OSMemoryBarrier (), (AI))
#elif !defined(HB_NO_MT) && defined(HAVE_GLIB)
@ -69,8 +65,6 @@ typedef volatile int hb_atomic_int_t;
#else
#define hb_atomic_int_add(AI, V) g_atomic_int_exchange_and_add (&(AI), (V))
#endif
#define hb_atomic_int_set(AI, V) g_atomic_int_set (&(AI), (V))
#define hb_atomic_int_get(AI) g_atomic_int_get (&(AI))
#else
@ -78,8 +72,6 @@ typedef volatile int hb_atomic_int_t;
#define HB_ATOMIC_INT_NIL 1
typedef volatile int hb_atomic_int_t;
#define hb_atomic_int_add(AI, V) (((AI) += (V)) - (V))
#define hb_atomic_int_set(AI, V) ((void) ((AI) = (V)))
#define hb_atomic_int_get(AI) (AI)
#endif

@ -48,17 +48,15 @@
/* reference_count */
typedef struct {
hb_atomic_int_t ref_count;
const hb_atomic_int_t ref_count;
#define HB_REFERENCE_COUNT_INVALID_VALUE ((hb_atomic_int_t) -1)
#define HB_REFERENCE_COUNT_INVALID {HB_REFERENCE_COUNT_INVALID_VALUE}
inline void init (int v) { ref_count = v; /* non-atomic is fine */ }
inline int inc (void) { return hb_atomic_int_add (ref_count, 1); }
inline int dec (void) { return hb_atomic_int_add (ref_count, -1); }
inline void init (int v) { const_cast<hb_atomic_int_t &> (ref_count) = v; }
inline int inc (void) { return hb_atomic_int_add (const_cast<hb_atomic_int_t &> (ref_count), 1); }
inline int dec (void) { return hb_atomic_int_add (const_cast<hb_atomic_int_t &> (ref_count), -1); }
inline int get (void) { return hb_atomic_int_get (ref_count); }
inline int get_unsafe (void) const { return ref_count; }
inline bool is_invalid (void) const { return ref_count == HB_REFERENCE_COUNT_INVALID_VALUE; }
} hb_reference_count_t;
@ -159,7 +157,7 @@ struct _hb_object_header_t {
DEBUG_MSG (OBJECT, (void *) this,
"%s refcount=%d",
function,
this ? ref_count.get_unsafe () : 0);
this ? ref_count.ref_count : 0);
}
};

Loading…
Cancel
Save