Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: third_party/harfbuzz-ng/src/hb-object-private.hh

Issue 10510004: Roll harfbuzz-ng 3b8fd9c48f4bde368bf2d465c148b9743a9216ee (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/harfbuzz-ng/src/hb-object-private.hh
diff --git a/third_party/harfbuzz-ng/src/hb-object-private.hh b/third_party/harfbuzz-ng/src/hb-object-private.hh
index 2e4a3858431d819f2b409af6ed3e1f970ef4f818..e3c9d2114c61ad9b841c7ed63b7be884fa2deaa9 100644
--- a/third_party/harfbuzz-ng/src/hb-object-private.hh
+++ b/third_party/harfbuzz-ng/src/hb-object-private.hh
@@ -34,10 +34,10 @@
#include "hb-private.hh"
+#include "hb-atomic-private.hh"
#include "hb-mutex-private.hh"
-
/* Debug */
#ifndef HB_DEBUG_OBJECT
@@ -45,76 +45,28 @@
#endif
-/* atomic_int */
-
-/* We need external help for these */
-
-#ifdef HAVE_GLIB
-
-#include <glib.h>
-
-typedef volatile int hb_atomic_int_t;
-#if GLIB_CHECK_VERSION(2,29,5)
-#define hb_atomic_int_add(AI, V) g_atomic_int_add (&(AI), V)
-#else
-#define hb_atomic_int_add(AI, V) g_atomic_int_exchange_and_add (&(AI), V)
-#endif
-#define hb_atomic_int_get(AI) g_atomic_int_get (&(AI))
-#define hb_atomic_int_set(AI, V) g_atomic_int_set (&(AI), V)
-
-
-#elif defined(_MSC_VER) && _MSC_VER >= 1600
-
-#include <intrin.h>
-
-typedef long hb_atomic_int_t;
-#define hb_atomic_int_add(AI, V) _InterlockedExchangeAdd (&(AI), V)
-#define hb_atomic_int_get(AI) (_ReadBarrier (), (AI))
-#define hb_atomic_int_set(AI, V) ((void) _InterlockedExchange (&(AI), (V)))
-
-
-#else
-
-#ifdef _MSC_VER
-#pragma message("Could not find any system to define atomic_int macros, library will NOT be thread-safe")
-#else
-#warning "Could not find any system to define atomic_int macros, library will NOT be thread-safe"
-#endif
-
-typedef volatile int hb_atomic_int_t;
-#define hb_atomic_int_add(AI, V) ((AI) += (V), (AI) - (V))
-#define hb_atomic_int_get(AI) (AI)
-#define hb_atomic_int_set(AI, V) ((void) ((AI) = (V)))
-
-
-#endif
-
-
-
-
/* reference_count */
-typedef struct {
+struct hb_reference_count_t
+{
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 set (int v) { hb_atomic_int_set (ref_count, v); }
+ 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) const { return hb_atomic_int_get (ref_count); }
- inline bool is_invalid (void) const { return get () == HB_REFERENCE_COUNT_INVALID_VALUE; }
+ inline bool is_invalid (void) const { return ref_count == HB_REFERENCE_COUNT_INVALID_VALUE; }
-} hb_reference_count_t;
+};
/* user_data */
-struct hb_user_data_array_t {
-
+struct hb_user_data_array_t
+{
struct hb_user_data_item_t {
hb_user_data_key_t *key;
void *data;
@@ -141,9 +93,8 @@ struct hb_user_data_array_t {
/* object_header */
-typedef struct _hb_object_header_t hb_object_header_t;
-
-struct _hb_object_header_t {
+struct hb_object_header_t
+{
hb_reference_count_t ref_count;
hb_user_data_array_t user_data;
@@ -200,17 +151,18 @@ struct _hb_object_header_t {
}
inline void trace (const char *function) const {
+ if (unlikely (!this)) return;
+ /* XXX We cannot use DEBUG_MSG_FUNC here since that one currecntly only
+ * prints the class name and throws away the template info. */
DEBUG_MSG (OBJECT, (void *) this,
- "refcount=%d %s",
- this ? ref_count.get () : 0,
- function);
+ "%s refcount=%d",
+ function,
+ this ? ref_count.ref_count : 0);
}
};
-
-
/* object */
template <typename Type>
@@ -261,7 +213,4 @@ static inline void *hb_object_get_user_data (Type *obj,
}
-
-
-
#endif /* HB_OBJECT_PRIVATE_HH */
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-mutex-private.hh ('k') | third_party/harfbuzz-ng/src/hb-open-file-private.hh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698