diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2014-07-18 03:13:19 +0300 |
---|---|---|
committer | Konstantin Ritt <ritt.ks@gmail.com> | 2014-07-20 01:12:24 +0200 |
commit | 461c2b20044359b80df8217a7565c7b8a60a1f0b (patch) | |
tree | a95666c97d87f0a9f3c02bee1fd08bcf47bcc748 /src/3rdparty/harfbuzz-ng/src/hb-private.hh | |
parent | 0078013693c96ad2d0fe7d50d4eb733df2c041ab (diff) |
Update bundled HarfBuzz-NG copy to 0.9.32
- Unicode 7.0 support
- New shapers
- Multiple improvements in Arabic, Indic, and Hebrew shapers
- Build fixes, optimizations, etc.
Change-Id: I0ba14b619c3e6fb35cddd9d65e694af41197d6ae
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src/3rdparty/harfbuzz-ng/src/hb-private.hh')
-rw-r--r-- | src/3rdparty/harfbuzz-ng/src/hb-private.hh | 186 |
1 files changed, 92 insertions, 94 deletions
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-private.hh b/src/3rdparty/harfbuzz-ng/src/hb-private.hh index 680b21e2cc..a451d164f9 100644 --- a/src/3rdparty/harfbuzz-ng/src/hb-private.hh +++ b/src/3rdparty/harfbuzz-ng/src/hb-private.hh @@ -54,23 +54,77 @@ #include <stdarg.h> +/* Compiler attributes */ -/* Essentials */ -#ifndef NULL -# define NULL ((void *) 0) +#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) +#define _HB_BOOLEAN_EXPR(expr) ((expr) ? 1 : 0) +#define likely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 1)) +#define unlikely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 0)) +#else +#define likely(expr) (expr) +#define unlikely(expr) (expr) #endif +#ifndef __GNUC__ +#undef __attribute__ +#define __attribute__(x) +#endif + +#if __GNUC__ >= 3 +#define HB_PURE_FUNC __attribute__((pure)) +#define HB_CONST_FUNC __attribute__((const)) +#define HB_PRINTF_FUNC(format_idx, arg_idx) __attribute__((__format__ (__printf__, format_idx, arg_idx))) +#else +#define HB_PURE_FUNC +#define HB_CONST_FUNC +#define HB_PRINTF_FUNC(format_idx, arg_idx) +#endif +#if __GNUC__ >= 4 +#define HB_UNUSED __attribute__((unused)) +#else +#define HB_UNUSED +#endif + +#ifndef HB_INTERNAL +# ifndef __MINGW32__ +# define HB_INTERNAL __attribute__((__visibility__("hidden"))) +# else +# define HB_INTERNAL +# endif +#endif + +#if (defined(__WIN32__) && !defined(__WINE__)) || defined(_MSC_VER) +#define snprintf _snprintf +#endif + +#ifdef _MSC_VER +#undef inline +#define inline __inline +#endif + +#ifdef __STRICT_ANSI__ +#undef inline +#define inline __inline__ +#endif + +#if __GNUC__ >= 3 +#define HB_FUNC __PRETTY_FUNCTION__ +#elif defined(_MSC_VER) +#define HB_FUNC __FUNCSIG__ +#else +#define HB_FUNC __func__ +#endif -/* Void! */ -struct _hb_void_t {}; -typedef const _hb_void_t &hb_void_t; -#define HB_VOID (* (const _hb_void_t *) NULL) /* Basics */ +#ifndef NULL +# define NULL ((void *) 0) +#endif + #undef MIN template <typename Type> static inline Type MIN (const Type &a, const Type &b) { return a < b ? a : b; } @@ -92,7 +146,7 @@ static inline unsigned int ARRAY_LENGTH (const Type (&)[n]) { return n; } #define HB_STMT_START do #define HB_STMT_END while (0) -#define _ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1] +#define _ASSERT_STATIC1(_line, _cond) HB_UNUSED typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1] #define _ASSERT_STATIC0(_line, _cond) _ASSERT_STATIC1 (_line, (_cond)) #define ASSERT_STATIC(_cond) _ASSERT_STATIC0 (__LINE__, (_cond)) @@ -139,7 +193,7 @@ ASSERT_STATIC (sizeof (hb_var_int_t) == 4); /* Check _assertion in a method environment */ #define _ASSERT_POD1(_line) \ - inline void _static_assertion_on_line_##_line (void) const \ + HB_UNUSED inline void _static_assertion_on_line_##_line (void) const \ { _ASSERT_INSTANCE_POD1 (_line, *this); /* Make sure it's POD. */ } # define _ASSERT_POD0(_line) _ASSERT_POD1 (_line) # define ASSERT_POD() _ASSERT_POD0 (__LINE__) @@ -148,68 +202,10 @@ ASSERT_STATIC (sizeof (hb_var_int_t) == 4); /* Misc */ - -#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__) -#define _HB_BOOLEAN_EXPR(expr) ((expr) ? 1 : 0) -#define likely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 1)) -#define unlikely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 0)) -#else -#define likely(expr) (expr) -#define unlikely(expr) (expr) -#endif - -#ifndef __GNUC__ -#undef __attribute__ -#define __attribute__(x) -#endif - -#if __GNUC__ >= 3 -#define HB_PURE_FUNC __attribute__((pure)) -#define HB_CONST_FUNC __attribute__((const)) -#define HB_PRINTF_FUNC(format_idx, arg_idx) __attribute__((__format__ (__printf__, format_idx, arg_idx))) -#else -#define HB_PURE_FUNC -#define HB_CONST_FUNC -#define HB_PRINTF_FUNC(format_idx, arg_idx) -#endif -#if __GNUC__ >= 4 -#define HB_UNUSED __attribute__((unused)) -#else -#define HB_UNUSED -#endif - -#ifndef HB_INTERNAL -# ifndef __MINGW32__ -# define HB_INTERNAL __attribute__((__visibility__("hidden"))) -# else -# define HB_INTERNAL -# endif -#endif - - -#if (defined(__WIN32__) && !defined(__WINE__)) || defined(_MSC_VER) -#define snprintf _snprintf -#endif - -#ifdef _MSC_VER -#undef inline -#define inline __inline -#endif - -#ifdef __STRICT_ANSI__ -#undef inline -#define inline __inline__ -#endif - - -#if __GNUC__ >= 3 -#define HB_FUNC __PRETTY_FUNCTION__ -#elif defined(_MSC_VER) -#define HB_FUNC __FUNCSIG__ -#else -#define HB_FUNC __func__ -#endif - +/* Void! */ +struct _hb_void_t {}; +typedef const _hb_void_t &hb_void_t; +#define HB_VOID (* (const _hb_void_t *) NULL) /* Return the number of 1 bits in mask. */ static inline HB_CONST_FUNC unsigned int @@ -219,7 +215,7 @@ _hb_popcount32 (uint32_t mask) return __builtin_popcount (mask); #else /* "HACKMEM 169" */ - register uint32_t y; + uint32_t y; y = (mask >> 1) &033333333333; y = mask - y - ((y >>1) & 033333333333); return (((y + (y >> 3)) & 030707070707) % 077); @@ -233,7 +229,7 @@ _hb_bit_storage (unsigned int number) #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__) return likely (number) ? (sizeof (unsigned int) * 8 - __builtin_clz (number)) : 0; #else - register unsigned int n_bits = 0; + unsigned int n_bits = 0; while (number) { n_bits++; number >>= 1; @@ -249,7 +245,7 @@ _hb_ctz (unsigned int number) #if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__) return likely (number) ? __builtin_ctz (number) : 0; #else - register unsigned int n_bits = 0; + unsigned int n_bits = 0; if (unlikely (!number)) return 0; while (!(number & 1)) { n_bits++; @@ -276,7 +272,7 @@ typedef int (*hb_compare_func_t) (const void *, const void *); #define HB_PREALLOCED_ARRAY_INIT {0} -template <typename Type, unsigned int StaticSize> +template <typename Type, unsigned int StaticSize=16> struct hb_prealloced_array_t { unsigned int len; @@ -357,14 +353,14 @@ struct hb_prealloced_array_t return NULL; } - inline void sort (void) + inline void qsort (void) { - qsort (array, len, sizeof (Type), (hb_compare_func_t) Type::cmp); + ::qsort (array, len, sizeof (Type), (hb_compare_func_t) Type::cmp); } - inline void sort (unsigned int start, unsigned int end) + inline void qsort (unsigned int start, unsigned int end) { - qsort (array + start, end - start, sizeof (Type), (hb_compare_func_t) Type::cmp); + ::qsort (array + start, end - start, sizeof (Type), (hb_compare_func_t) Type::cmp); } template <typename T> @@ -387,12 +383,11 @@ struct hb_prealloced_array_t } }; -#define HB_AUTO_ARRAY_PREALLOCED 16 template <typename Type> -struct hb_auto_array_t : hb_prealloced_array_t <Type, HB_AUTO_ARRAY_PREALLOCED> +struct hb_auto_array_t : hb_prealloced_array_t <Type> { - hb_auto_array_t (void) { hb_prealloced_array_t<Type, HB_AUTO_ARRAY_PREALLOCED>::init (); } - ~hb_auto_array_t (void) { hb_prealloced_array_t<Type, HB_AUTO_ARRAY_PREALLOCED>::finish (); } + hb_auto_array_t (void) { hb_prealloced_array_t<Type>::init (); } + ~hb_auto_array_t (void) { hb_prealloced_array_t<Type>::finish (); } }; @@ -725,7 +720,7 @@ static inline void _hb_warn_no_return (bool returned) } } template <> -inline void _hb_warn_no_return<hb_void_t> (bool returned HB_UNUSED) +/*static*/ inline void _hb_warn_no_return<hb_void_t> (bool returned HB_UNUSED) {} template <int max_level, typename ret_t> @@ -791,20 +786,23 @@ struct hb_auto_trace_t<0, ret_t> { /* Misc */ +template <typename T> class hb_assert_unsigned_t; +template <> class hb_assert_unsigned_t<unsigned char> {}; +template <> class hb_assert_unsigned_t<unsigned short> {}; +template <> class hb_assert_unsigned_t<unsigned int> {}; +template <> class hb_assert_unsigned_t<unsigned long> {}; -/* Pre-mature optimization: - * Checks for lo <= u <= hi but with an optimization if lo and hi - * are only different in a contiguous set of lower-most bits. - */ template <typename T> static inline bool hb_in_range (T u, T lo, T hi) { - if ( ((lo^hi) & lo) == 0 && - ((lo^hi) & hi) == (lo^hi) && - ((lo^hi) & ((lo^hi) + 1)) == 0 ) - return (u & ~(lo^hi)) == lo; - else - return lo <= u && u <= hi; + /* The sizeof() is here to force template instantiation. + * I'm sure there are better ways to do this but can't think of + * one right now. Declaring a variable won't work as HB_UNUSED + * is unsable on some platforms and unused types are less likely + * to generate a warning than unused variables. */ + ASSERT_STATIC (sizeof (hb_assert_unsigned_t<T>) >= 0); + + return (u - lo) <= (hi - lo); } template <typename T> static inline bool |