| Index: third_party/harfbuzz-ng/src/hb-private.hh
|
| diff --git a/third_party/harfbuzz-ng/src/hb-private.hh b/third_party/harfbuzz-ng/src/hb-private.hh
|
| index 344c71b058e5a1be93773612dbd23cb7caffc143..a451d164f91a0de224be1793e26c8c544eb9df29 100644
|
| --- a/third_party/harfbuzz-ng/src/hb-private.hh
|
| +++ b/third_party/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
|
| @@ -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
|
|
|