Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(931)

Side by Side Diff: third_party/harfbuzz-ng/src/hb-private.hh

Issue 475363002: Roll HarfBuzz to 0.9.35 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Windows build fix attempt Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright © 2007,2008,2009 Red Hat, Inc. 2 * Copyright © 2007,2008,2009 Red Hat, Inc.
3 * Copyright © 2011,2012 Google, Inc. 3 * Copyright © 2011,2012 Google, Inc.
4 * 4 *
5 * This is part of HarfBuzz, a text shaping library. 5 * This is part of HarfBuzz, a text shaping library.
6 * 6 *
7 * Permission is hereby granted, without written agreement and without 7 * Permission is hereby granted, without written agreement and without
8 * license or royalty fees, to use, copy, modify, and distribute this 8 * license or royalty fees, to use, copy, modify, and distribute this
9 * software and its documentation for any purpose, provided that the 9 * software and its documentation for any purpose, provided that the
10 * above copyright notice and the following two paragraphs appear in 10 * above copyright notice and the following two paragraphs appear in
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 #define HB_CONST_FUNC 80 #define HB_CONST_FUNC
81 #define HB_PRINTF_FUNC(format_idx, arg_idx) 81 #define HB_PRINTF_FUNC(format_idx, arg_idx)
82 #endif 82 #endif
83 #if __GNUC__ >= 4 83 #if __GNUC__ >= 4
84 #define HB_UNUSED __attribute__((unused)) 84 #define HB_UNUSED __attribute__((unused))
85 #else 85 #else
86 #define HB_UNUSED 86 #define HB_UNUSED
87 #endif 87 #endif
88 88
89 #ifndef HB_INTERNAL 89 #ifndef HB_INTERNAL
90 # ifndef __MINGW32__ 90 # if !defined(__MINGW32__) && !defined(__CYGWIN__)
91 # define HB_INTERNAL __attribute__((__visibility__("hidden"))) 91 # define HB_INTERNAL __attribute__((__visibility__("hidden")))
92 # else 92 # else
93 # define HB_INTERNAL 93 # define HB_INTERNAL
94 # endif 94 # endif
95 #endif 95 #endif
96 96
97 #if (defined(__WIN32__) && !defined(__WINE__)) || defined(_MSC_VER) 97 #if (defined(__WIN32__) && !defined(__WINE__)) || defined(_MSC_VER)
98 #define snprintf _snprintf 98 #define snprintf _snprintf
99 /* Windows CE only has _strdup, while rest of Windows has both. */
100 #define strdup _strdup
99 #endif 101 #endif
100 102
101 #ifdef _MSC_VER 103 #ifdef _MSC_VER
102 #undef inline 104 #undef inline
103 #define inline __inline 105 #define inline __inline
104 #endif 106 #endif
105 107
106 #ifdef __STRICT_ANSI__ 108 #ifdef __STRICT_ANSI__
107 #undef inline 109 #undef inline
108 #define inline __inline__ 110 #define inline __inline__
109 #endif 111 #endif
110 112
111 #if __GNUC__ >= 3 113 #if __GNUC__ >= 3
112 #define HB_FUNC __PRETTY_FUNCTION__ 114 #define HB_FUNC __PRETTY_FUNCTION__
113 #elif defined(_MSC_VER) 115 #elif defined(_MSC_VER)
114 #define HB_FUNC __FUNCSIG__ 116 #define HB_FUNC __FUNCSIG__
115 #else 117 #else
116 #define HB_FUNC __func__ 118 #define HB_FUNC __func__
117 #endif 119 #endif
118 120
121 #if defined(_WIN32) || defined(__CYGWIN__)
122 /* We need Windows Vista for both Uniscribe backend and for
123 * MemoryBarrier. We don't support compiling on Windows XP,
124 * though we run on it fine. */
125 # if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600
126 # undef _WIN32_WINNT
127 # endif
128 # ifndef _WIN32_WINNT
129 # define _WIN32_WINNT 0x0600
130 # endif
131 # ifndef WIN32_LEAN_AND_MEAN
132 # define WIN32_LEAN_AND_MEAN
133 # endif
134 # define STRICT
135 #endif
119 136
137 #ifdef _WIN32_WCE
138 /* Some things not defined on Windows CE. */
139 #define MemoryBarrier()
140 #define getenv(Name) NULL
141 #define setlocale(Category, Locale) "C"
142 static int errno = 0; /* Use something better? */
143 #endif
144
145 #if HAVE_ATEXIT
146 /* atexit() is only safe to be called from shared libraries on certain
147 * platforms. Whitelist.
148 * https://bugs.freedesktop.org/show_bug.cgi?id=82246 */
149 # if defined(__linux) && defined(__GLIBC_PREREQ)
150 # if __GLIBC_PREREQ(2,3)
151 /* From atexit() manpage, it's safe with glibc 2.2.3 on Linux. */
152 # define HB_USE_ATEXIT 1
153 # endif
154 # elif defined(_MSC_VER) || defined(__MINGW32__)
155 /* For MSVC:
156 * http://msdn.microsoft.com/en-ca/library/tze57ck3.aspx
157 * http://msdn.microsoft.com/en-ca/library/zk17ww08.aspx
158 * mingw32 headers say atexit is safe to use in shared libraries.
159 */
160 # define HB_USE_ATEXIT 1
161 # elif defined(__ANDROID__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR_ _ >= 6))
162 /* This was fixed in Android NKD r8 or r8b:
163 * https://code.google.com/p/android/issues/detail?id=6455
164 * which introduced GCC 4.6:
165 * https://developer.android.com/tools/sdk/ndk/index.html
166 */
167 # define HB_USE_ATEXIT 1
168 # endif
169 #endif
120 170
121 /* Basics */ 171 /* Basics */
122 172
123 173
124 #ifndef NULL 174 #ifndef NULL
125 # define NULL ((void *) 0) 175 # define NULL ((void *) 0)
126 #endif 176 #endif
127 177
128 #undef MIN 178 #undef MIN
129 template <typename Type> 179 template <typename Type>
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 314
265 /* Type of bsearch() / qsort() compare function */ 315 /* Type of bsearch() / qsort() compare function */
266 typedef int (*hb_compare_func_t) (const void *, const void *); 316 typedef int (*hb_compare_func_t) (const void *, const void *);
267 317
268 318
269 319
270 320
271 /* arrays and maps */ 321 /* arrays and maps */
272 322
273 323
274 #define HB_PREALLOCED_ARRAY_INIT {0} 324 #define HB_PREALLOCED_ARRAY_INIT {0, 0, NULL}
275 template <typename Type, unsigned int StaticSize=16> 325 template <typename Type, unsigned int StaticSize=16>
276 struct hb_prealloced_array_t 326 struct hb_prealloced_array_t
277 { 327 {
278 unsigned int len; 328 unsigned int len;
279 unsigned int allocated; 329 unsigned int allocated;
280 Type *array; 330 Type *array;
281 Type static_array[StaticSize]; 331 Type static_array[StaticSize];
282 332
283 void init (void) { memset (this, 0, sizeof (*this)); } 333 void init (void) { memset (this, 0, sizeof (*this)); }
284 334
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 #define DEBUG_ENABLED(WHAT) (DEBUG_LEVEL_ENABLED (WHAT, 0)) 623 #define DEBUG_ENABLED(WHAT) (DEBUG_LEVEL_ENABLED (WHAT, 0))
574 624
575 template <int max_level> static inline void 625 template <int max_level> static inline void
576 _hb_debug_msg_va (const char *what, 626 _hb_debug_msg_va (const char *what,
577 const void *obj, 627 const void *obj,
578 const char *func, 628 const char *func,
579 bool indented, 629 bool indented,
580 unsigned int level, 630 unsigned int level,
581 int level_dir, 631 int level_dir,
582 const char *message, 632 const char *message,
633 va_list ap) HB_PRINTF_FUNC(7, 0);
634 template <int max_level> static inline void
635 _hb_debug_msg_va (const char *what,
636 const void *obj,
637 const char *func,
638 bool indented,
639 unsigned int level,
640 int level_dir,
641 const char *message,
583 va_list ap) 642 va_list ap)
584 { 643 {
585 if (!_hb_debug (level, max_level)) 644 if (!_hb_debug (level, max_level))
586 return; 645 return;
587 646
588 fprintf (stderr, "%-10s", what ? what : ""); 647 fprintf (stderr, "%-10s", what ? what : "");
589 648
590 if (obj) 649 if (obj)
591 fprintf (stderr, "(%0*lx) ", (unsigned int) (2 * sizeof (void *)), (unsigned long) obj); 650 fprintf (stderr, "(%0*lx) ", (unsigned int) (2 * sizeof (void *)), (unsigned long) obj);
592 else 651 else
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 template <typename T> static inline bool 854 template <typename T> static inline bool
796 hb_in_range (T u, T lo, T hi) 855 hb_in_range (T u, T lo, T hi)
797 { 856 {
798 /* The sizeof() is here to force template instantiation. 857 /* The sizeof() is here to force template instantiation.
799 * I'm sure there are better ways to do this but can't think of 858 * I'm sure there are better ways to do this but can't think of
800 * one right now. Declaring a variable won't work as HB_UNUSED 859 * one right now. Declaring a variable won't work as HB_UNUSED
801 * is unsable on some platforms and unused types are less likely 860 * is unsable on some platforms and unused types are less likely
802 * to generate a warning than unused variables. */ 861 * to generate a warning than unused variables. */
803 ASSERT_STATIC (sizeof (hb_assert_unsigned_t<T>) >= 0); 862 ASSERT_STATIC (sizeof (hb_assert_unsigned_t<T>) >= 0);
804 863
805 return (u - lo) <= (hi - lo); 864 /* The casts below are important as if T is smaller than int,
865 * the subtract results will become a signed int! */
866 return (T)(u - lo) <= (T)(hi - lo);
806 } 867 }
807 868
808 template <typename T> static inline bool 869 template <typename T> static inline bool
809 hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2) 870 hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2)
810 { 871 {
811 return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2); 872 return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2);
812 } 873 }
813 874
814 template <typename T> static inline bool 875 template <typename T> static inline bool
815 hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3) 876 hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 hb_options (void) 968 hb_options (void)
908 { 969 {
909 if (unlikely (!_hb_options.i)) 970 if (unlikely (!_hb_options.i))
910 _hb_options_init (); 971 _hb_options_init ();
911 972
912 return _hb_options.opts; 973 return _hb_options.opts;
913 } 974 }
914 975
915 976
916 #endif /* HB_PRIVATE_HH */ 977 #endif /* HB_PRIVATE_HH */
OLDNEW
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-ot-shape-normalize.cc ('k') | third_party/harfbuzz-ng/src/hb-shape.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698