[HarfBuzz] harfbuzz: Branch 'master' - 2 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Wed Aug 1 05:59:12 UTC 2018
docs/harfbuzz-sections.txt | 2 ++
src/hb-atomic-private.hh | 28 +++++++++++++++++-----------
src/hb-gobject-structs.cc | 1 +
src/hb-gobject-structs.h | 4 ++++
src/hb-map.cc | 6 ++----
5 files changed, 26 insertions(+), 15 deletions(-)
New commits:
commit 896ff15ae60a4a4b94c62946e69196b877839bb5
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Jul 31 22:51:38 2018 -0700
[atomic] Fix get() impl
Originally, glib's atomic_get was implemented as "memory_barrier; load".
I copied this into cairo, fontconfig, and harfbuzz. However, that's
wrong. Correct way is "load; memory_barrier". The details are long
and hard to fully grasp. Best to read:
https://www.kernel.org/doc/Documentation/memory-barriers.txt
Also see my report against GNOME:
https://gitlab.gnome.org/GNOME/glib/issues/1449
Note that this is irrelevant if C++11-like atomic ops are available.
diff --git a/src/hb-atomic-private.hh b/src/hb-atomic-private.hh
index 2e73cd85..ef72872a 100644
--- a/src/hb-atomic-private.hh
+++ b/src/hb-atomic-private.hh
@@ -89,11 +89,10 @@ _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N)
#include <windows.h>
-/* MinGW has a convoluted history of supporting MemoryBarrier
- * properly. As such, define a function to wrap the whole
- * thing. */
-static inline void _HBMemoryBarrier (void) {
+static inline void _hb_memory_barrier (void)
+{
#if !defined(MemoryBarrier)
+ /* MinGW has a convoluted history of supporting MemoryBarrier. */
long dummy = 0;
InterlockedExchange (&dummy, 1);
#else
@@ -104,7 +103,6 @@ static inline void _HBMemoryBarrier (void) {
typedef LONG hb_atomic_int_impl_t;
#define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd ((AI), (V))
-#define hb_atomic_ptr_impl_get(P) (_HBMemoryBarrier (), (void *) *(P))
#define hb_atomic_ptr_impl_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O))
@@ -113,7 +111,8 @@ typedef LONG hb_atomic_int_impl_t;
typedef int hb_atomic_int_impl_t;
#define hb_atomic_int_impl_add(AI, V) __sync_fetch_and_add ((AI), (V))
-#define hb_atomic_ptr_impl_get(P) (void *) (__sync_synchronize (), *(P))
+static inline void _hb_memory_barrier (void) { __sync_synchronize (); }
+
#define hb_atomic_ptr_impl_cmpexch(P,O,N) __sync_bool_compare_and_swap ((P), (O), (N))
@@ -125,7 +124,8 @@ typedef int hb_atomic_int_impl_t;
typedef unsigned int hb_atomic_int_impl_t;
#define hb_atomic_int_impl_add(AI, V) ( ({__machine_rw_barrier ();}), atomic_add_int_nv ((AI), (V)) - (V))
-#define hb_atomic_ptr_impl_get(P) ( ({__machine_rw_barrier ();}), (void *) *(P))
+static inline void _hb_memory_barrier (void) { __machine_rw_barrier (); }
+
#define hb_atomic_ptr_impl_cmpexch(P,O,N) ( ({__machine_rw_barrier ();}), atomic_cas_ptr ((void **) (P), (void *) (O), (void *) (N)) == (void *) (O) ? true : false)
@@ -142,7 +142,8 @@ typedef unsigned int hb_atomic_int_impl_t;
typedef int32_t hb_atomic_int_impl_t;
#define hb_atomic_int_impl_add(AI, V) (OSAtomicAdd32Barrier ((V), (AI)) - (V))
-#define hb_atomic_ptr_impl_get(P) (OSMemoryBarrier (), (void *) *(P))
+static inline void _hb_memory_barrier (void) { OSMemoryBarrier (); }
+
#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100)
#define hb_atomic_ptr_impl_cmpexch(P,O,N) OSAtomicCompareAndSwapPtrBarrier ((void *) (O), (void *) (N), (void **) (P))
#else
@@ -175,7 +176,8 @@ static inline int _hb_compare_and_swaplp(volatile long* P, long O, long N) {
typedef int hb_atomic_int_impl_t;
#define hb_atomic_int_impl_add(AI, V) _hb_fetch_and_add ((AI), (V))
-#define hb_atomic_ptr_impl_get(P) (__sync(), (void *) *(P))
+static inline void _hb_memory_barrier (void) { __sync(); }
+
#define hb_atomic_ptr_impl_cmpexch(P,O,N) _hb_compare_and_swaplp ((long*)(P), (long)(O), (long)(N))
#elif !defined(HB_NO_MT)
@@ -185,7 +187,7 @@ typedef int hb_atomic_int_impl_t;
typedef volatile int hb_atomic_int_impl_t;
#define hb_atomic_int_impl_add(AI, V) ((*(AI) += (V)) - (V))
-#define hb_atomic_ptr_impl_get(P) ((void *) *(P))
+static inline void _hb_memory_barrier (void) {}
#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void * volatile *) (P) == (void *) (O) ? (* (void * volatile *) (P) = (void *) (N), true) : false)
@@ -194,7 +196,8 @@ typedef volatile int hb_atomic_int_impl_t;
typedef int hb_atomic_int_impl_t;
#define hb_atomic_int_impl_add(AI, V) ((*(AI) += (V)) - (V))
-#define hb_atomic_ptr_impl_get(P) ((void *) *(P))
+static inline void _hb_memory_barrier (void) {}
+
#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), true) : false)
@@ -210,6 +213,9 @@ typedef int hb_atomic_int_impl_t;
#ifndef hb_atomic_int_impl_get_relaxed
#define hb_atomic_int_impl_get_relaxed(AI) (*(AI))
#endif
+#ifndef hb_atomic_ptr_impl_get
+inline void *hb_atomic_ptr_impl_get (void **P) { void *v = *P; _hb_memory_barrier (); return v; }
+#endif
struct hb_atomic_int_t
commit d7a15799d40dac1f9521674a82c3293a7cb42ee4
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Jul 31 22:28:28 2018 -0700
[gobject] Hook up hb_map_t
diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt
index 5cf5a884..db4e71af 100644
--- a/docs/harfbuzz-sections.txt
+++ b/docs/harfbuzz-sections.txt
@@ -327,6 +327,7 @@ HB_GOBJECT_TYPE_FACE
HB_GOBJECT_TYPE_FONT
HB_GOBJECT_TYPE_FONT_FUNCS
HB_GOBJECT_TYPE_GLYPH_FLAGS
+HB_GOBJECT_TYPE_MAP
HB_GOBJECT_TYPE_MEMORY_MODE
HB_GOBJECT_TYPE_OT_LAYOUT_GLYPH_CLASS
HB_GOBJECT_TYPE_OT_MATH_CONSTANT
@@ -358,6 +359,7 @@ hb_gobject_face_get_type
hb_gobject_font_funcs_get_type
hb_gobject_font_get_type
hb_gobject_glyph_flags_get_type
+hb_gobject_map_get_type
hb_gobject_memory_mode_get_type
hb_gobject_ot_layout_glyph_class_get_type
hb_gobject_ot_math_constant_get_type
diff --git a/src/hb-gobject-structs.cc b/src/hb-gobject-structs.cc
index a96c3580..0c8e5573 100644
--- a/src/hb-gobject-structs.cc
+++ b/src/hb-gobject-structs.cc
@@ -71,6 +71,7 @@ HB_DEFINE_OBJECT_TYPE (face)
HB_DEFINE_OBJECT_TYPE (font)
HB_DEFINE_OBJECT_TYPE (font_funcs)
HB_DEFINE_OBJECT_TYPE (set)
+HB_DEFINE_OBJECT_TYPE (map)
HB_DEFINE_OBJECT_TYPE (shape_plan)
HB_DEFINE_OBJECT_TYPE (unicode_funcs)
HB_DEFINE_VALUE_TYPE (feature)
diff --git a/src/hb-gobject-structs.h b/src/hb-gobject-structs.h
index 302dc958..ccc06a5e 100644
--- a/src/hb-gobject-structs.h
+++ b/src/hb-gobject-structs.h
@@ -90,6 +90,10 @@ hb_gobject_set_get_type (void);
#define HB_GOBJECT_TYPE_SET (hb_gobject_set_get_type ())
HB_EXTERN GType
+hb_gobject_map_get_type (void);
+#define HB_GOBJECT_TYPE_SET (hb_gobject_map_get_type ())
+
+HB_EXTERN GType
hb_gobject_shape_plan_get_type (void);
#define HB_GOBJECT_TYPE_SHAPE_PLAN (hb_gobject_shape_plan_get_type ())
diff --git a/src/hb-map.cc b/src/hb-map.cc
index e3ddae41..138a8561 100644
--- a/src/hb-map.cc
+++ b/src/hb-map.cc
@@ -157,8 +157,6 @@ hb_map_allocation_successful (const hb_map_t *map)
*
*
*
- * Return value:
- *
* Since: 1.7.7
**/
void
@@ -188,7 +186,7 @@ hb_map_get (const hb_map_t *map,
/**
* hb_map_del:
* @map: a map.
- * @codepoint:
+ * @key:
*
*
*
@@ -204,7 +202,7 @@ hb_map_del (hb_map_t *map,
/**
* hb_map_has:
* @map: a map.
- * @codepoint:
+ * @key:
*
*
*
More information about the HarfBuzz
mailing list