[HarfBuzz] harfbuzz: Branch 'master'
src/hb-dsalgs.hh |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 718dfd4189275b1e4233dc7c12ab457352fccfcb Author: Behdad Esfahbod Date: Tue Jul 10 16:34:31 2018 +0200 Fix shift diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 4d3db966..6a8ddaa9 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -220,7 +220,7 @@ hb_ctz (T v) { unsigned int shift = 64; return (uint64_t) v ? hb_bit_storage ((uint64_t) v) : - hb_bit_storage ((uint64_t) v >> shift) + shift; + hb_bit_storage ((uint64_t) (v >> shift)) + shift; } assert (0); ___ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/harfbuzz
[HarfBuzz] harfbuzz: Branch 'master' - 2 commits
src/hb-debug.hh |1 src/hb-dsalgs.hh | 237 src/hb-object-private.hh |2 src/hb-private.hh| 251 --- 4 files changed, 245 insertions(+), 246 deletions(-) New commits: commit 25aa411ac524ed08624033da473a5e050ff41633 Author: Behdad Esfahbod Date: Tue Jul 10 16:05:03 2018 +0200 Put back include dependencies diff --git a/src/hb-object-private.hh b/src/hb-object-private.hh index 95847b9c..fcdc9256 100644 --- a/src/hb-object-private.hh +++ b/src/hb-object-private.hh @@ -33,6 +33,8 @@ #define HB_OBJECT_PRIVATE_HH #include "hb-private.hh" +#include "hb-atomic-private.hh" +#include "hb-mutex-private.hh" /* reference_count */ diff --git a/src/hb-private.hh b/src/hb-private.hh index 3520919f..ff339df4 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -599,11 +599,12 @@ _hb_memalign(void **memptr, size_t alignment, size_t size) #endif -/* Headers we include for everyone. Specifically ordered to resolve dependencies. */ +/* Headers we include for everyone. Keep sorted. They express dependency amongst + * themselves, but no other file should include them.*/ #include "hb-atomic-private.hh" -#include "hb-mutex-private.hh" -#include "hb-dsalgs.hh" #include "hb-debug.hh" +#include "hb-dsalgs.hh" +#include "hb-mutex-private.hh" #include "hb-object-private.hh" #endif /* HB_PRIVATE_HH */ commit 491d93bf74dd0483715ecca430715b69664e1211 Author: Behdad Esfahbod Date: Tue Jul 10 16:03:31 2018 +0200 Move more stuff from hb-private.hh to hb-dsalgs.hh diff --git a/src/hb-debug.hh b/src/hb-debug.hh index c244347b..ae0b6774 100644 --- a/src/hb-debug.hh +++ b/src/hb-debug.hh @@ -28,6 +28,7 @@ #define HB_DEBUG_HH #include "hb-private.hh" +#include "hb-dsalgs.hh" #ifndef HB_DEBUG diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 60cb0023..4d3db966 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -30,6 +30,243 @@ #include "hb-private.hh" +/* Void! For when we need a expression-type of void. */ +typedef const struct _hb_void_t *hb_void_t; +#define HB_VOID ((const _hb_void_t *) nullptr) + + +/* + * Bithacks. + */ + +/* Return the number of 1 bits in v. */ +template +static inline HB_CONST_FUNC unsigned int +hb_popcount (T v) +{ +#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) && defined(__OPTIMIZE__) + if (sizeof (T) <= sizeof (unsigned int)) +return __builtin_popcount (v); + + if (sizeof (T) <= sizeof (unsigned long)) +return __builtin_popcountl (v); + + if (sizeof (T) <= sizeof (unsigned long long)) +return __builtin_popcountll (v); +#endif + + if (sizeof (T) <= 4) + { +/* "HACKMEM 169" */ +uint32_t y; +y = (v >> 1) &0333; +y = v - y - ((y >>1) & 0333); +return (((y + (y >> 3)) & 030707070707) % 077); + } + + if (sizeof (T) == 8) + { +unsigned int shift = 32; +return hb_popcount ((uint32_t) v) + hb_popcount ((uint32_t) (v >> shift)); + } + + if (sizeof (T) == 16) + { +unsigned int shift = 64; +return hb_popcount ((uint64_t) v) + hb_popcount ((uint64_t) (v >> shift)); + } + + assert (0); + return 0; /* Shut up stupid compiler. */ +} + +/* Returns the number of bits needed to store number */ +template +static inline HB_CONST_FUNC unsigned int +hb_bit_storage (T v) +{ + if (unlikely (!v)) return 0; + +#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__) + if (sizeof (T) <= sizeof (unsigned int)) +return sizeof (unsigned int) * 8 - __builtin_clz (v); + + if (sizeof (T) <= sizeof (unsigned long)) +return sizeof (unsigned long) * 8 - __builtin_clzl (v); + + if (sizeof (T) <= sizeof (unsigned long long)) +return sizeof (unsigned long long) * 8 - __builtin_clzll (v); +#endif + +#if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__) + if (sizeof (T) <= sizeof (unsigned int)) + { +unsigned long where; +_BitScanReverse (, v); +return 1 + where; + } +# if _WIN64 + if (sizeof (T) <= 8) + { +unsigned long where; +_BitScanReverse64 (, v); +return 1 + where; + } +# endif +#endif + + if (sizeof (T) <= 4) + { +/* "bithacks" */ +const unsigned int b[] = {0x2, 0xC, 0xF0, 0xFF00, 0x}; +const unsigned int S[] = {1, 2, 4, 8, 16}; +unsigned int r = 0; +for (int i = 4; i >= 0; i--) + if (v & b[i]) + { + v >>= S[i]; + r |= S[i]; + } +return r + 1; + } + if (sizeof (T) <= 8) + { +/* "bithacks" */ +const uint64_t b[] = {0x2ULL, 0xCULL, 0xF0ULL, 0xFF00ULL, 0xULL, 0xULL}; +const unsigned int S[] = {1, 2, 4, 8, 16, 32}; +unsigned int r = 0; +for (int i = 5; i >= 0; i--) + if (v & b[i]) + { + v >>= S[i]; + r |= S[i]; + } +return r + 1; + } + if (sizeof (T) == 16) + { +unsigned int shift = 64; +return (v >> shift) ? hb_bit_storage ((uint64_t) (v >> shift)) +
[HarfBuzz] harfbuzz: Branch 'master' - 4 commits
src/hb-blob-private.hh |2 src/hb-blob.cc |1 src/hb-buffer-private.hh |1 src/hb-common.cc |2 src/hb-coretext.cc |1 src/hb-directwrite.cc|1 src/hb-dsalgs.hh | 130 +++ src/hb-face-private.hh |1 src/hb-font-private.hh |1 src/hb-ft.cc |1 src/hb-map-private.hh|1 src/hb-object-private.hh |4 - src/hb-open-type-private.hh |1 src/hb-ot-layout-common-private.hh |1 src/hb-ot-layout-gsubgpos-private.hh |1 src/hb-ot-shape-complex-arabic.cc|1 src/hb-private.hh| 113 +- src/hb-set-private.hh|1 src/hb-shape-plan-private.hh |1 src/hb-shape-plan.cc |1 src/hb-subset-input.cc |1 src/hb-subset-plan.hh|1 src/hb-subset.cc |1 src/hb-unicode-private.hh|1 src/hb-uniscribe.cc |1 src/hb-warning.cc|4 - 26 files changed, 123 insertions(+), 152 deletions(-) New commits: commit f477765661c196ac17b2c86731881a3da36a5ae6 Author: Behdad Esfahbod Date: Tue Jul 10 15:49:05 2018 +0200 Move more stuff to hb-dsalgs.hh diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 4eceeb2f..60cb0023 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -541,4 +541,87 @@ struct hb_bytes_t }; +struct HbOpOr +{ + static const bool passthru_left = true; + static const bool passthru_right = true; + template static void process (T , const T , const T ) { o = a | b; } +}; +struct HbOpAnd +{ + static const bool passthru_left = false; + static const bool passthru_right = false; + template static void process (T , const T , const T ) { o = a & b; } +}; +struct HbOpMinus +{ + static const bool passthru_left = true; + static const bool passthru_right = false; + template static void process (T , const T , const T ) { o = a & ~b; } +}; +struct HbOpXor +{ + static const bool passthru_left = true; + static const bool passthru_right = true; + template static void process (T , const T , const T ) { o = a ^ b; } +}; + + +/* Compiler-assisted vectorization. */ + +/* Type behaving similar to vectorized vars defined using __attribute__((vector_size(...))), + * using vectorized operations if HB_VECTOR_SIZE is set to **bit** numbers (eg 128). + * Define that to 0 to disable. */ +template +struct hb_vector_size_t +{ + elt_t& operator [] (unsigned int i) { return u.v[i]; } + const elt_t& operator [] (unsigned int i) const { return u.v[i]; } + + template + inline hb_vector_size_t process (const hb_vector_size_t ) const + { +hb_vector_size_t r; +#if HB_VECTOR_SIZE +if (HB_VECTOR_SIZE && 0 == (byte_size * 8) % HB_VECTOR_SIZE) + for (unsigned int i = 0; i < ARRAY_LENGTH (u.vec); i++) + Op::process (r.u.vec[i], u.vec[i], o.u.vec[i]); +else +#endif + for (unsigned int i = 0; i < ARRAY_LENGTH (u.v); i++) + Op::process (r.u.v[i], u.v[i], o.u.v[i]); +return r; + } + inline hb_vector_size_t operator | (const hb_vector_size_t ) const + { return process (o); } + inline hb_vector_size_t operator & (const hb_vector_size_t ) const + { return process (o); } + inline hb_vector_size_t operator ^ (const hb_vector_size_t ) const + { return process (o); } + inline hb_vector_size_t operator ~ () const + { +hb_vector_size_t r; +#if HB_VECTOR_SIZE && 0 +if (HB_VECTOR_SIZE && 0 == (byte_size * 8) % HB_VECTOR_SIZE) + for (unsigned int i = 0; i < ARRAY_LENGTH (u.vec); i++) + r.u.vec[i] = ~u.vec[i]; +else +#endif +for (unsigned int i = 0; i < ARRAY_LENGTH (u.v); i++) + r.u.v[i] = ~u.v[i]; +return r; + } + + private: + static_assert (byte_size / sizeof (elt_t) * sizeof (elt_t) == byte_size, ""); + union { +elt_t v[byte_size / sizeof (elt_t)]; +#if HB_VECTOR_SIZE +typedef unsigned long vec_t __attribute__((vector_size (HB_VECTOR_SIZE / 8))); +vec_t vec[byte_size / sizeof (vec_t)]; +#endif + } u; +}; + + #endif /* HB_DSALGS_HH */ diff --git a/src/hb-private.hh b/src/hb-private.hh index aa4d017c..61a13215 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -746,34 +746,6 @@ hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3) -/* Vectorization */ - -struct HbOpOr -{ - static const bool passthru_left = true; - static const bool passthru_right = true; - template static void process (T , const T , const T ) { o = a | b; } -}; -struct HbOpAnd -{ - static const bool passthru_left = false; - static const bool passthru_right = false; - template static void process (T , const T , const T ) { o = a & b; } -}; -struct HbOpMinus -{ - static const bool passthru_left = true; -
[HarfBuzz] harfbuzz: Branch 'master'
src/hb-private.hh |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) New commits: commit 763f878cc0595162255c58ffe7a82ac1ca51cb0b Author: Behdad Esfahbod Date: Tue Jul 10 13:47:41 2018 +0200 Fix syntax Oops. diff --git a/src/hb-private.hh b/src/hb-private.hh index 56606531..5131dded 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -74,7 +74,7 @@ extern "C" void hb_free_impl(void *ptr); #define realloc hb_realloc_impl #define free hb_free_impl -#if defined(hb_memalign_impl +#if defined(hb_memalign_impl) extern "C" int hb_memalign_impl(void **memptr, size_t alignment, size_t size); #define posix_memalign hb_memalign_impl #else ___ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/harfbuzz
[HarfBuzz] harfbuzz: Branch 'master' - 2 commits
configure.ac |2 - src/hb-private.hh | 63 -- 2 files changed, 53 insertions(+), 12 deletions(-) New commits: commit 83ea277178544cd7e417bdfb7b600ede94910e13 Author: Behdad Esfahbod Date: Tue Jul 10 13:17:27 2018 +0200 Add posix_memalign() fallback diff --git a/configure.ac b/configure.ac index d6c23e53..35de036b 100644 --- a/configure.ac +++ b/configure.ac @@ -78,7 +78,7 @@ GTK_DOC_CHECK([1.15],[--flavour no-tmpl]) ]) # Functions and headers -AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l) +AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l posix_memalign) save_libs="$LIBS" LIBS="$LIBS -lm" diff --git a/src/hb-private.hh b/src/hb-private.hh index 48a7db10..56606531 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -58,6 +58,7 @@ #define HB_PASTE1(a,b) a##b #define HB_PASTE(a,b) HB_PASTE1(a,b) + /* Compile-time custom allocator support. */ #if defined(hb_malloc_impl) \ @@ -72,6 +73,14 @@ extern "C" void hb_free_impl(void *ptr); #define calloc hb_calloc_impl #define realloc hb_realloc_impl #define free hb_free_impl + +#if defined(hb_memalign_impl +extern "C" int hb_memalign_impl(void **memptr, size_t alignment, size_t size); +#define posix_memalign hb_memalign_impl +#else +#undef HAVE_POSIX_MEMALIGN +#endif + #endif @@ -550,6 +559,10 @@ _hb_ceil_to_4 (unsigned int v) return ((v - 1) | 3) + 1; } +static inline bool _hb_ispow2 (unsigned int v) +{ + return 0 == (v & (v - 1)); +} /* @@ -1272,4 +1285,31 @@ _hb_round (double x) #endif +/* fallback for posix_memalign() */ +static inline int +_hb_memalign(void **memptr, size_t alignment, size_t size) +{ + if (unlikely (!_hb_ispow2 (alignment) || + !alignment || + 0 != (alignment & (sizeof (void *) - 1 +return EINVAL; + + char *p = (char *) malloc (size + alignment - 1); + if (unlikely (!p)) +return ENOMEM; + + size_t off = (size_t) p & (alignment - 1); + if (off) +p += alignment - off; + + *memptr = (void *) p; + + return 0; +} +#if !defined(posix_memalign) && !defined(HAVE_POSIX_MEMALIGN) +#define posix_memalign _hb_memalign +#endif + + + #endif /* HB_PRIVATE_HH */ commit 292c100d6141eb2e981fa632602d73768f748727 Author: Behdad Esfahbod Date: Tue Jul 10 13:16:52 2018 +0200 Always compile (but not use) alignof() and round() fallback codes Catches compile-errors in them better. diff --git a/src/hb-private.hh b/src/hb-private.hh index 8609e04a..48a7db10 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -78,6 +78,17 @@ extern "C" void hb_free_impl(void *ptr); /* Compiler attributes */ +template +struct _hb_alignof +{ + struct s + { +char c; +T t; + }; + static constexpr unsigned int value = offsetof (s, t); +}; + #if __cplusplus < 201103L #ifndef nullptr @@ -104,16 +115,6 @@ extern "C" void hb_free_impl(void *ptr); #ifndef alignof #define alignof(x) (_hb_alignof::value) -template -struct _hb_alignof -{ - struct s - { -char c; -T t; - }; - static constexpr unsigned int value = offsetof (s, t); -}; #endif // alignof #endif // __cplusplus < 201103L @@ -1258,7 +1259,6 @@ struct hb_bytes_t /* fallback for round() */ -#if !defined (HAVE_ROUND) && !defined (HAVE_DECL_ROUND) static inline double _hb_round (double x) { @@ -1267,6 +1267,7 @@ _hb_round (double x) else return ceil (x - 0.5); } +#if !defined (HAVE_ROUND) && !defined (HAVE_DECL_ROUND) #define round(x) _hb_round(x) #endif ___ HarfBuzz mailing list HarfBuzz@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/harfbuzz
[HarfBuzz] harfbuzz: Branch 'master' - 7 commits
CMakeLists.txt|3 +-- src/Makefile.am |8 src/gen-def.py| 12 +--- src/hb-private.hh | 18 ++ src/hb-set-private.hh |1 + 5 files changed, 33 insertions(+), 9 deletions(-) New commits: commit bca83618cda7ee4f683b4685d10db9e1bef4983c Author: Behdad Esfahbod Date: Tue Jul 10 12:58:13 2018 +0200 Add fallback implementation for constexpr and alignof diff --git a/src/hb-private.hh b/src/hb-private.hh index 5cec8e0b..6893bfd3 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -84,6 +84,10 @@ extern "C" void hb_free_impl(void *ptr); #define nullptr NULL #endif +#ifndef constexpr +#define constexpr const +#endif + // Static assertions #ifndef static_assert #define static_assert(e, msg) \ @@ -98,6 +102,20 @@ extern "C" void hb_free_impl(void *ptr); #define thread_local #endif +#ifndef alignof +#define alignof(x) _hb_alignof::value; +template +struct _hb_alignof +{ + struct s + { +char c; +T t; + }; + static constexpr unsigned int value = offsetof (s, t); +}; +#endif // alignof + #endif // __cplusplus < 201103L #if (defined(__GNUC__) || defined(__clang__)) && defined(__OPTIMIZE__) commit 7cb47d0f3f202843ebc7fb8801bf388bb90ba3aa Author: Behdad Esfahbod Date: Tue Jul 10 12:51:29 2018 +0200 Minor diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh index ccd4d8df..6841189e 100644 --- a/src/hb-set-private.hh +++ b/src/hb-set-private.hh @@ -405,6 +405,7 @@ struct hb_set_t if (get_population () > larger_set->get_population ()) return false; +/* TODO Optimize to use pages. */ hb_codepoint_t c = INVALID; while (next ()) if (!larger_set->has (c)) commit bf9e9676dda686f5b76826b4e3148f4a0b512e3c Merge: 46d8f0d5 53f73409 Author: Cosimo Lupo Date: Mon Jul 9 20:24:22 2018 +0200 Merge pull request #1091 from anthrotype/fix-gen-def-py gen-def.py: pass headers as arguments so that msys2 can convert posix paths commit 53f73409a91241765ae6a0cadf7600676988b6af Author: Cosimo Lupo Date: Mon Jul 9 18:54:23 2018 +0100 CMakeLists.txt: don't pass header args as single space-separated string let python's parse command-line args as usual diff --git a/CMakeLists.txt b/CMakeLists.txt index e0a4b881..e881dbd1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -834,9 +834,8 @@ set_target_properties(hb-ot-tag PROPERTIES COMPILE_FLAGS "-DMAIN") if (UNIX OR MINGW) if (BUILD_SHARED_LIBS) # generate harfbuzz.def after build completion -string(REPLACE ";" " " space_separated_headers "${project_headers}") add_custom_command(TARGET harfbuzz POST_BUILD - COMMAND "${PYTHON_EXECUTABLE}" ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def ${space_separated_headers} + COMMAND "${PYTHON_EXECUTABLE}" ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def ${project_headers} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src) add_test(NAME check-static-inits.sh commit 83d2233a5c47cf1feadcdece5bd4a6b498c6ee7a Author: Cosimo Lupo Date: Mon Jul 9 18:48:20 2018 +0100 CMakeLists.txt: pass headers as arguments to gen-def.py; call using PYTHON_EXECUTABLE diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ed7e56e..e0a4b881 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -836,7 +836,7 @@ if (UNIX OR MINGW) # generate harfbuzz.def after build completion string(REPLACE ";" " " space_separated_headers "${project_headers}") add_custom_command(TARGET harfbuzz POST_BUILD - COMMAND ${CMAKE_COMMAND} -E env "headers=${space_separated_headers}" python ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def + COMMAND "${PYTHON_EXECUTABLE}" ${PROJECT_SOURCE_DIR}/src/gen-def.py ${PROJECT_BINARY_DIR}/harfbuzz.def ${space_separated_headers} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src) add_test(NAME check-static-inits.sh commit ccdd15655480fe35226c0b757e28d3527fe2e6af Author: Cosimo Lupo Date: Mon Jul 9 18:26:44 2018 +0100 src/Makefile.am: pass headers to gen-def.py as arguments, not env vars diff --git a/src/Makefile.am b/src/Makefile.am index 9d5662e4..6dfec3bf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -277,13 +277,13 @@ endif check: $(DEF_FILES) # For check-symbols.sh CLEANFILES += $(DEF_FILES) harfbuzz.def: $(HBHEADERS) $(HBNODISTHEADERS) - $(AM_V_GEN) headers="$^" $(srcdir)/gen-def.py "$@" + $(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^ harfbuzz-subset.def: $(HB_SUBSET_headers) - $(AM_V_GEN) headers="$^" $(srcdir)/gen-def.py "$@" + $(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^ harfbuzz-icu.def: $(HB_ICU_headers) - $(AM_V_GEN) headers="$^" $(srcdir)/gen-def.py "$@" + $(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^ harfbuzz-gobject.def: $(HB_GOBJECT_headers) - $(AM_V_GEN) headers="$^" $(srcdir)/gen-def.py "$@" + $(AM_V_GEN) $(srcdir)/gen-def.py "$@" $^ GENERATORS = \