Behdad Esfahbod | 64aef3a | 2008-01-23 16:14:38 -0500 | [diff] [blame] | 1 | /* |
Behdad Esfahbod | 2409d5f | 2011-04-21 17:14:28 -0400 | [diff] [blame] | 2 | * Copyright © 2007,2008,2009 Red Hat, Inc. |
Behdad Esfahbod | 0ab8c86 | 2012-05-11 01:25:34 +0200 | [diff] [blame] | 3 | * Copyright © 2011,2012 Google, Inc. |
Behdad Esfahbod | 64aef3a | 2008-01-23 16:14:38 -0500 | [diff] [blame] | 4 | * |
Behdad Esfahbod | c755cb3 | 2010-04-22 00:11:43 -0400 | [diff] [blame] | 5 | * This is part of HarfBuzz, a text shaping library. |
Behdad Esfahbod | 64aef3a | 2008-01-23 16:14:38 -0500 | [diff] [blame] | 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 |
Behdad Esfahbod | 2409d5f | 2011-04-21 17:14:28 -0400 | [diff] [blame] | 26 | * Google Author(s): Behdad Esfahbod |
Behdad Esfahbod | 64aef3a | 2008-01-23 16:14:38 -0500 | [diff] [blame] | 27 | */ |
| 28 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 29 | #ifndef HB_HH |
| 30 | #define HB_HH |
Behdad Esfahbod | 5b3f770 | 2006-12-28 06:42:37 -0500 | [diff] [blame] | 31 | |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 32 | #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC |
Behdad Esfahbod | 227d85e | 2019-05-10 23:15:58 -0700 | [diff] [blame] | 33 | #ifdef _MSC_VER |
Behdad Esfahbod | 51b5848 | 2019-01-28 14:09:45 -0500 | [diff] [blame] | 34 | #pragma warning( disable: 4068 ) /* Unknown pragma */ |
| 35 | #endif |
Behdad Esfahbod | f13b678 | 2019-01-18 14:53:54 -0500 | [diff] [blame] | 36 | #if defined(__GNUC__) || defined(__clang__) |
Behdad Esfahbod | 1077e40 | 2019-01-17 18:36:10 -0500 | [diff] [blame] | 37 | /* Rules: |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 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 | * |
Behdad Esfahbod | 1077e40 | 2019-01-17 18:36:10 -0500 | [diff] [blame] | 42 | * - Within each category, keep sorted. |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 43 | * |
Behdad Esfahbod | 2bd530d | 2019-01-18 09:28:22 -0500 | [diff] [blame] | 44 | * - Warnings whose scope can be expanded in future compiler versions shall |
| 45 | * be declared as "warning". Otherwise, either ignored or error. |
Behdad Esfahbod | 1077e40 | 2019-01-17 18:36:10 -0500 | [diff] [blame] | 46 | */ |
Behdad Esfahbod | 16e5ba8 | 2019-01-18 09:46:17 -0500 | [diff] [blame] | 47 | |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 48 | /* Setup. Don't sort order within this category. */ |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 49 | #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_WARNING |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 50 | #pragma GCC diagnostic warning "-Wall" |
| 51 | #pragma GCC diagnostic warning "-Wextra" |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 52 | #endif |
| 53 | #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_IGNORED |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 54 | #pragma GCC diagnostic ignored "-Wpragmas" |
| 55 | #pragma GCC diagnostic ignored "-Wunknown-pragmas" |
| 56 | #pragma GCC diagnostic ignored "-Wunknown-warning-option" |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 57 | #endif |
| 58 | #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_WARNING |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 59 | //#pragma GCC diagnostic warning "-Weverything" |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 60 | #endif |
Behdad Esfahbod | 16e5ba8 | 2019-01-18 09:46:17 -0500 | [diff] [blame] | 61 | |
Behdad Esfahbod | 2bd530d | 2019-01-18 09:28:22 -0500 | [diff] [blame] | 62 | /* Error. Should never happen. */ |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 63 | #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR |
Behdad Esfahbod | 9bd7ba5 | 2021-10-12 08:44:01 -0700 | [diff] [blame] | 64 | #pragma GCC diagnostic error "-Wbitwise-instead-of-logical" |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 65 | #pragma GCC diagnostic error "-Wcast-align" |
Behdad Esfahbod | 60022ec | 2019-01-26 14:04:51 +0100 | [diff] [blame] | 66 | #pragma GCC diagnostic error "-Wcast-function-type" |
Behdad Esfahbod | e9c0a74 | 2022-06-15 16:57:16 -0600 | [diff] [blame] | 67 | #pragma GCC diagnostic error "-Wcomma" |
Behdad Esfahbod | 9b4e51b | 2019-01-18 12:23:02 -0500 | [diff] [blame] | 68 | #pragma GCC diagnostic error "-Wdelete-non-virtual-dtor" |
Behdad Esfahbod | 8e3cde6 | 2019-06-19 19:58:24 -0700 | [diff] [blame] | 69 | #pragma GCC diagnostic error "-Wembedded-directive" |
Behdad Esfahbod | e98f0dd | 2019-05-13 13:53:06 -0700 | [diff] [blame] | 70 | #pragma GCC diagnostic error "-Wextra-semi-stmt" |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 71 | #pragma GCC diagnostic error "-Wformat-security" |
| 72 | #pragma GCC diagnostic error "-Wimplicit-function-declaration" |
| 73 | #pragma GCC diagnostic error "-Winit-self" |
Behdad Esfahbod | f35e7ea | 2019-01-26 22:50:00 +0100 | [diff] [blame] | 74 | #pragma GCC diagnostic error "-Winjected-class-name" |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 75 | #pragma GCC diagnostic error "-Wmissing-braces" |
| 76 | #pragma GCC diagnostic error "-Wmissing-declarations" |
| 77 | #pragma GCC diagnostic error "-Wmissing-prototypes" |
Behdad Esfahbod | a89d9f2 | 2021-02-20 15:35:28 -0700 | [diff] [blame] | 78 | #pragma GCC diagnostic error "-Wnarrowing" |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 79 | #pragma GCC diagnostic error "-Wnested-externs" |
| 80 | #pragma GCC diagnostic error "-Wold-style-definition" |
| 81 | #pragma GCC diagnostic error "-Wpointer-arith" |
| 82 | #pragma GCC diagnostic error "-Wredundant-decls" |
Behdad Esfahbod | a25174a | 2019-01-18 09:59:36 -0500 | [diff] [blame] | 83 | #pragma GCC diagnostic error "-Wreorder" |
Behdad Esfahbod | 9077272 | 2019-01-22 12:40:18 +0100 | [diff] [blame] | 84 | #pragma GCC diagnostic error "-Wsign-compare" |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 85 | #pragma GCC diagnostic error "-Wstrict-prototypes" |
| 86 | #pragma GCC diagnostic error "-Wstring-conversion" |
| 87 | #pragma GCC diagnostic error "-Wswitch-enum" |
| 88 | #pragma GCC diagnostic error "-Wtautological-overlap-compare" |
| 89 | #pragma GCC diagnostic error "-Wunneeded-internal-declaration" |
| 90 | #pragma GCC diagnostic error "-Wunused" |
| 91 | #pragma GCC diagnostic error "-Wunused-local-typedefs" |
| 92 | #pragma GCC diagnostic error "-Wunused-value" |
| 93 | #pragma GCC diagnostic error "-Wunused-variable" |
Behdad Esfahbod | c81f02f | 2019-01-22 12:00:44 +0100 | [diff] [blame] | 94 | #pragma GCC diagnostic error "-Wvla" |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 95 | #pragma GCC diagnostic error "-Wwrite-strings" |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 96 | #endif |
Behdad Esfahbod | 16e5ba8 | 2019-01-18 09:46:17 -0500 | [diff] [blame] | 97 | |
Behdad Esfahbod | 2bd530d | 2019-01-18 09:28:22 -0500 | [diff] [blame] | 98 | /* Warning. To be investigated if happens. */ |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 99 | #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_WARNING |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 100 | #pragma GCC diagnostic warning "-Wbuiltin-macro-redefined" |
Behdad Esfahbod | 45f5e56 | 2019-05-07 00:33:32 -0700 | [diff] [blame] | 101 | #pragma GCC diagnostic warning "-Wdeprecated" |
Ebrahim Byagowi | 6a6bf7b | 2019-07-17 21:22:38 +0430 | [diff] [blame] | 102 | #pragma GCC diagnostic warning "-Wdeprecated-declarations" |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 103 | #pragma GCC diagnostic warning "-Wdisabled-optimization" |
Behdad Esfahbod | 3c240bd | 2019-06-07 10:56:24 -0700 | [diff] [blame] | 104 | #pragma GCC diagnostic warning "-Wdouble-promotion" |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 105 | #pragma GCC diagnostic warning "-Wformat=2" |
Behdad Esfahbod | ed023f6 | 2023-01-12 17:04:24 -0700 | [diff] [blame] | 106 | #pragma GCC diagnostic warning "-Wformat-signedness" |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 107 | #pragma GCC diagnostic warning "-Wignored-pragma-optimize" |
| 108 | #pragma GCC diagnostic warning "-Wlogical-op" |
Behdad Esfahbod | 4660090 | 2019-01-18 09:53:16 -0500 | [diff] [blame] | 109 | #pragma GCC diagnostic warning "-Wmaybe-uninitialized" |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 110 | #pragma GCC diagnostic warning "-Wmissing-format-attribute" |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 111 | #pragma GCC diagnostic warning "-Wundef" |
Behdad Esfahbod | 075fe33 | 2023-01-12 17:14:42 -0700 | [diff] [blame] | 112 | #pragma GCC diagnostic warning "-Wunsafe-loop-optimizations" |
Ebrahim Byagowi | 0ca3557 | 2020-08-09 16:10:06 +0430 | [diff] [blame] | 113 | #pragma GCC diagnostic warning "-Wunused-but-set-variable" |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 114 | #endif |
Behdad Esfahbod | 16e5ba8 | 2019-01-18 09:46:17 -0500 | [diff] [blame] | 115 | |
Behdad Esfahbod | 2bd530d | 2019-01-18 09:28:22 -0500 | [diff] [blame] | 116 | /* Ignored currently, but should be fixed at some point. */ |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 117 | #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_IGNORED |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 118 | #pragma GCC diagnostic ignored "-Wconversion" // TODO fix |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 119 | #pragma GCC diagnostic ignored "-Wshadow" // TODO fix |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 120 | #pragma GCC diagnostic ignored "-Wunused-parameter" // TODO fix |
Behdad Esfahbod | 05e845c | 2021-03-29 16:02:10 -0700 | [diff] [blame] | 121 | #if defined(__GNUC__) && !defined(__clang__) |
Behdad Esfahbod | b5e4032 | 2021-03-29 15:54:40 -0700 | [diff] [blame] | 122 | #pragma GCC diagnostic ignored "-Wunused-result" // TODO fix |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 123 | #endif |
Behdad Esfahbod | 05e845c | 2021-03-29 16:02:10 -0700 | [diff] [blame] | 124 | #endif |
Behdad Esfahbod | 16e5ba8 | 2019-01-18 09:46:17 -0500 | [diff] [blame] | 125 | |
Behdad Esfahbod | 2bd530d | 2019-01-18 09:28:22 -0500 | [diff] [blame] | 126 | /* Ignored intentionally. */ |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 127 | #ifndef HB_NO_PRAGMA_GCC_DIAGNOSTIC_IGNORED |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 128 | #pragma GCC diagnostic ignored "-Wclass-memaccess" |
Behdad Esfahbod | 60c6b77 | 2022-10-28 14:19:39 -0600 | [diff] [blame] | 129 | #pragma GCC diagnostic ignored "-Wcast-function-type-strict" // https://github.com/harfbuzz/harfbuzz/pull/3859#issuecomment-1295409126 |
Behdad Esfahbod | 13c7006 | 2023-01-18 17:29:26 -0700 | [diff] [blame] | 130 | #pragma GCC diagnostic ignored "-Wdangling-reference" // https://github.com/harfbuzz/harfbuzz/issues/4043 |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 131 | #pragma GCC diagnostic ignored "-Wformat-nonliteral" |
| 132 | #pragma GCC diagnostic ignored "-Wformat-zero-length" |
| 133 | #pragma GCC diagnostic ignored "-Wmissing-field-initializers" |
| 134 | #pragma GCC diagnostic ignored "-Wpacked" // Erratic impl in clang |
Behdad Esfahbod | 86993c0 | 2021-02-19 17:09:33 -0700 | [diff] [blame] | 135 | #pragma GCC diagnostic ignored "-Wrange-loop-analysis" // https://github.com/harfbuzz/harfbuzz/issues/2834 |
Behdad Esfahbod | 7a634d7 | 2019-01-18 09:49:14 -0500 | [diff] [blame] | 136 | #pragma GCC diagnostic ignored "-Wstrict-aliasing" |
| 137 | #pragma GCC diagnostic ignored "-Wtype-limits" |
Ebrahim Byagowi | e261dc3 | 2019-05-07 01:24:55 +0430 | [diff] [blame] | 138 | #pragma GCC diagnostic ignored "-Wc++11-compat" // only gcc raises it |
Behdad Esfahbod | f60282c | 2019-01-24 16:29:09 +0100 | [diff] [blame] | 139 | #endif |
Behdad Esfahbod | f13b678 | 2019-01-18 14:53:54 -0500 | [diff] [blame] | 140 | |
| 141 | #endif |
Behdad Esfahbod | 868b0c0 | 2019-01-17 15:08:36 -0500 | [diff] [blame] | 142 | #endif |
| 143 | |
Behdad Esfahbod | e6582de | 2019-05-10 23:53:38 -0700 | [diff] [blame] | 144 | |
| 145 | #include "hb-config.hh" |
Behdad Esfahbod | ae20896 | 2022-12-26 12:30:39 -0700 | [diff] [blame] | 146 | #include "hb-limits.hh" |
Behdad Esfahbod | e6582de | 2019-05-10 23:53:38 -0700 | [diff] [blame] | 147 | |
Behdad Esfahbod | 12360f7 | 2008-01-23 15:50:38 -0500 | [diff] [blame] | 148 | |
Behdad Esfahbod | 49334f9 | 2018-12-17 18:27:36 -0500 | [diff] [blame] | 149 | /* |
| 150 | * Following added based on what AC_USE_SYSTEM_EXTENSIONS adds to |
| 151 | * config.h.in. Copied here for the convenience of those embedding |
| 152 | * HarfBuzz and not using our build system. |
| 153 | */ |
| 154 | /* Enable extensions on AIX 3, Interix. */ |
| 155 | #ifndef _ALL_SOURCE |
| 156 | # define _ALL_SOURCE 1 |
| 157 | #endif |
| 158 | /* Enable GNU extensions on systems that have them. */ |
| 159 | #ifndef _GNU_SOURCE |
| 160 | # define _GNU_SOURCE 1 |
| 161 | #endif |
| 162 | /* Enable threading extensions on Solaris. */ |
| 163 | #ifndef _POSIX_PTHREAD_SEMANTICS |
| 164 | # define _POSIX_PTHREAD_SEMANTICS 1 |
| 165 | #endif |
| 166 | /* Enable extensions on HP NonStop. */ |
| 167 | #ifndef _TANDEM_SOURCE |
| 168 | # define _TANDEM_SOURCE 1 |
| 169 | #endif |
| 170 | /* Enable general extensions on Solaris. */ |
| 171 | #ifndef __EXTENSIONS__ |
| 172 | # define __EXTENSIONS__ 1 |
| 173 | #endif |
| 174 | |
Chun-wei Fan | 8e4ad1d | 2018-07-25 18:12:34 +0800 | [diff] [blame] | 175 | #if defined (_MSC_VER) && defined (HB_DLL_EXPORT) |
| 176 | #define HB_EXTERN __declspec (dllexport) extern |
| 177 | #endif |
| 178 | |
Behdad Esfahbod | d1c9eb4 | 2012-04-12 13:17:44 -0400 | [diff] [blame] | 179 | #include "hb.h" |
Behdad Esfahbod | d1c9eb4 | 2012-04-12 13:17:44 -0400 | [diff] [blame] | 180 | #define HB_H_IN |
Behdad Esfahbod | 3e32cd9 | 2012-04-23 13:20:52 -0400 | [diff] [blame] | 181 | #include "hb-ot.h" |
Behdad Esfahbod | d1c9eb4 | 2012-04-12 13:17:44 -0400 | [diff] [blame] | 182 | #define HB_OT_H_IN |
Behdad Esfahbod | b206133 | 2018-11-23 14:05:11 -0500 | [diff] [blame] | 183 | #include "hb-aat.h" |
| 184 | #define HB_AAT_H_IN |
Behdad Esfahbod | b28815c | 2009-08-04 22:35:36 -0400 | [diff] [blame] | 185 | |
Behdad Esfahbod | 7cb22ba | 2021-03-01 12:44:06 -0700 | [diff] [blame] | 186 | #include <cassert> |
| 187 | #include <cfloat> |
| 188 | #include <climits> |
Ryan VanderMeulen | 1c0eeb7 | 2022-06-15 23:05:15 -0400 | [diff] [blame] | 189 | #if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES) |
Behdad Esfahbod | e0d5fe7 | 2021-09-17 08:27:03 -0400 | [diff] [blame] | 190 | # define _USE_MATH_DEFINES |
| 191 | #endif |
Behdad Esfahbod | 7cb22ba | 2021-03-01 12:44:06 -0700 | [diff] [blame] | 192 | #include <cmath> |
| 193 | #include <cstdarg> |
| 194 | #include <cstddef> |
| 195 | #include <cstdio> |
| 196 | #include <cstdlib> |
| 197 | #include <cstring> |
Behdad Esfahbod | c7d457a | 2009-05-21 12:46:29 -0400 | [diff] [blame] | 198 | |
Tor Andersson | 8f4c123 | 2018-04-13 23:01:54 +0430 | [diff] [blame] | 199 | #if (defined(_MSC_VER) && _MSC_VER >= 1500) || defined(__MINGW32__) |
Eli Zaretskii | d5e5f37 | 2019-06-05 22:20:03 +0300 | [diff] [blame] | 200 | #ifdef __MINGW32_VERSION |
| 201 | #ifndef WIN32_LEAN_AND_MEAN |
| 202 | #define WIN32_LEAN_AND_MEAN 1 |
| 203 | #endif |
Eli Zaretskii | d5e5f37 | 2019-06-05 22:20:03 +0300 | [diff] [blame] | 204 | #else |
Arkady Shapkin | 6c10328 | 2018-02-15 23:17:46 +0300 | [diff] [blame] | 205 | #include <intrin.h> |
| 206 | #endif |
Eli Zaretskii | d5e5f37 | 2019-06-05 22:20:03 +0300 | [diff] [blame] | 207 | #endif |
Behdad Esfahbod | acdba3f | 2010-07-23 15:11:18 -0400 | [diff] [blame] | 208 | |
Hugo Beauzée-Luyssen | 40ec187 | 2020-04-24 14:01:07 +0200 | [diff] [blame] | 209 | #ifdef _WIN32 |
| 210 | #include <windows.h> |
| 211 | #include <winapifamily.h> |
| 212 | #endif |
| 213 | |
Behdad Esfahbod | 2a74968 | 2017-10-26 19:48:33 -0600 | [diff] [blame] | 214 | #define HB_PASTE1(a,b) a##b |
| 215 | #define HB_PASTE(a,b) HB_PASTE1(a,b) |
| 216 | |
Behdad Esfahbod | 83ea277 | 2018-07-10 13:17:27 +0200 | [diff] [blame] | 217 | |
Behdad Esfahbod | 52b4185 | 2015-10-03 13:20:55 +0100 | [diff] [blame] | 218 | /* Compile-time custom allocator support. */ |
| 219 | |
Ebrahim Byagowi | 7c433ff | 2020-07-15 09:38:12 +0430 | [diff] [blame] | 220 | #if !defined(HB_CUSTOM_MALLOC) \ |
| 221 | && defined(hb_malloc_impl) \ |
| 222 | && defined(hb_calloc_impl) \ |
| 223 | && defined(hb_realloc_impl) \ |
| 224 | && defined(hb_free_impl) |
| 225 | #define HB_CUSTOM_MALLOC |
| 226 | #endif |
| 227 | |
| 228 | #ifdef HB_CUSTOM_MALLOC |
Behdad Esfahbod | cc6ea30 | 2015-10-12 17:21:52 -0400 | [diff] [blame] | 229 | extern "C" void* hb_malloc_impl(size_t size); |
| 230 | extern "C" void* hb_calloc_impl(size_t nmemb, size_t size); |
| 231 | extern "C" void* hb_realloc_impl(void *ptr, size_t size); |
| 232 | extern "C" void hb_free_impl(void *ptr); |
Behdad Esfahbod | 2337f0d | 2021-07-08 10:58:50 -0600 | [diff] [blame] | 233 | #define hb_malloc hb_malloc_impl |
| 234 | #define hb_calloc hb_calloc_impl |
| 235 | #define hb_realloc hb_realloc_impl |
| 236 | #define hb_free hb_free_impl |
| 237 | #else |
| 238 | #define hb_malloc malloc |
| 239 | #define hb_calloc calloc |
| 240 | #define hb_realloc realloc |
| 241 | #define hb_free free |
Behdad Esfahbod | 52b4185 | 2015-10-03 13:20:55 +0100 | [diff] [blame] | 242 | #endif |
| 243 | |
| 244 | |
Behdad Esfahbod | 2aae617 | 2018-07-11 17:27:23 +0200 | [diff] [blame] | 245 | /* |
| 246 | * Compiler attributes |
Behdad Esfahbod | 37be774 | 2018-08-06 04:51:38 -0700 | [diff] [blame] | 247 | */ |
Behdad Esfahbod | 292c100 | 2018-07-10 13:16:52 +0200 | [diff] [blame] | 248 | |
Behdad Esfahbod | 5bc6ab0 | 2023-02-22 08:08:11 -0700 | [diff] [blame] | 249 | // gcc 10 has __has_builtin but not earlier versions. Sanction any gcc >= 5 |
| 250 | // clang defines it so no need. |
| 251 | #ifdef __has_builtin |
| 252 | #define hb_has_builtin __has_builtin |
| 253 | #else |
| 254 | #define hb_has_builtin(x) ((defined(__GNUC__) && __GNUC__ >= 5)) |
| 255 | #endif |
| 256 | |
| 257 | #if defined(__OPTIMIZE__) && hb_has_builtin(__builtin_expect) |
Ebrahim Byagowi | 76c4873 | 2017-06-02 21:53:10 +0430 | [diff] [blame] | 258 | #define likely(expr) (__builtin_expect (!!(expr), 1)) |
| 259 | #define unlikely(expr) (__builtin_expect (!!(expr), 0)) |
Behdad Esfahbod | ae2b854 | 2014-06-03 16:59:09 -0400 | [diff] [blame] | 260 | #else |
| 261 | #define likely(expr) (expr) |
| 262 | #define unlikely(expr) (expr) |
Behdad Esfahbod | bc20045 | 2010-04-29 01:40:26 -0400 | [diff] [blame] | 263 | #endif |
| 264 | |
Steve Lhomme | 0b8f3ab | 2016-07-11 21:57:26 +0200 | [diff] [blame] | 265 | #if !defined(__GNUC__) && !defined(__clang__) |
Behdad Esfahbod | ae2b854 | 2014-06-03 16:59:09 -0400 | [diff] [blame] | 266 | #undef __attribute__ |
| 267 | #define __attribute__(x) |
| 268 | #endif |
Behdad Esfahbod | a794ebf | 2009-08-06 12:32:35 -0400 | [diff] [blame] | 269 | |
Behdad Esfahbod | d9f6be3 | 2019-01-18 12:48:01 -0500 | [diff] [blame] | 270 | #if defined(__GNUC__) && (__GNUC__ >= 3) |
Behdad Esfahbod | ae2b854 | 2014-06-03 16:59:09 -0400 | [diff] [blame] | 271 | #define HB_PRINTF_FUNC(format_idx, arg_idx) __attribute__((__format__ (__printf__, format_idx, arg_idx))) |
| 272 | #else |
Behdad Esfahbod | ae2b854 | 2014-06-03 16:59:09 -0400 | [diff] [blame] | 273 | #define HB_PRINTF_FUNC(format_idx, arg_idx) |
| 274 | #endif |
Iceflower | d6a83ab | 2019-09-26 11:42:11 +0200 | [diff] [blame] | 275 | #if defined(__GNUC__) && (__GNUC__ >= 4) || (__clang__) |
Behdad Esfahbod | ae2b854 | 2014-06-03 16:59:09 -0400 | [diff] [blame] | 276 | #define HB_UNUSED __attribute__((unused)) |
Behdad Esfahbod | be59f3c | 2017-12-05 09:01:28 -0800 | [diff] [blame] | 277 | #elif defined(_MSC_VER) /* https://github.com/harfbuzz/harfbuzz/issues/635 */ |
| 278 | #define HB_UNUSED __pragma(warning(suppress: 4100 4101)) |
Behdad Esfahbod | ae2b854 | 2014-06-03 16:59:09 -0400 | [diff] [blame] | 279 | #else |
| 280 | #define HB_UNUSED |
| 281 | #endif |
| 282 | |
| 283 | #ifndef HB_INTERNAL |
Behdad Esfahbod | 90d1c74 | 2018-02-11 19:08:59 -0800 | [diff] [blame] | 284 | # if !defined(HB_NO_VISIBILITY) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_MSC_VER) && !defined(__SUNPRO_CC) |
Behdad Esfahbod | ae2b854 | 2014-06-03 16:59:09 -0400 | [diff] [blame] | 285 | # define HB_INTERNAL __attribute__((__visibility__("hidden"))) |
Behdad Esfahbod | 94759d4 | 2018-07-23 15:01:39 -0700 | [diff] [blame] | 286 | # elif defined(__MINGW32__) |
Chun-wei Fan | 8e4ad1d | 2018-07-25 18:12:34 +0800 | [diff] [blame] | 287 | /* We use -export-symbols on mingw32, since it does not support visibility attributes. */ |
| 288 | # define HB_INTERNAL |
| 289 | # elif defined (_MSC_VER) && defined (HB_DLL_EXPORT) |
| 290 | /* We do not try to export internal symbols on Visual Studio */ |
Behdad Esfahbod | 94759d4 | 2018-07-23 15:01:39 -0700 | [diff] [blame] | 291 | # define HB_INTERNAL |
| 292 | #else |
Behdad Esfahbod | ae2b854 | 2014-06-03 16:59:09 -0400 | [diff] [blame] | 293 | # define HB_INTERNAL |
Behdad Esfahbod | b87cbe2 | 2018-02-07 14:11:26 -0500 | [diff] [blame] | 294 | # define HB_NO_VISIBILITY 1 |
Behdad Esfahbod | ae2b854 | 2014-06-03 16:59:09 -0400 | [diff] [blame] | 295 | # endif |
| 296 | #endif |
| 297 | |
Behdad Esfahbod | 02d864a | 2019-04-15 15:39:03 -0400 | [diff] [blame] | 298 | /* https://github.com/harfbuzz/harfbuzz/issues/1651 */ |
| 299 | #if defined(__clang__) && __clang_major__ < 10 |
| 300 | #define static_const static |
| 301 | #else |
| 302 | #define static_const static const |
| 303 | #endif |
| 304 | |
Behdad Esfahbod | d9f6be3 | 2019-01-18 12:48:01 -0500 | [diff] [blame] | 305 | #if defined(__GNUC__) && (__GNUC__ >= 3) |
Behdad Esfahbod | ae2b854 | 2014-06-03 16:59:09 -0400 | [diff] [blame] | 306 | #define HB_FUNC __PRETTY_FUNCTION__ |
| 307 | #elif defined(_MSC_VER) |
| 308 | #define HB_FUNC __FUNCSIG__ |
| 309 | #else |
| 310 | #define HB_FUNC __func__ |
| 311 | #endif |
| 312 | |
prrace | 498e437 | 2018-06-09 16:04:28 -0700 | [diff] [blame] | 313 | #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140) |
Behdad Esfahbod | 8cef3a6 | 2018-02-09 16:04:23 -0600 | [diff] [blame] | 314 | /* https://github.com/harfbuzz/harfbuzz/issues/630 */ |
| 315 | #define __restrict |
| 316 | #endif |
| 317 | |
Behdad Esfahbod | 305d2fb | 2015-10-21 11:04:28 -0200 | [diff] [blame] | 318 | /* |
| 319 | * Borrowed from https://bugzilla.mozilla.org/show_bug.cgi?id=1215411 |
| 320 | * HB_FALLTHROUGH is an annotation to suppress compiler warnings about switch |
| 321 | * cases that fall through without a break or return statement. HB_FALLTHROUGH |
| 322 | * is only needed on cases that have code: |
| 323 | * |
| 324 | * switch (foo) { |
| 325 | * case 1: // These cases have no code. No fallthrough annotations are needed. |
| 326 | * case 2: |
| 327 | * case 3: |
| 328 | * foo = 4; // This case has code, so a fallthrough annotation is needed: |
| 329 | * HB_FALLTHROUGH; |
| 330 | * default: |
| 331 | * return foo; |
| 332 | * } |
| 333 | */ |
| 334 | #if defined(__clang__) && __cplusplus >= 201103L |
| 335 | /* clang's fallthrough annotations are only available starting in C++11. */ |
| 336 | # define HB_FALLTHROUGH [[clang::fallthrough]] |
Behdad Esfahbod | d9f6be3 | 2019-01-18 12:48:01 -0500 | [diff] [blame] | 337 | #elif defined(__GNUC__) && (__GNUC__ >= 7) |
Behdad Esfahbod | f41b921 | 2018-02-05 19:51:09 -0500 | [diff] [blame] | 338 | /* GNU fallthrough attribute is available from GCC7 */ |
| 339 | # define HB_FALLTHROUGH __attribute__((fallthrough)) |
Behdad Esfahbod | 305d2fb | 2015-10-21 11:04:28 -0200 | [diff] [blame] | 340 | #elif defined(_MSC_VER) |
| 341 | /* |
| 342 | * MSVC's __fallthrough annotations are checked by /analyze (Code Analysis): |
| 343 | * https://msdn.microsoft.com/en-us/library/ms235402%28VS.80%29.aspx |
| 344 | */ |
| 345 | # include <sal.h> |
| 346 | # define HB_FALLTHROUGH __fallthrough |
| 347 | #else |
| 348 | # define HB_FALLTHROUGH /* FALLTHROUGH */ |
| 349 | #endif |
| 350 | |
Ebrahim Byagowi | 385d64e | 2020-05-07 09:59:01 +0430 | [diff] [blame] | 351 | /* A tag to enforce use of return value for a function */ |
| 352 | #if __cplusplus >= 201703L |
| 353 | # define HB_NODISCARD [[nodiscard]] |
| 354 | #elif defined(__GNUC__) || defined(__clang__) |
| 355 | # define HB_NODISCARD __attribute__((warn_unused_result)) |
| 356 | #elif defined(_MSC_VER) |
| 357 | # define HB_NODISCARD _Check_return_ |
| 358 | #else |
| 359 | # define HB_NODISCARD |
| 360 | #endif |
Ebrahim Byagowi | 385d64e | 2020-05-07 09:59:01 +0430 | [diff] [blame] | 361 | |
Behdad Esfahbod | 89228cc | 2019-07-22 07:07:37 -0400 | [diff] [blame] | 362 | /* https://github.com/harfbuzz/harfbuzz/issues/1852 */ |
| 363 | #if defined(__clang__) && !(defined(_AIX) && (defined(__IBMCPP__) || defined(__ibmxl__))) |
Behdad Esfahbod | 62376a7 | 2018-10-14 15:20:50 -0700 | [diff] [blame] | 364 | /* Disable certain sanitizer errors. */ |
| 365 | /* https://github.com/harfbuzz/harfbuzz/issues/1247 */ |
| 366 | #define HB_NO_SANITIZE_SIGNED_INTEGER_OVERFLOW __attribute__((no_sanitize("signed-integer-overflow"))) |
| 367 | #else |
| 368 | #define HB_NO_SANITIZE_SIGNED_INTEGER_OVERFLOW |
| 369 | #endif |
| 370 | |
| 371 | |
Ken Brown | eee5b5e | 2018-11-12 21:05:39 -0500 | [diff] [blame] | 372 | #ifdef _WIN32 |
Behdad Esfahbod | db30828 | 2014-07-19 16:32:04 -0400 | [diff] [blame] | 373 | /* We need Windows Vista for both Uniscribe backend and for |
| 374 | * MemoryBarrier. We don't support compiling on Windows XP, |
| 375 | * though we run on it fine. */ |
| 376 | # if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0600 |
| 377 | # undef _WIN32_WINNT |
| 378 | # endif |
| 379 | # ifndef _WIN32_WINNT |
Hugo Beauzée-Luyssen | 40ec187 | 2020-04-24 14:01:07 +0200 | [diff] [blame] | 380 | # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) |
Matt Oliver | 24dd6c1 | 2018-09-23 18:08:30 +1000 | [diff] [blame] | 381 | # define _WIN32_WINNT 0x0600 |
| 382 | # endif |
Behdad Esfahbod | db30828 | 2014-07-19 16:32:04 -0400 | [diff] [blame] | 383 | # endif |
Behdad Esfahbod | 270971a | 2014-08-15 14:28:04 -0400 | [diff] [blame] | 384 | # ifndef WIN32_LEAN_AND_MEAN |
| 385 | # define WIN32_LEAN_AND_MEAN 1 |
| 386 | # endif |
| 387 | # ifndef STRICT |
| 388 | # define STRICT 1 |
| 389 | # endif |
Behdad Esfahbod | dabe698 | 2012-11-23 14:21:35 -0500 | [diff] [blame] | 390 | |
Konstantin Ritt | f3537b6 | 2015-01-25 09:50:51 +0400 | [diff] [blame] | 391 | # if defined(_WIN32_WCE) |
| 392 | /* Some things not defined on Windows CE. */ |
Konstantin Ritt | 5069062 | 2016-04-26 12:02:26 +0400 | [diff] [blame] | 393 | # define vsnprintf _vsnprintf |
Cody Planteen | 72e3eba | 2019-05-02 13:03:15 -0600 | [diff] [blame] | 394 | # ifndef HB_NO_GETENV |
| 395 | # define HB_NO_GETENV |
| 396 | # endif |
Konstantin Ritt | 855a5d7 | 2015-04-10 17:18:01 +0400 | [diff] [blame] | 397 | # if _WIN32_WCE < 0x800 |
Ebrahim Byagowi | a36ff94 | 2019-06-10 15:48:28 +0430 | [diff] [blame] | 398 | # define HB_NO_SETLOCALE |
Ebrahim Byagowi | 412d6ca | 2019-09-16 13:50:11 +0430 | [diff] [blame] | 399 | # define HB_NO_ERRNO |
Konstantin Ritt | 855a5d7 | 2015-04-10 17:18:01 +0400 | [diff] [blame] | 400 | # endif |
Khaled Hosny | 791a1bf | 2021-07-27 15:22:13 +0200 | [diff] [blame] | 401 | # elif !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) |
Cody Planteen | 72e3eba | 2019-05-02 13:03:15 -0600 | [diff] [blame] | 402 | # ifndef HB_NO_GETENV |
| 403 | # define HB_NO_GETENV |
| 404 | # endif |
Konstantin Ritt | f3537b6 | 2015-01-25 09:50:51 +0400 | [diff] [blame] | 405 | # endif |
Behdad Esfahbod | ce01ad7 | 2015-04-01 11:05:59 -0700 | [diff] [blame] | 406 | # if defined(_MSC_VER) && _MSC_VER < 1900 |
Konstantin Ritt | f3537b6 | 2015-01-25 09:50:51 +0400 | [diff] [blame] | 407 | # define snprintf _snprintf |
Konstantin Ritt | f3537b6 | 2015-01-25 09:50:51 +0400 | [diff] [blame] | 408 | # endif |
Behdad Esfahbod | 26a963b | 2014-08-10 18:04:50 -0400 | [diff] [blame] | 409 | #endif |
| 410 | |
Cody Planteen | 72e3eba | 2019-05-02 13:03:15 -0600 | [diff] [blame] | 411 | #ifdef HB_NO_GETENV |
| 412 | #define getenv(Name) nullptr |
| 413 | #endif |
| 414 | |
Behdad Esfahbod | e832dc4 | 2019-10-28 17:02:40 -0700 | [diff] [blame] | 415 | #ifndef HB_NO_ERRNO |
Behdad Esfahbod | 7cb22ba | 2021-03-01 12:44:06 -0700 | [diff] [blame] | 416 | # include <cerrno> |
Ebrahim Byagowi | 412d6ca | 2019-09-16 13:50:11 +0430 | [diff] [blame] | 417 | #else |
Behdad Esfahbod | fd71c04 | 2019-10-28 17:06:53 -0700 | [diff] [blame] | 418 | static int HB_UNUSED _hb_errno = 0; |
Behdad Esfahbod | e832dc4 | 2019-10-28 17:02:40 -0700 | [diff] [blame] | 419 | # undef errno |
| 420 | # define errno _hb_errno |
Ebrahim Byagowi | 412d6ca | 2019-09-16 13:50:11 +0430 | [diff] [blame] | 421 | #endif |
| 422 | |
Behdad Esfahbod | ed11632 | 2021-09-14 07:09:54 -0400 | [diff] [blame] | 423 | #define HB_STMT_START do |
| 424 | #define HB_STMT_END while (0) |
| 425 | |
Behdad Esfahbod | b89c7fd | 2018-11-21 12:32:48 -0500 | [diff] [blame] | 426 | #if defined(HAVE_ATEXIT) && !defined(HB_USE_ATEXIT) |
Behdad Esfahbod | 38fb30d | 2014-08-06 13:34:49 -0400 | [diff] [blame] | 427 | /* atexit() is only safe to be called from shared libraries on certain |
| 428 | * platforms. Whitelist. |
| 429 | * https://bugs.freedesktop.org/show_bug.cgi?id=82246 */ |
| 430 | # if defined(__linux) && defined(__GLIBC_PREREQ) |
| 431 | # if __GLIBC_PREREQ(2,3) |
| 432 | /* From atexit() manpage, it's safe with glibc 2.2.3 on Linux. */ |
| 433 | # define HB_USE_ATEXIT 1 |
| 434 | # endif |
| 435 | # elif defined(_MSC_VER) || defined(__MINGW32__) |
| 436 | /* For MSVC: |
Ebrahim Byagowi | f24b0b9 | 2018-04-12 13:40:45 +0430 | [diff] [blame] | 437 | * https://msdn.microsoft.com/en-us/library/tze57ck3.aspx |
| 438 | * https://msdn.microsoft.com/en-us/library/zk17ww08.aspx |
Behdad Esfahbod | 38fb30d | 2014-08-06 13:34:49 -0400 | [diff] [blame] | 439 | * mingw32 headers say atexit is safe to use in shared libraries. |
| 440 | */ |
| 441 | # define HB_USE_ATEXIT 1 |
Ebrahim Byagowi | 632713b | 2018-04-12 14:17:03 +0430 | [diff] [blame] | 442 | # elif defined(__ANDROID__) |
| 443 | /* This is available since Android NKD r8 or r8b: |
| 444 | * https://issuetracker.google.com/code/p/android/issues/detail?id=6455 |
Behdad Esfahbod | 38fb30d | 2014-08-06 13:34:49 -0400 | [diff] [blame] | 445 | */ |
| 446 | # define HB_USE_ATEXIT 1 |
Bruce Mitchener | e8859fc | 2018-02-04 01:26:57 +0700 | [diff] [blame] | 447 | # elif defined(__APPLE__) |
| 448 | /* For macOS and related platforms, the atexit man page indicates |
| 449 | * that it will be invoked when the library is unloaded, not only |
| 450 | * at application exit. |
| 451 | */ |
| 452 | # define HB_USE_ATEXIT 1 |
Behdad Esfahbod | 38fb30d | 2014-08-06 13:34:49 -0400 | [diff] [blame] | 453 | # endif |
Behdad Esfahbod | ed11632 | 2021-09-14 07:09:54 -0400 | [diff] [blame] | 454 | #endif /* defined(HAVE_ATEXIT) && !defined(HB_USE_ATEXIT) */ |
Behdad Esfahbod | c14b24f | 2018-03-26 10:44:54 -0700 | [diff] [blame] | 455 | #ifdef HB_NO_ATEXIT |
| 456 | # undef HB_USE_ATEXIT |
| 457 | #endif |
Behdad Esfahbod | b89c7fd | 2018-11-21 12:32:48 -0500 | [diff] [blame] | 458 | #ifndef HB_USE_ATEXIT |
| 459 | # define HB_USE_ATEXIT 0 |
| 460 | #endif |
Behdad Esfahbod | 9177953 | 2022-02-04 12:38:45 -0600 | [diff] [blame] | 461 | #ifndef hb_atexit |
Behdad Esfahbod | ed11632 | 2021-09-14 07:09:54 -0400 | [diff] [blame] | 462 | #if !HB_USE_ATEXIT |
| 463 | # define hb_atexit(_) HB_STMT_START { if (0) (_) (); } HB_STMT_END |
| 464 | #else /* HB_USE_ATEXIT */ |
| 465 | # ifdef HAVE_ATEXIT |
| 466 | # define hb_atexit atexit |
| 467 | # else |
Behdad Esfahbod | bda3238 | 2021-09-14 08:12:48 -0400 | [diff] [blame] | 468 | template <void (*function) (void)> struct hb_atexit_t { ~hb_atexit_t () { function (); } }; |
| 469 | # define hb_atexit(f) static hb_atexit_t<f> _hb_atexit_##__LINE__; |
Behdad Esfahbod | ed11632 | 2021-09-14 07:09:54 -0400 | [diff] [blame] | 470 | # endif |
| 471 | #endif |
Behdad Esfahbod | 9177953 | 2022-02-04 12:38:45 -0600 | [diff] [blame] | 472 | #endif |
Behdad Esfahbod | 5b3f770 | 2006-12-28 06:42:37 -0500 | [diff] [blame] | 473 | |
Behdad Esfahbod | 5b50b07 | 2023-02-19 20:30:38 -0700 | [diff] [blame] | 474 | |
| 475 | // Locale business |
| 476 | |
| 477 | #if !defined(HB_NO_SETLOCALE) && (!defined(HAVE_NEWLOCALE) || !defined(HAVE_USELOCALE)) |
| 478 | #define HB_NO_SETLOCALE 1 |
| 479 | #endif |
| 480 | |
| 481 | #ifndef HB_NO_SETLOCALE |
| 482 | |
| 483 | #include <locale.h> |
| 484 | #ifdef HAVE_XLOCALE_H |
| 485 | #include <xlocale.h> // Needed on BSD/OS X for uselocale |
| 486 | #endif |
| 487 | |
| 488 | #ifdef WIN32 |
| 489 | #define hb_locale_t _locale_t |
| 490 | #else |
| 491 | #define hb_locale_t locale_t |
| 492 | #endif |
| 493 | #define hb_setlocale setlocale |
| 494 | #define hb_uselocale uselocale |
| 495 | |
| 496 | #else |
| 497 | |
| 498 | #define hb_locale_t void * |
| 499 | #define hb_setlocale(Category, Locale) "C" |
| 500 | #define hb_uselocale(Locale) ((hb_locale_t) 0) |
| 501 | |
| 502 | #endif |
| 503 | |
| 504 | |
Behdad Esfahbod | 6fd5364 | 2011-04-11 11:47:14 -0400 | [diff] [blame] | 505 | /* Lets assert int types. Saves trouble down the road. */ |
Behdad Esfahbod | 606bf57 | 2018-09-16 19:33:48 +0200 | [diff] [blame] | 506 | static_assert ((sizeof (hb_codepoint_t) == 4), ""); |
| 507 | static_assert ((sizeof (hb_position_t) == 4), ""); |
| 508 | static_assert ((sizeof (hb_mask_t) == 4), ""); |
| 509 | static_assert ((sizeof (hb_var_int_t) == 4), ""); |
Behdad Esfahbod | 6fd5364 | 2011-04-11 11:47:14 -0400 | [diff] [blame] | 510 | |
Behdad Esfahbod | 44999f8 | 2018-07-11 17:00:59 +0200 | [diff] [blame] | 511 | |
Behdad Esfahbod | 75e6498 | 2023-03-14 12:41:46 -0600 | [diff] [blame^] | 512 | /* Pie time. */ |
| 513 | // https://github.com/harfbuzz/harfbuzz/issues/4166 |
| 514 | #define HB_PI 3.14159265358979f |
| 515 | #define HB_2_PI (2.f * HB_PI) |
| 516 | |
| 517 | |
Behdad Esfahbod | 865deeb | 2018-12-21 17:35:58 -0500 | [diff] [blame] | 518 | /* Headers we include for everyone. Keep topologically sorted by dependency. |
| 519 | * They express dependency amongst themselves, but no other file should include |
| 520 | * them directly.*/ |
Behdad Esfahbod | 17c8003 | 2022-06-09 04:17:38 -0600 | [diff] [blame] | 521 | #include "hb-cplusplus.hh" |
Behdad Esfahbod | e76a3ca | 2018-12-27 17:23:12 -0500 | [diff] [blame] | 522 | #include "hb-meta.hh" |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 523 | #include "hb-mutex.hh" |
Ebrahim Byagowi | a77bb7e | 2019-09-03 14:49:14 +0430 | [diff] [blame] | 524 | #include "hb-number.hh" |
Behdad Esfahbod | f64ea8f | 2018-12-30 18:49:34 -0500 | [diff] [blame] | 525 | #include "hb-atomic.hh" // Requires: hb-meta |
Behdad Esfahbod | 8c6cbbd | 2018-12-28 14:29:09 -0500 | [diff] [blame] | 526 | #include "hb-null.hh" // Requires: hb-meta |
Ebrahim Byagowi | a77bb7e | 2019-09-03 14:49:14 +0430 | [diff] [blame] | 527 | #include "hb-algs.hh" // Requires: hb-meta hb-null hb-number |
Behdad Esfahbod | a3fcb9a | 2019-04-16 10:45:20 -0400 | [diff] [blame] | 528 | #include "hb-iter.hh" // Requires: hb-algs hb-meta |
Behdad Esfahbod | 6e3ad65 | 2019-01-09 09:05:01 -0800 | [diff] [blame] | 529 | #include "hb-debug.hh" // Requires: hb-algs hb-atomic |
| 530 | #include "hb-array.hh" // Requires: hb-algs hb-iter hb-null |
Behdad Esfahbod | 865deeb | 2018-12-21 17:35:58 -0500 | [diff] [blame] | 531 | #include "hb-vector.hh" // Requires: hb-array hb-null |
| 532 | #include "hb-object.hh" // Requires: hb-atomic hb-mutex hb-vector |
Behdad Esfahbod | 83ea277 | 2018-07-10 13:17:27 +0200 | [diff] [blame] | 533 | |
Behdad Esfahbod | c77ae40 | 2018-08-25 22:36:36 -0700 | [diff] [blame] | 534 | #endif /* HB_HH */ |