summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-08-06 12:32:35 -0400
committerBehdad Esfahbod <behdad@behdad.org>2009-08-06 12:32:35 -0400
commit991de7d8d973cf914b4038348370c2ad86c7ce7f (patch)
treee5431f09ee8753119dc50831abb957eb212c4d5b
parentd29e8fcd57cd62627c4fdbbaf4cbcf2e58c5df89 (diff)
downloadpango-991de7d8d973cf914b4038348370c2ad86c7ce7f.tar.gz
[HB] Use glib again
-rw-r--r--pango/opentype/Makefile.am5
-rw-r--r--pango/opentype/hb-blob.c4
-rw-r--r--pango/opentype/hb-object-private.h19
-rw-r--r--pango/opentype/hb-private.h45
4 files changed, 37 insertions, 36 deletions
diff --git a/pango/opentype/Makefile.am b/pango/opentype/Makefile.am
index 68b40669..2292c18a 100644
--- a/pango/opentype/Makefile.am
+++ b/pango/opentype/Makefile.am
@@ -36,12 +36,13 @@ HBHEADERS = \
$(NULL)
libharfbuzz_la_SOURCES = $(HBSOURCES) $(HBHEADERS)
-libharfbuzz_la_LIBADD =
+libharfbuzz_la_CPPFLAGS = -DHAVE_GLIB $(GLIB_CFLAGS)
+libharfbuzz_la_LIBADD = $(GLIB_LIBS)
noinst_PROGRAMS = main
main_SOURCES = main.cc
-main_CXXFLAGS = $(GLIB_CFLAGS)
+main_CPPFLAGS = -DHAVE_GLIB $(GLIB_CFLAGS)
main_LDADD = libharfbuzz.la $(GLIB_LIBS)
EXTRA_DIST = README COPYING
diff --git a/pango/opentype/hb-blob.c b/pango/opentype/hb-blob.c
index 910c0478..428e7d0d 100644
--- a/pango/opentype/hb-blob.c
+++ b/pango/opentype/hb-blob.c
@@ -171,7 +171,7 @@ const char *
hb_blob_lock (hb_blob_t *blob)
{
if (!HB_OBJECT_IS_INERT (blob))
- (void) _hb_reference_count_inc (blob->lock);
+ (void) hb_reference_count_inc (blob->lock);
#if HB_DEBUG
fprintf (stderr, "%p %s (%d) -> %p\n", blob, __FUNCTION__,
@@ -185,7 +185,7 @@ void
hb_blob_unlock (hb_blob_t *blob)
{
if (!HB_OBJECT_IS_INERT (blob)) {
- int old_lock = _hb_reference_count_dec (blob->lock);
+ int old_lock = hb_reference_count_dec (blob->lock);
assert (old_lock > 0);
}
diff --git a/pango/opentype/hb-object-private.h b/pango/opentype/hb-object-private.h
index d274b295..86ab82b9 100644
--- a/pango/opentype/hb-object-private.h
+++ b/pango/opentype/hb-object-private.h
@@ -30,26 +30,19 @@
#ifndef HB_REFCOUNT_PRIVATE_H
#define HB_REFCOUNT_PRIVATE_H
-typedef int hb_atomic_int_t;
-
-/* XXX add real atomic ops */
-#define _hb_atomic_fetch_and_add(AI, V) ((AI) += (V), (AI)-(V))
-#define _hb_atomic_int_get(AI) ((AI)+0)
-#define _hb_atomic_int_set(AI, VALUE) HB_STMT_START { (AI) = (VALUE); } HB_STMT_END
-
/* Encapsulate operations on the object's reference count */
typedef struct {
hb_atomic_int_t ref_count;
} hb_reference_count_t;
-#define _hb_reference_count_inc(RC) _hb_atomic_fetch_and_add ((RC).ref_count, 1)
-#define _hb_reference_count_dec(RC) _hb_atomic_fetch_and_add ((RC).ref_count, -1)
+#define hb_reference_count_inc(RC) hb_atomic_fetch_and_add ((RC).ref_count, 1)
+#define hb_reference_count_dec(RC) hb_atomic_fetch_and_add ((RC).ref_count, -1)
#define HB_REFERENCE_COUNT_INIT(RC, VALUE) ((RC).ref_count = (VALUE))
-#define HB_REFERENCE_COUNT_GET_VALUE(RC) _hb_atomic_int_get ((RC).ref_count)
-#define HB_REFERENCE_COUNT_SET_VALUE(RC, VALUE) _hb_atomic_int_set ((RC).ref_count, (VALUE))
+#define HB_REFERENCE_COUNT_GET_VALUE(RC) hb_atomic_int_get ((RC).ref_count)
+#define HB_REFERENCE_COUNT_SET_VALUE(RC, VALUE) hb_atomic_int_set ((RC).ref_count, (VALUE))
#define HB_REFERENCE_COUNT_INVALID_VALUE ((hb_atomic_int_t) -1)
#define HB_REFERENCE_COUNT_INVALID {HB_REFERENCE_COUNT_INVALID_VALUE}
@@ -85,7 +78,7 @@ typedef struct {
int old_count; \
if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \
return obj; \
- old_count = _hb_reference_count_inc (obj->ref_count); \
+ old_count = hb_reference_count_inc (obj->ref_count); \
assert (old_count > 0); \
return obj; \
} HB_STMT_END
@@ -102,7 +95,7 @@ typedef struct {
int old_count; \
if (HB_UNLIKELY (!(obj) || HB_OBJECT_IS_INERT (obj))) \
return; \
- old_count = _hb_reference_count_dec (obj->ref_count); \
+ old_count = hb_reference_count_dec (obj->ref_count); \
assert (old_count > 0); \
if (old_count != 1) \
return; \
diff --git a/pango/opentype/hb-private.h b/pango/opentype/hb-private.h
index ab3af855..fe13b7e2 100644
--- a/pango/opentype/hb-private.h
+++ b/pango/opentype/hb-private.h
@@ -46,6 +46,32 @@
#include "hb-common.h"
+#define hb_be_uint8
+#define hb_be_int8
+#define hb_be_uint16(v) ((uint16_t) hb_be_int16 ((uint16_t) v))
+#define hb_be_uint32(v) ((uint32_t) hb_be_int32 ((uint32_t) v))
+
+typedef int hb_atomic_int_t;
+
+/* We need external help for these */
+
+#if HAVE_GLIB
+
+#include <glib.h>
+
+/* Macros to convert to/from BigEndian */
+#define hb_be_int16(v) GINT16_FROM_BE (v)
+#define hb_be_int32(v) GINT32_FROM_BE (v)
+
+#define hb_atomic_fetch_and_add(AI, V) g_atomic_int_exchange_and_add (&(AI), V)
+#define hb_atomic_int_get(AI) g_atomic_int_get (&(AI))
+#define hb_atomic_int_set(AI, V) g_atomic_int_set (&(AI), V)
+
+#else
+#error "Could not find any system to define platform macros, see hb-private.h"
+#endif
+
+
/* Basics */
#undef MIN
@@ -146,25 +172,6 @@ _hb_popcount32 (uint32_t mask)
#endif
}
-static HB_GNUC_UNUSED inline uint16_t
-_hb_be_uint16 (uint16_t v)
-{
- return (v>>8) + (v<<8);
-}
-static HB_GNUC_UNUSED inline uint32_t
-_hb_be_uint32 (uint32_t v)
-{
- return _hb_be_uint16 (v>>16) + (_hb_be_uint16 (v) <<16);
-}
-
-/* Macros to convert to/from BigEndian */
-#define hb_be_uint8
-#define hb_be_int8
-#define hb_be_uint16(v) _hb_be_uint16 (v)
-#define hb_be_int16(v) ((int16_t) hb_be_uint16 (v))
-#define hb_be_uint32(v) _hb_be_uint32 (v)
-#define hb_be_int32(v) ((int32_t) hb_be_uint32 (v))
-
#include "hb-object-private.h"