tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

platform.h (27841B)


      1 // © 2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html
      3 /*
      4 ******************************************************************************
      5 *
      6 *   Copyright (C) 1997-2016, International Business Machines
      7 *   Corporation and others.  All Rights Reserved.
      8 *
      9 ******************************************************************************
     10 *
     11 *  FILE NAME : platform.h
     12 *
     13 *   Date        Name        Description
     14 *   05/13/98    nos         Creation (content moved here from ptypes.h).
     15 *   03/02/99    stephen     Added AS400 support.
     16 *   03/30/99    stephen     Added Linux support.
     17 *   04/13/99    stephen     Reworked for autoconf.
     18 ******************************************************************************
     19 */
     20 
     21 #ifndef _PLATFORM_H
     22 #define _PLATFORM_H
     23 
     24 #include "unicode/uconfig.h"
     25 #include "unicode/uvernum.h"
     26 
     27 /**
     28 * \file
     29 * \brief Basic types for the platform.
     30 *
     31 * This file used to be generated by autoconf/configure.
     32 * Starting with ICU 49, platform.h is a normal source file,
     33 * to simplify cross-compiling and working with non-autoconf/make build systems.
     34 *
     35 * When a value in this file does not work on a platform, then please
     36 * try to derive it from the U_PLATFORM value
     37 * (for which we might need a new value constant in rare cases)
     38 * and/or from other macros that are predefined by the compiler
     39 * or defined in standard (POSIX or platform or compiler) headers.
     40 *
     41 * As a temporary workaround, you can add an explicit \#define for some macros
     42 * before it is first tested, or add an equivalent -D macro definition
     43 * to the compiler's command line.
     44 *
     45 * Note: Some compilers provide ways to show the predefined macros.
     46 * For example, with gcc you can compile an empty .c file and have the compiler
     47 * print the predefined macros with
     48 * \code
     49 * gcc -E -dM -x c /dev/null | sort
     50 * \endcode
     51 * (You can provide an actual empty .c file rather than /dev/null.
     52 * <code>-x c++</code> is for C++.)
     53 */
     54 
     55 /**
     56 * Define some things so that they can be documented.
     57 * @internal
     58 */
     59 #ifdef U_IN_DOXYGEN
     60 /*
     61 * Problem: "platform.h:335: warning: documentation for unknown define U_HAVE_STD_STRING found." means that U_HAVE_STD_STRING is not documented.
     62 * Solution: #define any defines for non @internal API here, so that they are visible in the docs.  If you just set PREDEFINED in Doxyfile.in,  they won't be documented.
     63 */
     64 
     65 /* None for now. */
     66 #endif
     67 
     68 /**
     69 * \def U_PLATFORM
     70 * The U_PLATFORM macro defines the platform we're on.
     71 *
     72 * We used to define one different, value-less macro per platform.
     73 * That made it hard to know the set of relevant platforms and macros,
     74 * and hard to deal with variants of platforms.
     75 *
     76 * Starting with ICU 49, we define platforms as numeric macros,
     77 * with ranges of values for related platforms and their variants.
     78 * The U_PLATFORM macro is set to one of these values.
     79 *
     80 * Historical note from the Solaris Wikipedia article:
     81 * AT&T and Sun collaborated on a project to merge the most popular Unix variants
     82 * on the market at that time: BSD, System V, and Xenix.
     83 * This became Unix System V Release 4 (SVR4).
     84 *
     85 * @internal
     86 */
     87 
     88 /** Unknown platform. @internal */
     89 #define U_PF_UNKNOWN 0
     90 /** Windows @internal */
     91 #define U_PF_WINDOWS 1000
     92 /** MinGW. Windows, calls to Win32 API, but using GNU gcc and binutils. @internal */
     93 #define U_PF_MINGW 1800
     94 /**
     95 * Cygwin. Windows, calls to cygwin1.dll for Posix functions,
     96 * using MSVC or GNU gcc and binutils.
     97 * @internal
     98 */
     99 #define U_PF_CYGWIN 1900
    100 /* Reserve 2000 for U_PF_UNIX? */
    101 /** HP-UX is based on UNIX System V. @internal */
    102 #define U_PF_HPUX 2100
    103 /** Solaris is a Unix operating system based on SVR4. @internal */
    104 #define U_PF_SOLARIS 2600
    105 /** BSD is a UNIX operating system derivative. @internal */
    106 #define U_PF_BSD 3000
    107 /** AIX is based on UNIX System V Releases and 4.3 BSD. @internal */
    108 #define U_PF_AIX 3100
    109 /** IRIX is based on UNIX System V with BSD extensions. @internal */
    110 #define U_PF_IRIX 3200
    111 /**
    112 * Darwin is a POSIX-compliant operating system, composed of code developed by Apple,
    113 * as well as code derived from NeXTSTEP, BSD, and other projects,
    114 * built around the Mach kernel.
    115 * Darwin forms the core set of components upon which Mac OS X, Apple TV, and iOS are based.
    116 * (Original description modified from WikiPedia.)
    117 * @internal
    118 */
    119 #define U_PF_DARWIN 3500
    120 /** iPhone OS (iOS) is a derivative of Mac OS X. @internal */
    121 #define U_PF_IPHONE 3550
    122 /** QNX is a commercial Unix-like real-time operating system related to BSD. @internal */
    123 #define U_PF_QNX 3700
    124 /** Linux is a Unix-like operating system. @internal */
    125 #define U_PF_LINUX 4000
    126 /**
    127 * Native Client is pretty close to Linux.
    128 * See https://developer.chrome.com/native-client and
    129 *  http://www.chromium.org/nativeclient
    130 *  @internal
    131 */
    132 #define U_PF_BROWSER_NATIVE_CLIENT 4020
    133 /** Android is based on Linux. @internal */
    134 #define U_PF_ANDROID 4050
    135 /** Haiku is a POSIX-ish platform. @internal */
    136 #define U_PF_HAIKU 4080
    137 /** Fuchsia is a POSIX-ish platform. @internal */
    138 #define U_PF_FUCHSIA 4100
    139 /* Maximum value for Linux-based platform is 4499 */
    140 /**
    141 * Emscripten is a C++ transpiler for the Web that can target asm.js or
    142 * WebAssembly. It provides some POSIX-compatible wrappers and stubs and
    143 * some Linux-like functionality, but is not fully compatible with
    144 * either.
    145 * @internal
    146 */
    147 #define U_PF_EMSCRIPTEN 5010
    148 /** z/OS is the successor to OS/390 which was the successor to MVS. @internal */
    149 #define U_PF_OS390 9000
    150 /** "IBM i" is the current name of what used to be i5/OS and earlier OS/400. @internal */
    151 #define U_PF_OS400 9400
    152 
    153 #ifdef U_PLATFORM
    154    /* Use the predefined value. */
    155 #elif defined(__MINGW32__)
    156 #   define U_PLATFORM U_PF_MINGW
    157 #elif defined(__CYGWIN__)
    158 #   define U_PLATFORM U_PF_CYGWIN
    159    /* Cygwin uchar.h doesn't exist until Cygwin 3.5. */
    160 #   include <cygwin/version.h>
    161 #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
    162 #   define U_PLATFORM U_PF_WINDOWS
    163 #elif defined(__ANDROID__)
    164 #   define U_PLATFORM U_PF_ANDROID
    165    /* Android wchar_t support depends on the API level. */
    166 #   include <android/api-level.h>
    167 #elif defined(__pnacl__) || defined(__native_client__)
    168 #   define U_PLATFORM U_PF_BROWSER_NATIVE_CLIENT
    169 #elif defined(__Fuchsia__)
    170 #   define U_PLATFORM U_PF_FUCHSIA
    171 #elif defined(linux) || defined(__linux__) || defined(__linux)
    172 #   define U_PLATFORM U_PF_LINUX
    173 #elif defined(__APPLE__) && defined(__MACH__)
    174 #   include <TargetConditionals.h>
    175 #   if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && (defined(TARGET_OS_MACCATALYST) && !TARGET_OS_MACCATALYST)   /* variant of TARGET_OS_MAC */
    176 #       define U_PLATFORM U_PF_IPHONE
    177 #   else
    178 #       define U_PLATFORM U_PF_DARWIN
    179 #   endif
    180 #elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__)
    181 #   if defined(__FreeBSD__)
    182 #       include <sys/endian.h>
    183 #   endif
    184 #   define U_PLATFORM U_PF_BSD
    185 #elif defined(sun) || defined(__sun)
    186    /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */
    187 #   define U_PLATFORM U_PF_SOLARIS
    188 #   if defined(__GNUC__)
    189        /* Solaris/GCC needs this header file to get the proper endianness. Normally, this
    190         * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h
    191         *  is included which does not include this header file.
    192         */
    193 #       include <sys/isa_defs.h>
    194 #   endif
    195 #elif defined(_AIX) || defined(__TOS_AIX__)
    196 #   define U_PLATFORM U_PF_AIX
    197 #elif defined(_hpux) || defined(hpux) || defined(__hpux)
    198 #   define U_PLATFORM U_PF_HPUX
    199 #elif defined(sgi) || defined(__sgi)
    200 #   define U_PLATFORM U_PF_IRIX
    201 #elif defined(__QNX__) || defined(__QNXNTO__)
    202 #   define U_PLATFORM U_PF_QNX
    203 #elif defined(__TOS_MVS__)
    204 #   define U_PLATFORM U_PF_OS390
    205 #elif defined(__OS400__) || defined(__TOS_OS400__)
    206 #   define U_PLATFORM U_PF_OS400
    207 #elif defined(__HAIKU__)
    208 #   define U_PLATFORM U_PF_HAIKU
    209 #elif defined(__EMSCRIPTEN__)
    210 #   define U_PLATFORM U_PF_EMSCRIPTEN
    211 #else
    212 #   define U_PLATFORM U_PF_UNKNOWN
    213 #endif
    214 
    215 /**
    216 * \def U_REAL_MSVC
    217 * Defined if the compiler is the real MSVC compiler (and not something like
    218 * Clang setting _MSC_VER in order to compile Windows code that requires it).
    219 * Otherwise undefined.
    220 * @internal
    221 */
    222 #if (defined(_MSC_VER) && !(defined(__clang__) && __clang__)) || defined(U_IN_DOXYGEN)
    223 #   define U_REAL_MSVC
    224 #endif
    225 
    226 /**
    227 * \def CYGWINMSVC
    228 * Defined if this is Windows with Cygwin, but using MSVC rather than gcc.
    229 * Otherwise undefined.
    230 * @internal
    231 */
    232 /* Commented out because this is already set in mh-cygwin-msvc
    233 #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER)
    234 #   define CYGWINMSVC
    235 #endif
    236 */
    237 #ifdef U_IN_DOXYGEN
    238 #   define CYGWINMSVC
    239 #endif
    240 
    241 /**
    242 * \def U_PLATFORM_USES_ONLY_WIN32_API
    243 * Defines whether the platform uses only the Win32 API.
    244 * Set to 1 for Windows/MSVC, ClangCL and MinGW but not Cygwin.
    245 * @internal
    246 */
    247 #ifdef U_PLATFORM_USES_ONLY_WIN32_API
    248    /* Use the predefined value. */
    249 #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC)
    250 #   define U_PLATFORM_USES_ONLY_WIN32_API 1
    251 #else
    252    /* Cygwin implements POSIX. */
    253 #   define U_PLATFORM_USES_ONLY_WIN32_API 0
    254 #endif
    255 
    256 /**
    257 * \def U_PLATFORM_HAS_WIN32_API
    258 * Defines whether the Win32 API is available on the platform.
    259 * Set to 1 for Windows/MSVC, ClangCL, MinGW and Cygwin.
    260 * @internal
    261 */
    262 #ifdef U_PLATFORM_HAS_WIN32_API
    263    /* Use the predefined value. */
    264 #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
    265 #   define U_PLATFORM_HAS_WIN32_API 1
    266 #else
    267 #   define U_PLATFORM_HAS_WIN32_API 0
    268 #endif
    269 
    270 /**
    271 * \def U_PLATFORM_HAS_WINUWP_API
    272 * Defines whether target is intended for Universal Windows Platform API
    273 * Set to 1 for Windows10 Release Solution Configuration
    274 * @internal
    275 */
    276 #ifdef U_PLATFORM_HAS_WINUWP_API
    277    /* Use the predefined value. */
    278 #else
    279 #   define U_PLATFORM_HAS_WINUWP_API 0
    280 #endif
    281 
    282 /**
    283 * \def U_PLATFORM_IMPLEMENTS_POSIX
    284 * Defines whether the platform implements (most of) the POSIX API.
    285 * Set to 1 for Cygwin and most other platforms.
    286 * @internal
    287 */
    288 #ifdef U_PLATFORM_IMPLEMENTS_POSIX
    289    /* Use the predefined value. */
    290 #elif U_PLATFORM_USES_ONLY_WIN32_API
    291 #   define U_PLATFORM_IMPLEMENTS_POSIX 0
    292 #else
    293 #   define U_PLATFORM_IMPLEMENTS_POSIX 1
    294 #endif
    295 
    296 /**
    297 * \def U_PLATFORM_IS_LINUX_BASED
    298 * Defines whether the platform is Linux or one of its derivatives.
    299 * @internal
    300 */
    301 #ifdef U_PLATFORM_IS_LINUX_BASED
    302    /* Use the predefined value. */
    303 #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= 4499
    304 #   define U_PLATFORM_IS_LINUX_BASED 1
    305 #else
    306 #   define U_PLATFORM_IS_LINUX_BASED 0
    307 #endif
    308 
    309 /**
    310 * \def U_PLATFORM_IS_DARWIN_BASED
    311 * Defines whether the platform is Darwin or one of its derivatives.
    312 * @internal
    313 */
    314 #ifdef U_PLATFORM_IS_DARWIN_BASED
    315    /* Use the predefined value. */
    316 #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE
    317 #   define U_PLATFORM_IS_DARWIN_BASED 1
    318 #else
    319 #   define U_PLATFORM_IS_DARWIN_BASED 0
    320 #endif
    321 
    322 /*===========================================================================*/
    323 /** @{ Compiler and environment features                                     */
    324 /*===========================================================================*/
    325 
    326 /**
    327 * \def U_GCC_MAJOR_MINOR
    328 * Indicates whether the compiler is gcc (test for != 0),
    329 * and if so, contains its major (times 100) and minor version numbers.
    330 * If the compiler is not gcc, then U_GCC_MAJOR_MINOR == 0.
    331 *
    332 * For example, for testing for whether we have gcc, and whether it's 4.6 or higher,
    333 * use "#if U_GCC_MAJOR_MINOR >= 406".
    334 * @internal
    335 */
    336 #ifdef __GNUC__
    337 #   define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__)
    338 #else
    339 #   define U_GCC_MAJOR_MINOR 0
    340 #endif
    341 
    342 /**
    343 * \def U_IS_BIG_ENDIAN
    344 * Determines the endianness of the platform.
    345 * @internal
    346 */
    347 #ifdef U_IS_BIG_ENDIAN
    348    /* Use the predefined value. */
    349 #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN)
    350 #   define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
    351 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
    352    /* gcc */
    353 #   define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
    354 #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
    355 #   define U_IS_BIG_ENDIAN 1
    356 #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)
    357 #   define U_IS_BIG_ENDIAN 0
    358 #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__)
    359    /* These platforms do not appear to predefine any endianness macros. */
    360 #   define U_IS_BIG_ENDIAN 1
    361 #elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0)
    362    /* HPPA do not appear to predefine any endianness macros. */
    363 #   define U_IS_BIG_ENDIAN 1
    364 #elif defined(sparc) || defined(__sparc) || defined(__sparc__)
    365    /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */
    366 #   define U_IS_BIG_ENDIAN 1
    367 #else
    368 #   define U_IS_BIG_ENDIAN 0
    369 #endif
    370 
    371 /**
    372 * \def U_HAVE_DEBUG_LOCATION_NEW 
    373 * Define this to define the MFC debug version of the operator new.
    374 *
    375 * @stable ICU 3.4
    376 */
    377 #ifdef U_HAVE_DEBUG_LOCATION_NEW
    378    /* Use the predefined value. */
    379 #elif defined(_MSC_VER)
    380 #   define U_HAVE_DEBUG_LOCATION_NEW 1
    381 #else
    382 #   define U_HAVE_DEBUG_LOCATION_NEW 0
    383 #endif
    384 
    385 /* Compatibility with compilers other than clang: http://clang.llvm.org/docs/LanguageExtensions.html */
    386 #ifdef __has_attribute
    387 #   define UPRV_HAS_ATTRIBUTE(x) __has_attribute(x)
    388 #else
    389 #   define UPRV_HAS_ATTRIBUTE(x) 0
    390 #endif
    391 #ifdef __has_cpp_attribute
    392 #   define UPRV_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
    393 #else
    394 #   define UPRV_HAS_CPP_ATTRIBUTE(x) 0
    395 #endif
    396 #ifdef __has_declspec_attribute
    397 #   define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) __has_declspec_attribute(x)
    398 #else
    399 #   define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) 0
    400 #endif
    401 #ifdef __has_builtin
    402 #   define UPRV_HAS_BUILTIN(x) __has_builtin(x)
    403 #else
    404 #   define UPRV_HAS_BUILTIN(x) 0
    405 #endif
    406 #ifdef __has_feature
    407 #   define UPRV_HAS_FEATURE(x) __has_feature(x)
    408 #else
    409 #   define UPRV_HAS_FEATURE(x) 0
    410 #endif
    411 #ifdef __has_extension
    412 #   define UPRV_HAS_EXTENSION(x) __has_extension(x)
    413 #else
    414 #   define UPRV_HAS_EXTENSION(x) 0
    415 #endif
    416 #ifdef __has_warning
    417 #   define UPRV_HAS_WARNING(x) __has_warning(x)
    418 #else
    419 #   define UPRV_HAS_WARNING(x) 0
    420 #endif
    421 
    422 
    423 #if defined(__clang__)
    424 #define UPRV_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined")))
    425 #else
    426 #define UPRV_NO_SANITIZE_UNDEFINED
    427 #endif
    428 
    429 /**
    430 * \def U_MALLOC_ATTR
    431 * Attribute to mark functions as malloc-like
    432 * @internal
    433 */
    434 #if defined(__GNUC__) && __GNUC__>=3
    435 #    define U_MALLOC_ATTR __attribute__ ((__malloc__))
    436 #else
    437 #    define U_MALLOC_ATTR
    438 #endif
    439 
    440 /**
    441 * \def U_ALLOC_SIZE_ATTR
    442 * Attribute to specify the size of the allocated buffer for malloc-like functions
    443 * @internal
    444 */
    445 #if (defined(__GNUC__) &&                                            \
    446        (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \
    447        UPRV_HAS_ATTRIBUTE(alloc_size)
    448 #   define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X)))
    449 #   define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y)))
    450 #else
    451 #   define U_ALLOC_SIZE_ATTR(X)
    452 #   define U_ALLOC_SIZE_ATTR2(X,Y)
    453 #endif
    454 
    455 /**
    456 * \def U_CPLUSPLUS_VERSION
    457 * 0 if no C++; 1, 11, 14, ... if C++.
    458 * Support for specific features cannot always be determined by the C++ version alone.
    459 * @internal
    460 */
    461 #ifdef U_CPLUSPLUS_VERSION
    462 #   if U_CPLUSPLUS_VERSION != 0 && !defined(__cplusplus)
    463 #       undef U_CPLUSPLUS_VERSION
    464 #       define U_CPLUSPLUS_VERSION 0
    465 #   endif
    466    /* Otherwise use the predefined value. */
    467 #elif !defined(__cplusplus)
    468 #   define U_CPLUSPLUS_VERSION 0
    469 // The value of _MSVC_LANG for C++23 preview is undocumented, except that it is larger than 202002.
    470 // As of this writing, it is 202004.
    471 #elif __cplusplus >= 202302L || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L)
    472 #   define U_CPLUSPLUS_VERSION 23
    473 #elif __cplusplus >= 202002L || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
    474 #   define U_CPLUSPLUS_VERSION 20
    475 #elif __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
    476 #   define U_CPLUSPLUS_VERSION 17
    477 #elif __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
    478 #   define U_CPLUSPLUS_VERSION 14
    479 #elif __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)
    480 #   define U_CPLUSPLUS_VERSION 11
    481 #else
    482    // C++98 or C++03
    483 #   define U_CPLUSPLUS_VERSION 1
    484 #endif
    485 
    486 /**
    487 * \def U_FALLTHROUGH
    488 * Annotate intentional fall-through between switch labels.
    489 * https://clang.llvm.org/docs/AttributeReference.html#fallthrough
    490 * @internal
    491 */
    492 #if defined(U_FALLTHROUGH)
    493    // Use the predefined value.
    494 #elif defined(__clang__)
    495    // Test for compiler vs. feature separately.
    496    // Other compilers might choke on the feature test.
    497 #    if UPRV_HAS_CPP_ATTRIBUTE(clang::fallthrough) || \
    498             (UPRV_HAS_FEATURE(cxx_attributes) &&     \
    499             UPRV_HAS_WARNING("-Wimplicit-fallthrough"))
    500 #       define U_FALLTHROUGH [[clang::fallthrough]]
    501 #   endif
    502 #elif defined(__GNUC__) && (__GNUC__ >= 7)
    503 #   define U_FALLTHROUGH __attribute__((fallthrough))
    504 #endif
    505 
    506 #ifndef U_FALLTHROUGH
    507 #   define U_FALLTHROUGH
    508 #endif
    509 
    510 /** @} */
    511 
    512 /*===========================================================================*/
    513 /** @{ Character data types                                                  */
    514 /*===========================================================================*/
    515 
    516 /**
    517 * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform.
    518 * @stable ICU 2.0
    519 */
    520 #define U_ASCII_FAMILY 0
    521 
    522 /**
    523 * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform.
    524 * @stable ICU 2.0
    525 */
    526 #define U_EBCDIC_FAMILY 1
    527 
    528 /**
    529 * \def U_CHARSET_FAMILY
    530 *
    531 * <p>These definitions allow to specify the encoding of text
    532 * in the char data type as defined by the platform and the compiler.
    533 * It is enough to determine the code point values of "invariant characters",
    534 * which are the ones shared by all encodings that are in use
    535 * on a given platform.</p>
    536 *
    537 * <p>Those "invariant characters" should be all the uppercase and lowercase
    538 * latin letters, the digits, the space, and "basic punctuation".
    539 * Also, '\\n', '\\r', '\\t' should be available.</p>
    540 *
    541 * <p>The list of "invariant characters" is:<br>
    542 * \code
    543 *    A-Z  a-z  0-9  SPACE  "  %  &amp;  '  (  )  *  +  ,  -  .  /  :  ;  <  =  >  ?  _
    544 * \endcode
    545 * <br>
    546 * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)</p>
    547 *
    548 * <p>This matches the IBM Syntactic Character Set (CS 640).</p>
    549 *
    550 * <p>In other words, all the graphic characters in 7-bit ASCII should
    551 * be safely accessible except the following:</p>
    552 *
    553 * \code
    554 *    '\' <backslash>
    555 *    '[' <left bracket>
    556 *    ']' <right bracket>
    557 *    '{' <left brace>
    558 *    '}' <right brace>
    559 *    '^' <circumflex>
    560 *    '~' <tilde>
    561 *    '!' <exclamation mark>
    562 *    '#' <number sign>
    563 *    '|' <vertical line>
    564 *    '$' <dollar sign>
    565 *    '@' <commercial at>
    566 *    '`' <grave accent>
    567 * \endcode
    568 * @stable ICU 2.0
    569 */
    570 #ifdef U_CHARSET_FAMILY
    571    /* Use the predefined value. */
    572 #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB)
    573 #   define U_CHARSET_FAMILY U_EBCDIC_FAMILY
    574 #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__)
    575 #   define U_CHARSET_FAMILY U_EBCDIC_FAMILY
    576 #else
    577 #   define U_CHARSET_FAMILY U_ASCII_FAMILY
    578 #endif
    579 
    580 /**
    581 * \def U_CHARSET_IS_UTF8
    582 *
    583 * Hardcode the default charset to UTF-8.
    584 *
    585 * If this is set to 1, then
    586 * - ICU will assume that all non-invariant char*, StringPiece, std::string etc.
    587 *   contain UTF-8 text, regardless of what the system API uses
    588 * - some ICU code will use fast functions like u_strFromUTF8()
    589 *   rather than the more general and more heavy-weight conversion API (ucnv.h)
    590 * - ucnv_getDefaultName() always returns "UTF-8"
    591 * - ucnv_setDefaultName() is disabled and will not change the default charset
    592 * - static builds of ICU are smaller
    593 * - more functionality is available with the UCONFIG_NO_CONVERSION build-time
    594 *   configuration option (see unicode/uconfig.h)
    595 * - the UCONFIG_NO_CONVERSION build option in uconfig.h is more usable
    596 *
    597 * @stable ICU 4.2
    598 * @see UCONFIG_NO_CONVERSION
    599 */
    600 #ifdef U_CHARSET_IS_UTF8
    601    /* Use the predefined value. */
    602 #elif U_PLATFORM_IS_LINUX_BASED || U_PLATFORM_IS_DARWIN_BASED || \
    603        U_PLATFORM == U_PF_EMSCRIPTEN
    604 #   define U_CHARSET_IS_UTF8 1
    605 #else
    606 #   define U_CHARSET_IS_UTF8 0
    607 #endif
    608 
    609 /** @} */
    610 
    611 /*===========================================================================*/
    612 /** @{ Information about wchar support                                       */
    613 /*===========================================================================*/
    614 
    615 /**
    616 * \def U_HAVE_WCHAR_H
    617 * Indicates whether <wchar.h> is available (1) or not (0). Set to 1 by default.
    618 *
    619 * @stable ICU 2.0
    620 */
    621 #ifdef U_HAVE_WCHAR_H
    622    /* Use the predefined value. */
    623 #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9
    624    /*
    625     * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t.
    626     * The type and header existed, but the library functions did not work as expected.
    627     * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway.
    628     */
    629 #   define U_HAVE_WCHAR_H 0
    630 #else
    631 #   define U_HAVE_WCHAR_H 1
    632 #endif
    633 
    634 /**
    635 * \def U_SIZEOF_WCHAR_T
    636 * U_SIZEOF_WCHAR_T==sizeof(wchar_t)
    637 *
    638 * @stable ICU 2.0
    639 */
    640 #ifdef U_SIZEOF_WCHAR_T
    641    /* Use the predefined value. */
    642 #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9)
    643    /*
    644     * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring.
    645     * Newer Mac OS X has size 4.
    646     */
    647 #   define U_SIZEOF_WCHAR_T 1
    648 #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN
    649 #   define U_SIZEOF_WCHAR_T 2
    650 #elif U_PLATFORM == U_PF_AIX
    651    /*
    652     * AIX 6.1 information, section "Wide character data representation":
    653     * "... the wchar_t datatype is 32-bit in the 64-bit environment and
    654     * 16-bit in the 32-bit environment."
    655     * and
    656     * "All locales use Unicode for their wide character code values (process code),
    657     * except the IBM-eucTW codeset."
    658     */
    659 #   ifdef __64BIT__
    660 #       define U_SIZEOF_WCHAR_T 4
    661 #   else
    662 #       define U_SIZEOF_WCHAR_T 2
    663 #   endif
    664 #elif U_PLATFORM == U_PF_OS390
    665    /*
    666     * z/OS V1R11 information center, section "LP64 | ILP32":
    667     * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes.
    668     * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes."
    669     */
    670 #   ifdef _LP64
    671 #       define U_SIZEOF_WCHAR_T 4
    672 #   else
    673 #       define U_SIZEOF_WCHAR_T 2
    674 #   endif
    675 #elif U_PLATFORM == U_PF_OS400
    676 #   if defined(__UTF32__)
    677        /*
    678         * LOCALETYPE(*LOCALEUTF) is specified.
    679         * Wide-character strings are in UTF-32,
    680         * narrow-character strings are in UTF-8.
    681         */
    682 #       define U_SIZEOF_WCHAR_T 4
    683 #   elif defined(__UCS2__)
    684        /*
    685         * LOCALETYPE(*LOCALEUCS2) is specified.
    686         * Wide-character strings are in UCS-2,
    687         * narrow-character strings are in EBCDIC.
    688         */
    689 #       define U_SIZEOF_WCHAR_T 2
    690 #   else
    691        /*
    692         * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified.
    693         * Wide-character strings are in 16-bit EBCDIC,
    694         * narrow-character strings are in EBCDIC.
    695         */
    696 #       define U_SIZEOF_WCHAR_T 2
    697 #   endif
    698 #else
    699 #   define U_SIZEOF_WCHAR_T 4
    700 #endif
    701 
    702 #ifndef U_HAVE_WCSCPY
    703 #define U_HAVE_WCSCPY U_HAVE_WCHAR_H
    704 #endif
    705 
    706 /** @} */
    707 
    708 /**
    709 * \def U_HAVE_CHAR16_T
    710 * Defines whether the char16_t type is available for UTF-16
    711 * and u"abc" UTF-16 string literals are supported.
    712 * This is a new standard type and standard string literal syntax in C++11
    713 * but has been available in some compilers before.
    714 * @internal
    715 */
    716 #ifdef U_HAVE_CHAR16_T
    717    /* Use the predefined value. */
    718 #else
    719    /*
    720     * Notes:
    721     * C++11 and C11 require support for UTF-16 literals
    722     * Doesn't work on Mac C11 (see workaround in ptypes.h)
    723     * or Cygwin less than 3.5.
    724     */
    725 #   if defined(__cplusplus)
    726 #       define U_HAVE_CHAR16_T 1
    727 #   elif U_PLATFORM_IS_DARWIN_BASED || (U_PLATFORM == U_PF_CYGWIN && CYGWIN_VERSION_DLL_MAJOR < 3005)
    728 #       define U_HAVE_CHAR16_T 0
    729 #   else
    730        // conformant C11
    731 #       define U_HAVE_CHAR16_T 1
    732 #   endif
    733 #endif
    734 
    735 /**
    736 * @{
    737 * \def U_DECLARE_UTF16
    738 * Do not use this macro because it is not defined on all platforms.
    739 * In C++, use std::u16string_view literals, see the UNICODE_STRING docs.
    740 * In C, use u"UTF-16 literals".
    741 * See also the public U_STRING_DECL macro.
    742 * @internal
    743 */
    744 #ifdef U_DECLARE_UTF16
    745    /* Use the predefined value. */
    746 #elif U_HAVE_CHAR16_T \
    747    || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
    748    || (defined(__HP_aCC) && __HP_aCC >= 035000) \
    749    || (defined(__HP_cc) && __HP_cc >= 111106) \
    750    || (defined(U_IN_DOXYGEN))
    751 #   define U_DECLARE_UTF16(string) u ## string
    752 #elif U_SIZEOF_WCHAR_T == 2 \
    753    && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__)))
    754 #   define U_DECLARE_UTF16(string) L ## string
    755 #else
    756    /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */
    757 #endif
    758 
    759 /** @} */
    760 
    761 /*===========================================================================*/
    762 /** @{ Symbol import-export control                                          */
    763 /*===========================================================================*/
    764 
    765 #ifdef U_EXPORT
    766    /* Use the predefined value. */
    767 #elif defined(U_STATIC_IMPLEMENTATION)
    768 #   define U_EXPORT
    769 #elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllexport__) && \
    770                            UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllimport__))
    771 #   define U_EXPORT __declspec(dllexport)
    772 #elif defined(__GNUC__) || defined(__open_xl__)
    773 #   define U_EXPORT __attribute__((visibility("default")))
    774 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
    775   || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) 
    776 #   define U_EXPORT __global
    777 /*#elif defined(__HP_aCC) || defined(__HP_cc)
    778 #   define U_EXPORT __declspec(dllexport)*/
    779 #else
    780 #   define U_EXPORT
    781 #endif
    782 
    783 /* U_CALLCONV is related to U_EXPORT2 */
    784 #ifdef U_EXPORT2
    785    /* Use the predefined value. */
    786 #elif defined(_MSC_VER)
    787 #   define U_EXPORT2 __cdecl
    788 #else
    789 #   define U_EXPORT2
    790 #endif
    791 
    792 #ifdef U_IMPORT
    793    /* Use the predefined value. */
    794 #elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllexport__) && \
    795                            UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllimport__))
    796    /* Windows needs to export/import data. */
    797 #   define U_IMPORT __declspec(dllimport)
    798 #else
    799 #   define U_IMPORT 
    800 #endif
    801 
    802 /**
    803 * \def U_HIDDEN
    804 * This is used to mark internal structs declared within external classes,
    805 * to prevent the internal structs from having the same visibility as the
    806 * class within which they are declared. 
    807 * @internal
    808 */
    809 #ifdef U_HIDDEN
    810    /* Use the predefined value. */
    811 #elif defined(__GNUC__) || defined(__open_xl__)
    812 #   define U_HIDDEN __attribute__((visibility("hidden")))
    813 #else
    814 #   define U_HIDDEN 
    815 #endif
    816 
    817 /**
    818 * \def U_CALLCONV
    819 * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary
    820 * in callback function typedefs to make sure that the calling convention
    821 * is compatible.
    822 *
    823 * This is only used for non-ICU-API functions.
    824 * When a function is a public ICU API,
    825 * you must use the U_CAPI and U_EXPORT2 qualifiers.
    826 *
    827 * Please note, you need to use U_CALLCONV after the *.
    828 *
    829 * NO : "static const char U_CALLCONV *func( . . . )"
    830 * YES: "static const char* U_CALLCONV func( . . . )"
    831 *
    832 * @stable ICU 2.0
    833 */
    834 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
    835 #    define U_CALLCONV __cdecl
    836 #else
    837 #    define U_CALLCONV U_EXPORT2
    838 #endif
    839 
    840 /**
    841 * \def U_CALLCONV_FPTR
    842 * Similar to U_CALLCONV, but only used on function pointers.
    843 * @internal
    844 */
    845 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
    846 #    define U_CALLCONV_FPTR U_CALLCONV
    847 #else
    848 #    define U_CALLCONV_FPTR
    849 #endif
    850 /** @} */
    851 
    852 #endif  // _PLATFORM_H