[HarfBuzz] harfbuzz: Branch 'master' - 6 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Wed Sep 26 20:41:16 UTC 2018
.circleci/config.yml | 11 ++++++-----
src/hb-atomic.hh | 21 ++++++++++++++++++---
src/hb-ft.cc | 8 ++++----
test/api/Makefile.am | 8 +++++---
test/api/test-multithread.c | 27 ++++++++++++++++++---------
5 files changed, 51 insertions(+), 24 deletions(-)
New commits:
commit 7f30629cddcf0196d7b754df0cb2d4a8e5fed4b6
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Sep 26 16:40:23 2018 -0400
[ft] Make TSan happy
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index 3aed7188..50182f1b 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -70,7 +70,7 @@ struct hb_ft_font_t
bool symbol; /* Whether selected cmap is symbol cmap. */
bool unref; /* Whether to destroy ft_face when done. */
- mutable int cached_x_scale;
+ mutable hb_atomic_int_t cached_x_scale;
mutable hb_advance_cache_t advance_cache;
};
@@ -88,7 +88,7 @@ _hb_ft_font_create (FT_Face ft_face, bool symbol, bool unref)
ft_font->load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING;
- ft_font->cached_x_scale = 0;
+ ft_font->cached_x_scale.set (0);
ft_font->advance_cache.init ();
return ft_font;
@@ -250,10 +250,10 @@ hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data,
int load_flags = ft_font->load_flags;
int mult = font->x_scale < 0 ? -1 : +1;
- if (font->x_scale != ft_font->cached_x_scale)
+ if (font->x_scale != ft_font->cached_x_scale.get ())
{
ft_font->advance_cache.clear ();
- ft_font->cached_x_scale = font->x_scale;
+ ft_font->cached_x_scale.set (font->x_scale);
}
for (unsigned int i = 0; i < count; i++)
commit ec743fce2a72a1cb76ac9401747a442a03a051d9
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Sep 26 16:37:18 2018 -0400
Add more atomic intrinsics
diff --git a/src/hb-atomic.hh b/src/hb-atomic.hh
index 6e3672c1..8bc94039 100644
--- a/src/hb-atomic.hh
+++ b/src/hb-atomic.hh
@@ -49,17 +49,21 @@
/* Defined externally, i.e. in config.h. */
-#elif !defined(HB_NO_MT) && defined(__ATOMIC_CONSUME)
+#elif !defined(HB_NO_MT) && defined(__ATOMIC_ACQUIRE)
/* C++11-style GCC primitives. */
+#define _hb_memory_barrier() __sync_synchronize ()
+
#define hb_atomic_int_impl_add(AI, V) __atomic_fetch_add ((AI), (V), __ATOMIC_ACQ_REL)
#define hb_atomic_int_impl_set_relaxed(AI, V) __atomic_store_n ((AI), (V), __ATOMIC_RELAXED)
+#define hb_atomic_int_impl_set(AI, V) __atomic_store_n ((AI), (V), __ATOMIC_RELEASE)
#define hb_atomic_int_impl_get_relaxed(AI) __atomic_load_n ((AI), __ATOMIC_RELAXED)
+#define hb_atomic_int_impl_get(AI) __atomic_load_n ((AI), __ATOMIC_ACQUIRE)
#define hb_atomic_ptr_impl_set_relaxed(P, V) __atomic_store_n ((P), (V), __ATOMIC_RELAXED)
#define hb_atomic_ptr_impl_get_relaxed(P) __atomic_load_n ((P), __ATOMIC_RELAXED)
-#define hb_atomic_ptr_impl_get(P) __atomic_load_n ((P), __ATOMIC_CONSUME)
+#define hb_atomic_ptr_impl_get(P) __atomic_load_n ((P), __ATOMIC_ACQUIRE)
static inline bool
_hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N)
{
@@ -74,13 +78,19 @@ _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N)
#include <atomic>
+#define _hb_memory_barrier() std::atomic_thread_fence(std::memory_order_ack_rel)
+#define _hb_memory_r_barrier() std::atomic_thread_fence(std::memory_order_acquire)
+#define _hb_memory_w_barrier() std::atomic_thread_fence(std::memory_order_release)
+
#define hb_atomic_int_impl_add(AI, V) (reinterpret_cast<std::atomic<int> *> (AI)->fetch_add ((V), std::memory_order_acq_rel))
#define hb_atomic_int_impl_set_relaxed(AI, V) (reinterpret_cast<std::atomic<int> *> (AI)->store ((V), std::memory_order_relaxed))
+#define hb_atomic_int_impl_set_relaxed(AI, V) (reinterpret_cast<std::atomic<int> *> (AI)->store ((V), std::memory_order_release))
#define hb_atomic_int_impl_get_relaxed(AI) (reinterpret_cast<std::atomic<int> *> (AI)->load (std::memory_order_relaxed))
+#define hb_atomic_int_impl_get_relaxed(AI) (reinterpret_cast<std::atomic<int> *> (AI)->load (std::memory_order_acquire))
#define hb_atomic_ptr_impl_set_relaxed(P, V) (reinterpret_cast<std::atomic<void*> *> (P)->store ((V), std::memory_order_relaxed))
#define hb_atomic_ptr_impl_get_relaxed(P) (reinterpret_cast<std::atomic<void*> *> (P)->load (std::memory_order_relaxed))
-#define hb_atomic_ptr_impl_get(P) (reinterpret_cast<std::atomic<void*> *> (P)->load (std::memory_order_consume))
+#define hb_atomic_ptr_impl_get(P) (reinterpret_cast<std::atomic<void*> *> (P)->load (std::memory_order_acquire))
static inline bool
_hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N)
{
@@ -243,6 +253,9 @@ static_assert ((sizeof (long) == sizeof (void *)), "");
#ifndef hb_atomic_ptr_impl_get_relaxed
#define hb_atomic_ptr_impl_get_relaxed(P) (*(P))
#endif
+#ifndef hb_atomic_int_impl_get
+inline int hb_atomic_int_impl_get (int *AI) { int v = *AI; _hb_memory_r_barrier (); return v; }
+#endif
#ifndef hb_atomic_ptr_impl_get
inline void *hb_atomic_ptr_impl_get (void **P) { void *v = *P; _hb_memory_r_barrier (); return v; }
#endif
@@ -252,7 +265,9 @@ inline void *hb_atomic_ptr_impl_get (void **P) { void *v = *P; _hb_memory_r_barr
struct hb_atomic_int_t
{
inline void set_relaxed (int v_) const { hb_atomic_int_impl_set_relaxed (&v, v_); }
+ inline void set (int v_) const { hb_atomic_int_impl_set (&v, v_); }
inline int get_relaxed (void) const { return hb_atomic_int_impl_get_relaxed (&v); }
+ inline int get (void) const { return hb_atomic_int_impl_get (&v); }
inline int inc (void) { return hb_atomic_int_impl_add (&v, 1); }
inline int dec (void) { return hb_atomic_int_impl_add (&v, -1); }
commit d183b33c1dd42055a9432f4a756ea20856913201
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Wed Sep 26 16:29:35 2018 -0400
Rename test
diff --git a/test/api/Makefile.am b/test/api/Makefile.am
index 466d56f0..f910f9e0 100644
--- a/test/api/Makefile.am
+++ b/test/api/Makefile.am
@@ -30,13 +30,13 @@ noinst_PROGRAMS = $(TEST_PROGS)
TEST_PROGS = \
test-blob \
test-buffer \
+ test-collect-unicodes \
test-common \
test-font \
test-object \
test-set \
test-shape \
test-subset \
- test-subset-codepoints \
test-subset-cmap \
test-subset-glyf \
test-subset-hdmx \
diff --git a/test/api/test-subset-codepoints.c b/test/api/test-collect-unicodes.c
similarity index 100%
rename from test/api/test-subset-codepoints.c
rename to test/api/test-collect-unicodes.c
commit c9c75fe3d9eb36f166d594ceb5889a1dc0b14fe6
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Thu Sep 27 00:08:06 2018 +0330
[ci] Compile freetype on tsan and put sanitizer flags on correct places (#1188)
diff --git a/.circleci/config.yml b/.circleci/config.yml
index ec8abd92..97d211bc 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -107,7 +107,7 @@ jobs:
- run: apt update || true
- run: apt install -y clang lld binutils libtool autoconf automake make pkg-config gtk-doc-tools ragel libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python python-pip
- run: pip install fonttools
- - run: CPPFLAGS="-fsanitize=address" LDFLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer" CFLAGS="-O1 -g -fno-omit-frame-pointer" CXXFLAGS="-O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2
+ - run: CPPFLAGS="-fsanitize=address" LDFLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer" CFLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer" CXXFLAGS="-fsanitize=address -O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2
- run: make
- run: make check || .ci/fail.sh | asan_symbolize | c++filt
@@ -123,7 +123,7 @@ jobs:
- run: apt update || true
- run: apt install -y clang lld binutils libtool autoconf automake make pkg-config ragel libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python python-pip
- run: pip install fonttools
- - run: CPPFLAGS="-fsanitize=memory" LDFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" CFLAGS="-O1 -g -fno-omit-frame-pointer" CXXFLAGS="-O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2
+ - run: CPPFLAGS="-fsanitize=memory" LDFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" CFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" CXXFLAGS="-fsanitize=memory -O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2
- run: make
- run: MSAN_OPTIONS=exitcode=42 make check || .ci/fail.sh | asan_symbolize | c++filt
@@ -139,9 +139,10 @@ jobs:
- run: apt update || true
- run: apt install -y clang lld binutils libtool autoconf automake make pkg-config ragel libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python python-pip
- run: pip install fonttools
- - run: CPPFLAGS="-fsanitize=thread" LDFLAGS="-fsanitize=thread -O1 -g -fno-omit-frame-pointer" CFLAGS="-O1 -g -fno-omit-frame-pointer" CXXFLAGS="-O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2
+ - run: wget http://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.bz2 && tar xf freetype-2.9.tar.bz2 && cd freetype-2.9 && CPPFLAGS="-fsanitize=thread" LDFLAGS="-fsanitize=thread -O1 -g -fno-omit-frame-pointer" CFLAGS="-fsanitize=thread -O1 -g -fno-omit-frame-pointer" CXXFLAGS="-fsanitize=thread -O1 -g -fno-omit-frame-pointer" ./autogen.sh && ./configure && make -j4 && cd ..
+ - run: CPPFLAGS="-fsanitize=thread" LDFLAGS="-fsanitize=thread -O1 -g -fno-omit-frame-pointer" CFLAGS="-fsanitize=thread -O1 -g -fno-omit-frame-pointer" CXXFLAGS="-fsanitize=thread -O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2
- run: make
- - run: make check || .ci/fail.sh | asan_symbolize | c++filt
+ - run: LD_LIBRARY_PATH="$PWD/freetype-2.9/objs/.libs" make check || .ci/fail.sh | asan_symbolize | c++filt
clang-ubsan:
docker:
@@ -155,7 +156,7 @@ jobs:
- run: apt update || true
- run: apt install -y clang lld binutils libtool autoconf automake make pkg-config ragel libfreetype6-dev libglib2.0-dev libcairo2-dev libicu-dev libgraphite2-dev python python-pip
- run: pip install fonttools
- - run: CPPFLAGS="-fsanitize=undefined" LDFLAGS="-fsanitize=undefined -O1 -g -fno-omit-frame-pointer" CFLAGS="-O1 -g -fno-omit-frame-pointer" CXXFLAGS="-O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2
+ - run: CPPFLAGS="-fsanitize=undefined" LDFLAGS="-fsanitize=undefined -O1 -g -fno-omit-frame-pointer" CFLAGS="-fsanitize=undefined -O1 -g -fno-omit-frame-pointer" CXXFLAGS="-fsanitize=undefined -O1 -g -fno-omit-frame-pointer" LD=ld.lld CC=clang CXX=clang++ ./autogen.sh --with-freetype --with-glib --with-cairo --with-icu --with-graphite2
- run: make
- run: make check || .ci/fail.sh | asan_symbolize | c++filt
commit 39da1914b4fd1c58d61cb29c78a0904ff6b905c6
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Wed Sep 26 23:32:45 2018 +0330
Test freetype funcs on test-multithread (#1187)
diff --git a/test/api/Makefile.am b/test/api/Makefile.am
index 1c0f92c1..466d56f0 100644
--- a/test/api/Makefile.am
+++ b/test/api/Makefile.am
@@ -77,9 +77,11 @@ TEST_PROGS += \
$(NULL)
if HAVE_PTHREAD
+if HAVE_FREETYPE
TEST_PROGS += test-multithread
-test_multithread_CFLAGS = $(CFLAGS) $(PTHREAD_CFLAGS)
-test_multithread_LDADD = $(LDADD) $(PTHREAD_LIBS)
+test_multithread_CFLAGS = $(CFLAGS) $(PTHREAD_CFLAGS) $(FREETYPE_CFLAGS)
+test_multithread_LDADD = $(LDADD) $(PTHREAD_LIBS) $(FREETYPE_LIBS)
+endif
endif
if HAVE_FREETYPE
diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c
index 4570da12..c87da3c0 100644
--- a/test/api/test-multithread.c
+++ b/test/api/test-multithread.c
@@ -30,6 +30,7 @@
#include <pthread.h>
#include <hb.h>
+#include <hb-ft.h>
#include <hb-ot.h>
const char *text = "طرحنَما";
@@ -74,8 +75,8 @@ thread_func (void *data)
return 0;
}
-int
-main (int argc, char **argv)
+void
+test_body ()
{
int i;
int num_threads = 30;
@@ -84,11 +85,6 @@ main (int argc, char **argv)
pthread_mutex_lock (&mutex);
- hb_blob_t *blob = hb_blob_create_from_file (path);
- hb_face_t *face = hb_face_create (blob, 0);
- font = hb_font_create (face);
- hb_ot_font_set_funcs (font);
-
for (i = 0; i < num_threads; i++)
{
hb_buffer_t *buffer = hb_buffer_create ();
@@ -124,7 +120,7 @@ main (int argc, char **argv)
HB_BUFFER_SERIALIZE_FLAG_DEFAULT);
fprintf (stderr, "Expected: %s\n", out);
- return 1;
+ exit (1);
}
hb_buffer_destroy (buffer);
}
@@ -133,6 +129,19 @@ main (int argc, char **argv)
free (buffers);
free (threads);
+}
+
+int
+main (int argc, char **argv)
+{
+ hb_blob_t *blob = hb_blob_create_from_file (path);
+ hb_face_t *face = hb_face_create (blob, 0);
+ font = hb_font_create (face);
+
+ hb_ft_font_set_funcs (font);
+ test_body ();
+ hb_ot_font_set_funcs (font);
+ test_body ();
hb_font_destroy (font);
hb_face_destroy (face);
commit e88009a93f5d13ed31b6262f928761e9574dcef1
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Wed Sep 26 22:53:02 2018 +0330
Minor, remove the no longer needed comment on test-multithread
diff --git a/test/api/test-multithread.c b/test/api/test-multithread.c
index b9bcdf86..4570da12 100644
--- a/test/api/test-multithread.c
+++ b/test/api/test-multithread.c
@@ -78,7 +78,7 @@ int
main (int argc, char **argv)
{
int i;
- int num_threads = 30; // FIXME: Increase this and fix the issue
+ int num_threads = 30;
pthread_t *threads = calloc (num_threads, sizeof (pthread_t));
hb_buffer_t **buffers = calloc (num_threads, sizeof (hb_buffer_t *));
More information about the HarfBuzz
mailing list