hb.hh (18542B)
1 /* 2 * Copyright © 2007,2008,2009 Red Hat, Inc. 3 * Copyright © 2011,2012 Google, Inc. 4 * 5 * This is part of HarfBuzz, a text shaping library. 6 * 7 * Permission is hereby granted, without written agreement and without 8 * license or royalty fees, to use, copy, modify, and distribute this 9 * software and its documentation for any purpose, provided that the 10 * above copyright notice and the following two paragraphs appear in 11 * all copies of this software. 12 * 13 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR 14 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 15 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN 16 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 17 * DAMAGE. 18 * 19 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, 20 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 21 * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 22 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO 23 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. 24 * 25 * Red Hat Author(s): Behdad Esfahbod 26 * Google Author(s): Behdad Esfahbod 27 */ 28 29 #ifndef HB_HH 30 #define HB_HH 31 32 #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC 33 #ifdef _MSC_VER 34 #pragma warning( disable: 4068 ) /* Unknown pragma */ 35 #endif 36 #if defined(__GNUC__) || defined(__clang__) 37 /* Rules: 38 * 39 * - All pragmas are declared GCC even if they are clang ones. Otherwise GCC 40 * nags, even though we instruct it to ignore -Wunknown-pragmas. ¯\_(ツ)_/¯ 41 * 42 * - Within each category, keep sorted. 43 * 44 * - Warnings whose scope can be expanded in future compiler versions shall 45 * be declared as "warning". Otherwise, either ignored or error. 46 */ 47 48 /* Setup. Don't sort order within this category. */ 49 #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_WARNING 50 #pragma GCC diagnostic warning "-Wall" 51 #pragma GCC diagnostic warning "-Wextra" 52 #endif 53 #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_IGNORED 54 #pragma GCC diagnostic ignored "-Wpragmas" 55 #pragma GCC diagnostic ignored "-Wunknown-pragmas" 56 #pragma GCC diagnostic ignored "-Wunknown-warning-option" 57 #endif 58 #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_WARNING 59 //#pragma GCC diagnostic warning "-Weverything" 60 #endif 61 62 /* Error. Should never happen. */ 63 #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR 64 #pragma GCC diagnostic error "-Wbitwise-instead-of-logical" 65 #pragma GCC diagnostic error "-Wcast-align" 66 #pragma GCC diagnostic error "-Wcast-function-type" 67 #pragma GCC diagnostic error "-Wcast-function-type-strict" 68 #pragma GCC diagnostic error "-Wconstant-conversion" 69 #pragma GCC diagnostic error "-Wcomma" 70 #pragma GCC diagnostic error "-Wdelete-non-virtual-dtor" 71 #pragma GCC diagnostic error "-Wembedded-directive" 72 #pragma GCC diagnostic error "-Wextra-semi-stmt" 73 #pragma GCC diagnostic error "-Wformat-security" 74 #pragma GCC diagnostic error "-Wimplicit-function-declaration" 75 #pragma GCC diagnostic error "-Winit-self" 76 #pragma GCC diagnostic error "-Winjected-class-name" 77 #pragma GCC diagnostic error "-Wmissing-braces" 78 #pragma GCC diagnostic error "-Wmissing-declarations" 79 #pragma GCC diagnostic error "-Wmissing-prototypes" 80 #pragma GCC diagnostic error "-Wnarrowing" 81 #pragma GCC diagnostic error "-Wnested-externs" 82 #pragma GCC diagnostic error "-Wold-style-definition" 83 #pragma GCC diagnostic error "-Wpointer-arith" 84 #pragma GCC diagnostic error "-Wredundant-decls" 85 #pragma GCC diagnostic error "-Wreorder" 86 #pragma GCC diagnostic error "-Wsign-compare" 87 #pragma GCC diagnostic error "-Wstrict-flex-arrays" 88 #pragma GCC diagnostic error "-Wstrict-prototypes" 89 #pragma GCC diagnostic error "-Wstring-conversion" 90 #pragma GCC diagnostic error "-Wswitch-enum" 91 #pragma GCC diagnostic error "-Wtautological-overlap-compare" 92 #pragma GCC diagnostic error "-Wunneeded-internal-declaration" 93 #pragma GCC diagnostic error "-Wunused" 94 #pragma GCC diagnostic error "-Wunused-local-typedefs" 95 #pragma GCC diagnostic error "-Wunused-value" 96 #pragma GCC diagnostic error "-Wunused-variable" 97 #pragma GCC diagnostic error "-Wvla" 98 #pragma GCC diagnostic error "-Wwrite-strings" 99 #endif 100 101 /* Warning. To be investigated if happens. */ 102 #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_WARNING 103 #pragma GCC diagnostic warning "-Wbuiltin-macro-redefined" 104 #pragma GCC diagnostic warning "-Wdeprecated" 105 #pragma GCC diagnostic warning "-Wdeprecated-declarations" 106 #pragma GCC diagnostic warning "-Wdisabled-optimization" 107 #pragma GCC diagnostic warning "-Wdouble-promotion" 108 #pragma GCC diagnostic warning "-Wformat=2" 109 #pragma GCC diagnostic warning "-Wformat-signedness" 110 #pragma GCC diagnostic warning "-Wignored-pragma-optimize" 111 #pragma GCC diagnostic warning "-Wlogical-op" 112 #pragma GCC diagnostic warning "-Wmissing-format-attribute" 113 #pragma GCC diagnostic warning "-Wpessimizing-move" 114 #pragma GCC diagnostic warning "-Wundef" 115 #pragma GCC diagnostic warning "-Wunsafe-loop-optimizations" 116 #pragma GCC diagnostic warning "-Wunused-but-set-variable" 117 #ifdef __clang__ 118 // The following are too buggy on gcc 119 // https://github.com/harfbuzz/harfbuzz/issues/5589 120 // https://github.com/harfbuzz/harfbuzz/pull/5367 121 #pragma GCC diagnostic warning "-Wmaybe-uninitialized" 122 #pragma GCC diagnostic warning "-Wuninitialized" 123 #else 124 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" 125 #pragma GCC diagnostic ignored "-Wuninitialized" 126 #endif 127 #endif 128 129 /* Ignored currently, but should be fixed at some point. */ 130 #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_IGNORED 131 #pragma GCC diagnostic ignored "-Wconversion" // TODO fix 132 #pragma GCC diagnostic ignored "-Wshadow" // TODO fix 133 #pragma GCC diagnostic ignored "-Wunused-parameter" // TODO fix 134 #if defined(__GNUC__) && !defined(__clang__) 135 #pragma GCC diagnostic ignored "-Wunused-result" // TODO fix 136 #endif 137 #endif 138 139 /* Ignored intentionally. */ 140 #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_IGNORED 141 #pragma GCC diagnostic ignored "-Wclass-memaccess" 142 #pragma GCC diagnostic ignored "-Wcast-function-type-strict" // https://github.com/harfbuzz/harfbuzz/pull/3859#issuecomment-1295409126 143 #pragma GCC diagnostic ignored "-Wdangling-reference" // https://github.com/harfbuzz/harfbuzz/issues/4043 144 #pragma GCC diagnostic ignored "-Wdangling-pointer" // Trigerred by hb_decycler_node_t(). 145 #pragma GCC diagnostic ignored "-Wformat-nonliteral" 146 #pragma GCC diagnostic ignored "-Wformat-zero-length" 147 #pragma GCC diagnostic ignored "-Wmissing-field-initializers" 148 #pragma GCC diagnostic ignored "-Wold-style-cast" 149 #pragma GCC diagnostic ignored "-Wpacked" // Erratic impl in clang 150 #pragma GCC diagnostic ignored "-Wrange-loop-analysis" // https://github.com/harfbuzz/harfbuzz/issues/2834 151 #pragma GCC diagnostic ignored "-Wstrict-aliasing" 152 #pragma GCC diagnostic ignored "-Wtype-limits" 153 #pragma GCC diagnostic ignored "-Wc++11-compat" // only gcc raises it 154 #endif 155 156 #endif 157 #endif 158 159 160 #include "hb-config.hh" 161 #include "hb-limits.hh" 162 163 164 /* 165 * Following added based on what AC_USE_SYSTEM_EXTENSIONS adds to 166 * config.h.in. Copied here for the convenience of those embedding 167 * HarfBuzz and not using our build system. 168 */ 169 /* Enable extensions on AIX 3, Interix. */ 170 #ifndef _ALL_SOURCE 171 # define _ALL_SOURCE 1 172 #endif 173 /* Enable GNU extensions on systems that have them. */ 174 #ifndef _GNU_SOURCE 175 # define _GNU_SOURCE 1 176 #endif 177 /* Enable threading extensions on Solaris. */ 178 #ifndef _POSIX_PTHREAD_SEMANTICS 179 # define _POSIX_PTHREAD_SEMANTICS 1 180 #endif 181 /* Enable extensions on HP NonStop. */ 182 #ifndef _TANDEM_SOURCE 183 # define _TANDEM_SOURCE 1 184 #endif 185 /* Enable general extensions on Solaris. */ 186 #ifndef __EXTENSIONS__ 187 # define __EXTENSIONS__ 1 188 #endif 189 190 #if defined (_MSC_VER) && defined (HB_DLL_EXPORT) 191 #define HB_EXTERN __declspec (dllexport) extern 192 #endif 193 194 // https://github.com/harfbuzz/harfbuzz/pull/4619 195 #ifndef __STDC_FORMAT_MACROS 196 #define __STDC_FORMAT_MACROS 1 197 #endif 198 199 #include "hb.h" 200 #define HB_H_IN 201 #include "hb-ot.h" 202 #define HB_OT_H_IN 203 #include "hb-aat.h" 204 #define HB_AAT_H_IN 205 206 #include <cassert> 207 #include <cfloat> 208 #include <climits> 209 #if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES) 210 # define _USE_MATH_DEFINES 211 #endif 212 #include <cmath> 213 #include <cstdarg> 214 #include <cstddef> 215 #include <cstdio> 216 #include <cstdlib> 217 #include <cstring> 218 219 #if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__) 220 #ifdef __MINGW32_VERSION 221 #ifndef WIN32_LEAN_AND_MEAN 222 #define WIN32_LEAN_AND_MEAN 1 223 #endif 224 #else 225 #include <intrin.h> 226 #endif 227 #endif 228 229 #ifdef _WIN32 230 #include <windows.h> 231 #include <winapifamily.h> 232 #endif 233 234 #ifndef PRId32 235 # define PRId32 "d" 236 # define PRIu32 "u" 237 # define PRIx32 "x" 238 #endif 239 240 #define HB_PASTE1(a,b) a##b 241 #define HB_PASTE(a,b) HB_PASTE1(a,b) 242 243 244 /* 245 * Compiler attributes 246 */ 247 248 // gcc 10 has __has_builtin but not earlier versions. Sanction any gcc >= 5 249 // clang defines it so no need. 250 #ifdef __has_builtin 251 #define hb_has_builtin __has_builtin 252 #elif defined(_MSC_VER) 253 #define hb_has_builtin(x) 0 254 #else 255 #define hb_has_builtin(x) ((defined(__GNUC__) && __GNUC__ >= 5)) 256 #endif 257 258 #if defined(__OPTIMIZE__) && hb_has_builtin(__builtin_expect) 259 #define likely(expr) __builtin_expect (bool(expr), 1) 260 #define unlikely(expr) __builtin_expect (bool(expr), 0) 261 #else 262 #define likely(expr) (expr) 263 #define unlikely(expr) (expr) 264 #endif 265 266 #if !defined(__GNUC__) && !defined(__clang__) 267 #undef __attribute__ 268 #define __attribute__(x) 269 #endif 270 271 #if defined(__MINGW32__) && (__GNUC__ >= 3) && !defined(__clang__) 272 #define HB_PRINTF_FUNC(format_idx, arg_idx) __attribute__((__format__ (gnu_printf, format_idx, arg_idx))) 273 #elif defined(__GNUC__) && (__GNUC__ >= 3) 274 #define HB_PRINTF_FUNC(format_idx, arg_idx) __attribute__((__format__ (__printf__, format_idx, arg_idx))) 275 #else 276 #define HB_PRINTF_FUNC(format_idx, arg_idx) 277 #endif 278 #if defined(__GNUC__) && (__GNUC__ >= 4) || (__clang__) 279 #define HB_UNUSED __attribute__((unused)) 280 #elif defined(_MSC_VER) /* https://github.com/harfbuzz/harfbuzz/issues/635 */ 281 #define HB_UNUSED __pragma(warning(suppress: 4100 4101)) 282 #else 283 #define HB_UNUSED 284 #endif 285 286 #ifndef HB_INTERNAL 287 # if !defined(HB_NO_VISIBILITY) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_MSC_VER) && !defined(__SUNPRO_CC) 288 # define HB_INTERNAL __attribute__((__visibility__("hidden"))) 289 # elif defined(__MINGW32__) 290 /* We use -export-symbols on mingw32, since it does not support visibility attributes. */ 291 # define HB_INTERNAL 292 # elif defined (_MSC_VER) && defined (HB_DLL_EXPORT) 293 /* We do not try to export internal symbols on Visual Studio */ 294 # define HB_INTERNAL 295 #else 296 # define HB_INTERNAL 297 # define HB_NO_VISIBILITY 1 298 # endif 299 #endif 300 301 /* https://github.com/harfbuzz/harfbuzz/issues/1651 */ 302 #if defined(__clang__) && __clang_major__ < 10 303 #define static_const static 304 #else 305 #define static_const static const 306 #endif 307 308 #if defined(__GNUC__) && (__GNUC__ >= 3) 309 #define HB_FUNC __PRETTY_FUNCTION__ 310 #elif defined(_MSC_VER) 311 #define HB_FUNC __FUNCSIG__ 312 #else 313 #define HB_FUNC __func__ 314 #endif 315 316 #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140) 317 /* https://github.com/harfbuzz/harfbuzz/issues/630 */ 318 #define __restrict 319 #endif 320 321 #ifndef HB_ALWAYS_INLINE 322 #if defined(_MSC_VER) 323 #define HB_ALWAYS_INLINE __forceinline 324 #else 325 #define HB_ALWAYS_INLINE __attribute__((always_inline)) inline 326 #endif 327 #endif 328 329 #ifndef HB_HOT 330 #define HB_HOT __attribute__((hot)) 331 #endif 332 333 /* 334 * Borrowed from https://bugzilla.mozilla.org/show_bug.cgi?id=1215411 335 * HB_FALLTHROUGH is an annotation to suppress compiler warnings about switch 336 * cases that fall through without a break or return statement. HB_FALLTHROUGH 337 * is only needed on cases that have code: 338 * 339 * switch (foo) { 340 * case 1: // These cases have no code. No fallthrough annotations are needed. 341 * case 2: 342 * case 3: 343 * foo = 4; // This case has code, so a fallthrough annotation is needed: 344 * HB_FALLTHROUGH; 345 * default: 346 * return foo; 347 * } 348 */ 349 #if defined(__clang__) && __cplusplus >= 201103L 350 /* clang's fallthrough annotations are only available starting in C++11. */ 351 # define HB_FALLTHROUGH [[clang::fallthrough]] 352 #elif defined(__GNUC__) && (__GNUC__ >= 7) 353 /* GNU fallthrough attribute is available from GCC7 */ 354 # define HB_FALLTHROUGH __attribute__((fallthrough)) 355 #elif defined(_MSC_VER) 356 /* 357 * MSVC's __fallthrough annotations are checked by /analyze (Code Analysis): 358 * https://msdn.microsoft.com/en-us/library/ms235402%28VS.80%29.aspx 359 */ 360 # include <sal.h> 361 # define HB_FALLTHROUGH __fallthrough 362 #else 363 # define HB_FALLTHROUGH /* FALLTHROUGH */ 364 #endif 365 366 /* A tag to enforce use of return value for a function */ 367 #if __cplusplus >= 201703L 368 # define HB_NODISCARD [[nodiscard]] 369 #elif defined(__GNUC__) || defined(__clang__) 370 # define HB_NODISCARD __attribute__((warn_unused_result)) 371 #elif defined(_MSC_VER) 372 # define HB_NODISCARD _Check_return_ 373 #else 374 # define HB_NODISCARD 375 #endif 376 377 /* https://github.com/harfbuzz/harfbuzz/issues/1852 */ 378 #if defined(__clang__) && !(defined(_AIX) && (defined(__IBMCPP__) || defined(__ibmxl__))) 379 /* Disable certain sanitizer errors. */ 380 /* https://github.com/harfbuzz/harfbuzz/issues/1247 */ 381 #define HB_NO_SANITIZE_SIGNED_INTEGER_OVERFLOW __attribute__((no_sanitize("signed-integer-overflow"))) 382 #else 383 #define HB_NO_SANITIZE_SIGNED_INTEGER_OVERFLOW 384 #endif 385 386 387 #ifdef _WIN32 388 /* We need Windows Vista for both Uniscribe backend and for 389 * MemoryBarrier. We don't support compiling on Windows XP, 390 * though we run on it fine. */ 391 # if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600 392 # undef _WIN32_WINNT 393 # endif 394 # ifndef _WIN32_WINNT 395 # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 396 # define _WIN32_WINNT 0x0600 397 # endif 398 # endif 399 # ifndef WIN32_LEAN_AND_MEAN 400 # define WIN32_LEAN_AND_MEAN 1 401 # endif 402 # ifndef STRICT 403 # define STRICT 1 404 # endif 405 406 # if defined(_WIN32_WCE) 407 /* Some things not defined on Windows CE. */ 408 # define vsnprintf _vsnprintf 409 # ifndef HB_NO_GETENV 410 # define HB_NO_GETENV 411 # endif 412 # if _WIN32_WCE < 0x800 413 # define HB_NO_SETLOCALE 414 # define HB_NO_ERRNO 415 # endif 416 # elif !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 417 # ifndef HB_NO_GETENV 418 # define HB_NO_GETENV 419 # endif 420 # endif 421 # if defined(_MSC_VER) && _MSC_VER < 1900 422 # define snprintf _snprintf 423 # endif 424 #endif 425 426 #ifdef HB_NO_GETENV 427 #define getenv(Name) nullptr 428 #endif 429 430 #ifndef HB_NO_ERRNO 431 # include <cerrno> 432 #else 433 static int HB_UNUSED _hb_errno = 0; 434 # undef errno 435 # define errno _hb_errno 436 #endif 437 438 #define HB_STMT_START do 439 #define HB_STMT_END while (0) 440 441 #if defined(HAVE_ATEXIT) && !defined(HB_USE_ATEXIT) 442 /* atexit() is only safe to be called from shared libraries on certain 443 * platforms. Whitelist. 444 * https://bugs.freedesktop.org/show_bug.cgi?id=82246 */ 445 # if defined(__linux) && defined(__GLIBC_PREREQ) 446 # if __GLIBC_PREREQ(2,3) 447 /* From atexit() manpage, it's safe with glibc 2.2.3 on Linux. */ 448 # define HB_USE_ATEXIT 1 449 # endif 450 # elif defined(_MSC_VER) || defined(__MINGW32__) 451 /* For MSVC: 452 * https://msdn.microsoft.com/en-us/library/tze57ck3.aspx 453 * https://msdn.microsoft.com/en-us/library/zk17ww08.aspx 454 * mingw32 headers say atexit is safe to use in shared libraries. 455 */ 456 # define HB_USE_ATEXIT 1 457 # elif defined(__ANDROID__) 458 /* This is available since Android NKD r8 or r8b: 459 * https://issuetracker.google.com/code/p/android/issues/detail?id=6455 460 */ 461 # define HB_USE_ATEXIT 1 462 # elif defined(__APPLE__) 463 /* For macOS and related platforms, the atexit man page indicates 464 * that it will be invoked when the library is unloaded, not only 465 * at application exit. 466 */ 467 # define HB_USE_ATEXIT 1 468 # endif 469 #endif /* defined(HAVE_ATEXIT) && !defined(HB_USE_ATEXIT) */ 470 #ifdef HB_NO_ATEXIT 471 # undef HB_USE_ATEXIT 472 #endif 473 #ifndef HB_USE_ATEXIT 474 # define HB_USE_ATEXIT 0 475 #endif 476 #ifndef hb_atexit 477 #if !HB_USE_ATEXIT 478 # define hb_atexit(_) HB_STMT_START { if (0) (_) (); } HB_STMT_END 479 #else /* HB_USE_ATEXIT */ 480 # ifdef HAVE_ATEXIT 481 # define hb_atexit atexit 482 # else 483 template <void (*function) (void)> struct hb_atexit_t { ~hb_atexit_t () { function (); } }; 484 # define hb_atexit(f) static hb_atexit_t<f> _hb_atexit_##__LINE__ 485 # endif 486 #endif 487 #endif 488 489 490 // Locale business 491 492 #if !defined(HB_NO_SETLOCALE) && (!defined(HAVE_NEWLOCALE) || !defined(HAVE_USELOCALE)) 493 #define HB_NO_SETLOCALE 1 494 #endif 495 496 #ifndef HB_NO_SETLOCALE 497 498 #include <locale.h> 499 #ifdef HAVE_XLOCALE_H 500 #include <xlocale.h> // Needed on BSD/OS X for uselocale 501 #endif 502 503 #ifdef WIN32 504 #define hb_locale_t _locale_t 505 #else 506 #define hb_locale_t locale_t 507 #endif 508 #define hb_setlocale setlocale 509 #define hb_uselocale uselocale 510 511 #else 512 513 #define hb_locale_t void * 514 #define hb_setlocale(Category, Locale) "C" 515 #define hb_uselocale(Locale) ((hb_locale_t) 0) 516 517 #endif 518 519 520 /* Lets assert int types. Saves trouble down the road. */ 521 static_assert ((sizeof (hb_codepoint_t) == 4), ""); 522 static_assert ((sizeof (hb_position_t) == 4), ""); 523 static_assert ((sizeof (hb_mask_t) == 4), ""); 524 static_assert ((sizeof (hb_var_int_t) == 4), ""); 525 526 527 /* Pie time. */ 528 // https://github.com/harfbuzz/harfbuzz/issues/4166 529 #define HB_PI 3.14159265358979f 530 #define HB_2_PI (2.f * HB_PI) 531 532 /* Compile-time custom allocator support. */ 533 534 #if !defined(HB_CUSTOM_MALLOC) \ 535 && defined(hb_malloc_impl) \ 536 && defined(hb_calloc_impl) \ 537 && defined(hb_realloc_impl) \ 538 && defined(hb_free_impl) 539 #define HB_CUSTOM_MALLOC 540 #endif 541 542 #ifdef HB_CUSTOM_MALLOC 543 extern "C" void* hb_malloc_impl(size_t size); 544 extern "C" void* hb_calloc_impl(size_t nmemb, size_t size); 545 extern "C" void* hb_realloc_impl(void *ptr, size_t size); 546 extern "C" void hb_free_impl(void *ptr); 547 #else 548 #define hb_malloc_impl malloc 549 #define hb_calloc_impl calloc 550 #define hb_realloc_impl realloc 551 #define hb_free_impl free 552 #endif 553 554 555 556 /* Headers we include for everyone. Keep topologically sorted by dependency. 557 * They express dependency amongst themselves, but no other file should include 558 * them directly.*/ 559 #include "hb-cplusplus.hh" 560 #include "hb-meta.hh" 561 #include "hb-mutex.hh" 562 #include "hb-number.hh" 563 #include "hb-atomic.hh" // Requires: hb-meta 564 #include "hb-null.hh" // Requires: hb-meta 565 #include "hb-algs.hh" // Requires: hb-meta hb-null hb-number 566 #include "hb-iter.hh" // Requires: hb-algs hb-meta 567 #include "hb-debug.hh" // Requires: hb-algs hb-atomic 568 #include "hb-array.hh" // Requires: hb-algs hb-iter hb-null 569 #include "hb-vector.hh" // Requires: hb-array hb-null 570 #include "hb-object.hh" // Requires: hb-atomic hb-mutex hb-vector 571 572 573 /* Our src/test-*.cc use hb_assert(), such that it's not compiled out under NDEBUG. 574 * https://github.com/harfbuzz/harfbuzz/issues/5418 */ 575 #define hb_always_assert(x) \ 576 HB_STMT_START { \ 577 if (!(x)) { fprintf(stderr, "Assertion failed: %s, at %s:%d\n", #x, __FILE__, __LINE__); abort(); } \ 578 } HB_STMT_END 579 580 581 #endif /* HB_HH */