From a9f24c802956d57180d71b83e96a0fb81197df4a Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Thu, 21 Apr 2011 17:18:22 -0400 Subject: [PATCH] Move hb_reference_count_t to hb-private.h --- src/hb-object-private.hh | 17 ----------------- src/hb-private.hh | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/hb-object-private.hh b/src/hb-object-private.hh index 3654b0718..f45e32d3a 100644 --- a/src/hb-object-private.hh +++ b/src/hb-object-private.hh @@ -37,23 +37,6 @@ HB_BEGIN_DECLS -typedef struct { - 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_fetch_and_add (ref_count, 1); } - inline int dec (void) { return hb_atomic_int_fetch_and_add (ref_count, -1); } - inline void set (int v) { return hb_atomic_int_set (ref_count, v); } - - inline int get (void) const { return hb_atomic_int_get (ref_count); } - inline bool is_invalid (void) const { return get () == HB_REFERENCE_COUNT_INVALID_VALUE; } - -} hb_reference_count_t; - - /* Debug */ diff --git a/src/hb-private.hh b/src/hb-private.hh index e3fd6cf3b..929b28747 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -254,6 +254,25 @@ typedef volatile int hb_mutex_t; #endif +/* A reference count */ + +typedef struct { + 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_fetch_and_add (ref_count, 1); } + inline int dec (void) { return hb_atomic_int_fetch_and_add (ref_count, -1); } + inline void set (int v) { return hb_atomic_int_set (ref_count, v); } + + inline int get (void) const { return hb_atomic_int_get (ref_count); } + inline bool is_invalid (void) const { return get () == HB_REFERENCE_COUNT_INVALID_VALUE; } + +} hb_reference_count_t; + + /* Big-endian handling */ #define hb_be_uint16(v) ((uint16_t) ((((const uint8_t *)&(v))[0] << 8) + (((const uint8_t *)&(v))[1]))) @@ -270,6 +289,7 @@ typedef volatile int hb_mutex_t; /* ASCII tag/character handling */ #define ISALPHA(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z')) +#define ISALNUM(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z') || ((c) >= '0' && (c) <= '9')) #define TOUPPER(c) (((c) >= 'a' && (c) <= 'z') ? (c) - 'a' + 'A' : (c)) #define TOLOWER(c) (((c) >= 'A' && (c) <= 'Z') ? (c) - 'A' + 'a' : (c))