|
||||
Warning, file /include/unicode/platform.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // © 2016 and later: Unicode, Inc. and others. 0002 // License & terms of use: http://www.unicode.org/copyright.html 0003 /* 0004 ****************************************************************************** 0005 * 0006 * Copyright (C) 1997-2016, International Business Machines 0007 * Corporation and others. All Rights Reserved. 0008 * 0009 ****************************************************************************** 0010 * 0011 * FILE NAME : platform.h 0012 * 0013 * Date Name Description 0014 * 05/13/98 nos Creation (content moved here from ptypes.h). 0015 * 03/02/99 stephen Added AS400 support. 0016 * 03/30/99 stephen Added Linux support. 0017 * 04/13/99 stephen Reworked for autoconf. 0018 ****************************************************************************** 0019 */ 0020 0021 #ifndef _PLATFORM_H 0022 #define _PLATFORM_H 0023 0024 #include "unicode/uconfig.h" 0025 #include "unicode/uvernum.h" 0026 0027 /** 0028 * \file 0029 * \brief Basic types for the platform. 0030 * 0031 * This file used to be generated by autoconf/configure. 0032 * Starting with ICU 49, platform.h is a normal source file, 0033 * to simplify cross-compiling and working with non-autoconf/make build systems. 0034 * 0035 * When a value in this file does not work on a platform, then please 0036 * try to derive it from the U_PLATFORM value 0037 * (for which we might need a new value constant in rare cases) 0038 * and/or from other macros that are predefined by the compiler 0039 * or defined in standard (POSIX or platform or compiler) headers. 0040 * 0041 * As a temporary workaround, you can add an explicit \#define for some macros 0042 * before it is first tested, or add an equivalent -D macro definition 0043 * to the compiler's command line. 0044 * 0045 * Note: Some compilers provide ways to show the predefined macros. 0046 * For example, with gcc you can compile an empty .c file and have the compiler 0047 * print the predefined macros with 0048 * \code 0049 * gcc -E -dM -x c /dev/null | sort 0050 * \endcode 0051 * (You can provide an actual empty .c file rather than /dev/null. 0052 * <code>-x c++</code> is for C++.) 0053 */ 0054 0055 /** 0056 * Define some things so that they can be documented. 0057 * @internal 0058 */ 0059 #ifdef U_IN_DOXYGEN 0060 /* 0061 * Problem: "platform.h:335: warning: documentation for unknown define U_HAVE_STD_STRING found." means that U_HAVE_STD_STRING is not documented. 0062 * 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. 0063 */ 0064 0065 /* None for now. */ 0066 #endif 0067 0068 /** 0069 * \def U_PLATFORM 0070 * The U_PLATFORM macro defines the platform we're on. 0071 * 0072 * We used to define one different, value-less macro per platform. 0073 * That made it hard to know the set of relevant platforms and macros, 0074 * and hard to deal with variants of platforms. 0075 * 0076 * Starting with ICU 49, we define platforms as numeric macros, 0077 * with ranges of values for related platforms and their variants. 0078 * The U_PLATFORM macro is set to one of these values. 0079 * 0080 * Historical note from the Solaris Wikipedia article: 0081 * AT&T and Sun collaborated on a project to merge the most popular Unix variants 0082 * on the market at that time: BSD, System V, and Xenix. 0083 * This became Unix System V Release 4 (SVR4). 0084 * 0085 * @internal 0086 */ 0087 0088 /** Unknown platform. @internal */ 0089 #define U_PF_UNKNOWN 0 0090 /** Windows @internal */ 0091 #define U_PF_WINDOWS 1000 0092 /** MinGW. Windows, calls to Win32 API, but using GNU gcc and binutils. @internal */ 0093 #define U_PF_MINGW 1800 0094 /** 0095 * Cygwin. Windows, calls to cygwin1.dll for Posix functions, 0096 * using MSVC or GNU gcc and binutils. 0097 * @internal 0098 */ 0099 #define U_PF_CYGWIN 1900 0100 /* Reserve 2000 for U_PF_UNIX? */ 0101 /** HP-UX is based on UNIX System V. @internal */ 0102 #define U_PF_HPUX 2100 0103 /** Solaris is a Unix operating system based on SVR4. @internal */ 0104 #define U_PF_SOLARIS 2600 0105 /** BSD is a UNIX operating system derivative. @internal */ 0106 #define U_PF_BSD 3000 0107 /** AIX is based on UNIX System V Releases and 4.3 BSD. @internal */ 0108 #define U_PF_AIX 3100 0109 /** IRIX is based on UNIX System V with BSD extensions. @internal */ 0110 #define U_PF_IRIX 3200 0111 /** 0112 * Darwin is a POSIX-compliant operating system, composed of code developed by Apple, 0113 * as well as code derived from NeXTSTEP, BSD, and other projects, 0114 * built around the Mach kernel. 0115 * Darwin forms the core set of components upon which Mac OS X, Apple TV, and iOS are based. 0116 * (Original description modified from WikiPedia.) 0117 * @internal 0118 */ 0119 #define U_PF_DARWIN 3500 0120 /** iPhone OS (iOS) is a derivative of Mac OS X. @internal */ 0121 #define U_PF_IPHONE 3550 0122 /** QNX is a commercial Unix-like real-time operating system related to BSD. @internal */ 0123 #define U_PF_QNX 3700 0124 /** Linux is a Unix-like operating system. @internal */ 0125 #define U_PF_LINUX 4000 0126 /** 0127 * Native Client is pretty close to Linux. 0128 * See https://developer.chrome.com/native-client and 0129 * http://www.chromium.org/nativeclient 0130 * @internal 0131 */ 0132 #define U_PF_BROWSER_NATIVE_CLIENT 4020 0133 /** Android is based on Linux. @internal */ 0134 #define U_PF_ANDROID 4050 0135 /** Fuchsia is a POSIX-ish platform. @internal */ 0136 #define U_PF_FUCHSIA 4100 0137 /* Maximum value for Linux-based platform is 4499 */ 0138 /** 0139 * Emscripten is a C++ transpiler for the Web that can target asm.js or 0140 * WebAssembly. It provides some POSIX-compatible wrappers and stubs and 0141 * some Linux-like functionality, but is not fully compatible with 0142 * either. 0143 * @internal 0144 */ 0145 #define U_PF_EMSCRIPTEN 5010 0146 /** z/OS is the successor to OS/390 which was the successor to MVS. @internal */ 0147 #define U_PF_OS390 9000 0148 /** "IBM i" is the current name of what used to be i5/OS and earlier OS/400. @internal */ 0149 #define U_PF_OS400 9400 0150 0151 #ifdef U_PLATFORM 0152 /* Use the predefined value. */ 0153 #elif defined(__MINGW32__) 0154 # define U_PLATFORM U_PF_MINGW 0155 #elif defined(__CYGWIN__) 0156 # define U_PLATFORM U_PF_CYGWIN 0157 #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) 0158 # define U_PLATFORM U_PF_WINDOWS 0159 #elif defined(__ANDROID__) 0160 # define U_PLATFORM U_PF_ANDROID 0161 /* Android wchar_t support depends on the API level. */ 0162 # include <android/api-level.h> 0163 #elif defined(__pnacl__) || defined(__native_client__) 0164 # define U_PLATFORM U_PF_BROWSER_NATIVE_CLIENT 0165 #elif defined(__Fuchsia__) 0166 # define U_PLATFORM U_PF_FUCHSIA 0167 #elif defined(linux) || defined(__linux__) || defined(__linux) 0168 # define U_PLATFORM U_PF_LINUX 0169 #elif defined(__APPLE__) && defined(__MACH__) 0170 # include <TargetConditionals.h> 0171 # if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && (defined(TARGET_OS_MACCATALYST) && !TARGET_OS_MACCATALYST) /* variant of TARGET_OS_MAC */ 0172 # define U_PLATFORM U_PF_IPHONE 0173 # else 0174 # define U_PLATFORM U_PF_DARWIN 0175 # endif 0176 #elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__) 0177 # if defined(__FreeBSD__) 0178 # include <sys/endian.h> 0179 # endif 0180 # define U_PLATFORM U_PF_BSD 0181 #elif defined(sun) || defined(__sun) 0182 /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */ 0183 # define U_PLATFORM U_PF_SOLARIS 0184 # if defined(__GNUC__) 0185 /* Solaris/GCC needs this header file to get the proper endianness. Normally, this 0186 * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h 0187 * is included which does not include this header file. 0188 */ 0189 # include <sys/isa_defs.h> 0190 # endif 0191 #elif defined(_AIX) || defined(__TOS_AIX__) 0192 # define U_PLATFORM U_PF_AIX 0193 #elif defined(_hpux) || defined(hpux) || defined(__hpux) 0194 # define U_PLATFORM U_PF_HPUX 0195 #elif defined(sgi) || defined(__sgi) 0196 # define U_PLATFORM U_PF_IRIX 0197 #elif defined(__QNX__) || defined(__QNXNTO__) 0198 # define U_PLATFORM U_PF_QNX 0199 #elif defined(__TOS_MVS__) 0200 # define U_PLATFORM U_PF_OS390 0201 #elif defined(__OS400__) || defined(__TOS_OS400__) 0202 # define U_PLATFORM U_PF_OS400 0203 #elif defined(__EMSCRIPTEN__) 0204 # define U_PLATFORM U_PF_EMSCRIPTEN 0205 #else 0206 # define U_PLATFORM U_PF_UNKNOWN 0207 #endif 0208 0209 /** 0210 * \def CYGWINMSVC 0211 * Defined if this is Windows with Cygwin, but using MSVC rather than gcc. 0212 * Otherwise undefined. 0213 * @internal 0214 */ 0215 /* Commented out because this is already set in mh-cygwin-msvc 0216 #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER) 0217 # define CYGWINMSVC 0218 #endif 0219 */ 0220 #ifdef U_IN_DOXYGEN 0221 # define CYGWINMSVC 0222 #endif 0223 0224 /** 0225 * \def U_PLATFORM_USES_ONLY_WIN32_API 0226 * Defines whether the platform uses only the Win32 API. 0227 * Set to 1 for Windows/MSVC and MinGW but not Cygwin. 0228 * @internal 0229 */ 0230 #ifdef U_PLATFORM_USES_ONLY_WIN32_API 0231 /* Use the predefined value. */ 0232 #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC) 0233 # define U_PLATFORM_USES_ONLY_WIN32_API 1 0234 #else 0235 /* Cygwin implements POSIX. */ 0236 # define U_PLATFORM_USES_ONLY_WIN32_API 0 0237 #endif 0238 0239 /** 0240 * \def U_PLATFORM_HAS_WIN32_API 0241 * Defines whether the Win32 API is available on the platform. 0242 * Set to 1 for Windows/MSVC, MinGW and Cygwin. 0243 * @internal 0244 */ 0245 #ifdef U_PLATFORM_HAS_WIN32_API 0246 /* Use the predefined value. */ 0247 #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN 0248 # define U_PLATFORM_HAS_WIN32_API 1 0249 #else 0250 # define U_PLATFORM_HAS_WIN32_API 0 0251 #endif 0252 0253 /** 0254 * \def U_PLATFORM_HAS_WINUWP_API 0255 * Defines whether target is intended for Universal Windows Platform API 0256 * Set to 1 for Windows10 Release Solution Configuration 0257 * @internal 0258 */ 0259 #ifdef U_PLATFORM_HAS_WINUWP_API 0260 /* Use the predefined value. */ 0261 #else 0262 # define U_PLATFORM_HAS_WINUWP_API 0 0263 #endif 0264 0265 /** 0266 * \def U_PLATFORM_IMPLEMENTS_POSIX 0267 * Defines whether the platform implements (most of) the POSIX API. 0268 * Set to 1 for Cygwin and most other platforms. 0269 * @internal 0270 */ 0271 #ifdef U_PLATFORM_IMPLEMENTS_POSIX 0272 /* Use the predefined value. */ 0273 #elif U_PLATFORM_USES_ONLY_WIN32_API 0274 # define U_PLATFORM_IMPLEMENTS_POSIX 0 0275 #else 0276 # define U_PLATFORM_IMPLEMENTS_POSIX 1 0277 #endif 0278 0279 /** 0280 * \def U_PLATFORM_IS_LINUX_BASED 0281 * Defines whether the platform is Linux or one of its derivatives. 0282 * @internal 0283 */ 0284 #ifdef U_PLATFORM_IS_LINUX_BASED 0285 /* Use the predefined value. */ 0286 #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= 4499 0287 # define U_PLATFORM_IS_LINUX_BASED 1 0288 #else 0289 # define U_PLATFORM_IS_LINUX_BASED 0 0290 #endif 0291 0292 /** 0293 * \def U_PLATFORM_IS_DARWIN_BASED 0294 * Defines whether the platform is Darwin or one of its derivatives. 0295 * @internal 0296 */ 0297 #ifdef U_PLATFORM_IS_DARWIN_BASED 0298 /* Use the predefined value. */ 0299 #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE 0300 # define U_PLATFORM_IS_DARWIN_BASED 1 0301 #else 0302 # define U_PLATFORM_IS_DARWIN_BASED 0 0303 #endif 0304 0305 /** 0306 * \def U_HAVE_STDINT_H 0307 * Defines whether stdint.h is available. It is a C99 standard header. 0308 * We used to include inttypes.h which includes stdint.h but we usually do not need 0309 * the additional definitions from inttypes.h. 0310 * @internal 0311 */ 0312 #ifdef U_HAVE_STDINT_H 0313 /* Use the predefined value. */ 0314 #elif U_PLATFORM_USES_ONLY_WIN32_API 0315 # if defined(__BORLANDC__) || U_PLATFORM == U_PF_MINGW || (defined(_MSC_VER) && _MSC_VER>=1600) 0316 /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */ 0317 # define U_HAVE_STDINT_H 1 0318 # else 0319 # define U_HAVE_STDINT_H 0 0320 # endif 0321 #elif U_PLATFORM == U_PF_SOLARIS 0322 /* Solaris has inttypes.h but not stdint.h. */ 0323 # define U_HAVE_STDINT_H 0 0324 #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER) 0325 /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */ 0326 # define U_HAVE_STDINT_H 0 0327 #else 0328 # define U_HAVE_STDINT_H 1 0329 #endif 0330 0331 /** 0332 * \def U_HAVE_INTTYPES_H 0333 * Defines whether inttypes.h is available. It is a C99 standard header. 0334 * We include inttypes.h where it is available but stdint.h is not. 0335 * @internal 0336 */ 0337 #ifdef U_HAVE_INTTYPES_H 0338 /* Use the predefined value. */ 0339 #elif U_PLATFORM == U_PF_SOLARIS 0340 /* Solaris has inttypes.h but not stdint.h. */ 0341 # define U_HAVE_INTTYPES_H 1 0342 #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER) 0343 /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */ 0344 # define U_HAVE_INTTYPES_H 1 0345 #else 0346 /* Most platforms have both inttypes.h and stdint.h, or neither. */ 0347 # define U_HAVE_INTTYPES_H U_HAVE_STDINT_H 0348 #endif 0349 0350 /*===========================================================================*/ 0351 /** @{ Compiler and environment features */ 0352 /*===========================================================================*/ 0353 0354 /** 0355 * \def U_GCC_MAJOR_MINOR 0356 * Indicates whether the compiler is gcc (test for != 0), 0357 * and if so, contains its major (times 100) and minor version numbers. 0358 * If the compiler is not gcc, then U_GCC_MAJOR_MINOR == 0. 0359 * 0360 * For example, for testing for whether we have gcc, and whether it's 4.6 or higher, 0361 * use "#if U_GCC_MAJOR_MINOR >= 406". 0362 * @internal 0363 */ 0364 #ifdef __GNUC__ 0365 # define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__) 0366 #else 0367 # define U_GCC_MAJOR_MINOR 0 0368 #endif 0369 0370 /** 0371 * \def U_IS_BIG_ENDIAN 0372 * Determines the endianness of the platform. 0373 * @internal 0374 */ 0375 #ifdef U_IS_BIG_ENDIAN 0376 /* Use the predefined value. */ 0377 #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN) 0378 # define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN) 0379 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) 0380 /* gcc */ 0381 # define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) 0382 #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN) 0383 # define U_IS_BIG_ENDIAN 1 0384 #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN) 0385 # define U_IS_BIG_ENDIAN 0 0386 #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__) 0387 /* These platforms do not appear to predefine any endianness macros. */ 0388 # define U_IS_BIG_ENDIAN 1 0389 #elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) 0390 /* HPPA do not appear to predefine any endianness macros. */ 0391 # define U_IS_BIG_ENDIAN 1 0392 #elif defined(sparc) || defined(__sparc) || defined(__sparc__) 0393 /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */ 0394 # define U_IS_BIG_ENDIAN 1 0395 #else 0396 # define U_IS_BIG_ENDIAN 0 0397 #endif 0398 0399 /** 0400 * \def U_HAVE_PLACEMENT_NEW 0401 * Determines whether to override placement new and delete for STL. 0402 * @stable ICU 2.6 0403 */ 0404 #ifdef U_HAVE_PLACEMENT_NEW 0405 /* Use the predefined value. */ 0406 #elif defined(__BORLANDC__) 0407 # define U_HAVE_PLACEMENT_NEW 0 0408 #else 0409 # define U_HAVE_PLACEMENT_NEW 1 0410 #endif 0411 0412 /** 0413 * \def U_HAVE_DEBUG_LOCATION_NEW 0414 * Define this to define the MFC debug version of the operator new. 0415 * 0416 * @stable ICU 3.4 0417 */ 0418 #ifdef U_HAVE_DEBUG_LOCATION_NEW 0419 /* Use the predefined value. */ 0420 #elif defined(_MSC_VER) 0421 # define U_HAVE_DEBUG_LOCATION_NEW 1 0422 #else 0423 # define U_HAVE_DEBUG_LOCATION_NEW 0 0424 #endif 0425 0426 /* Compatibility with compilers other than clang: http://clang.llvm.org/docs/LanguageExtensions.html */ 0427 #ifdef __has_attribute 0428 # define UPRV_HAS_ATTRIBUTE(x) __has_attribute(x) 0429 #else 0430 # define UPRV_HAS_ATTRIBUTE(x) 0 0431 #endif 0432 #ifdef __has_cpp_attribute 0433 # define UPRV_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) 0434 #else 0435 # define UPRV_HAS_CPP_ATTRIBUTE(x) 0 0436 #endif 0437 #ifdef __has_declspec_attribute 0438 # define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) __has_declspec_attribute(x) 0439 #else 0440 # define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) 0 0441 #endif 0442 #ifdef __has_builtin 0443 # define UPRV_HAS_BUILTIN(x) __has_builtin(x) 0444 #else 0445 # define UPRV_HAS_BUILTIN(x) 0 0446 #endif 0447 #ifdef __has_feature 0448 # define UPRV_HAS_FEATURE(x) __has_feature(x) 0449 #else 0450 # define UPRV_HAS_FEATURE(x) 0 0451 #endif 0452 #ifdef __has_extension 0453 # define UPRV_HAS_EXTENSION(x) __has_extension(x) 0454 #else 0455 # define UPRV_HAS_EXTENSION(x) 0 0456 #endif 0457 #ifdef __has_warning 0458 # define UPRV_HAS_WARNING(x) __has_warning(x) 0459 #else 0460 # define UPRV_HAS_WARNING(x) 0 0461 #endif 0462 0463 0464 #if defined(__clang__) 0465 #define UPRV_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined"))) 0466 #else 0467 #define UPRV_NO_SANITIZE_UNDEFINED 0468 #endif 0469 0470 /** 0471 * \def U_MALLOC_ATTR 0472 * Attribute to mark functions as malloc-like 0473 * @internal 0474 */ 0475 #if defined(__GNUC__) && __GNUC__>=3 0476 # define U_MALLOC_ATTR __attribute__ ((__malloc__)) 0477 #else 0478 # define U_MALLOC_ATTR 0479 #endif 0480 0481 /** 0482 * \def U_ALLOC_SIZE_ATTR 0483 * Attribute to specify the size of the allocated buffer for malloc-like functions 0484 * @internal 0485 */ 0486 #if (defined(__GNUC__) && \ 0487 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \ 0488 UPRV_HAS_ATTRIBUTE(alloc_size) 0489 # define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X))) 0490 # define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y))) 0491 #else 0492 # define U_ALLOC_SIZE_ATTR(X) 0493 # define U_ALLOC_SIZE_ATTR2(X,Y) 0494 #endif 0495 0496 /** 0497 * \def U_CPLUSPLUS_VERSION 0498 * 0 if no C++; 1, 11, 14, ... if C++. 0499 * Support for specific features cannot always be determined by the C++ version alone. 0500 * @internal 0501 */ 0502 #ifdef U_CPLUSPLUS_VERSION 0503 # if U_CPLUSPLUS_VERSION != 0 && !defined(__cplusplus) 0504 # undef U_CPLUSPLUS_VERSION 0505 # define U_CPLUSPLUS_VERSION 0 0506 # endif 0507 /* Otherwise use the predefined value. */ 0508 #elif !defined(__cplusplus) 0509 # define U_CPLUSPLUS_VERSION 0 0510 #elif __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) 0511 # define U_CPLUSPLUS_VERSION 14 0512 #elif __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) 0513 # define U_CPLUSPLUS_VERSION 11 0514 #else 0515 // C++98 or C++03 0516 # define U_CPLUSPLUS_VERSION 1 0517 #endif 0518 0519 /** 0520 * \def U_FALLTHROUGH 0521 * Annotate intentional fall-through between switch labels. 0522 * http://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough 0523 * @internal 0524 */ 0525 #ifndef __cplusplus 0526 // Not for C. 0527 #elif defined(U_FALLTHROUGH) 0528 // Use the predefined value. 0529 #elif defined(__clang__) 0530 // Test for compiler vs. feature separately. 0531 // Other compilers might choke on the feature test. 0532 # if UPRV_HAS_CPP_ATTRIBUTE(clang::fallthrough) || \ 0533 (UPRV_HAS_FEATURE(cxx_attributes) && \ 0534 UPRV_HAS_WARNING("-Wimplicit-fallthrough")) 0535 # define U_FALLTHROUGH [[clang::fallthrough]] 0536 # endif 0537 #elif defined(__GNUC__) && (__GNUC__ >= 7) 0538 # define U_FALLTHROUGH __attribute__((fallthrough)) 0539 #endif 0540 0541 #ifndef U_FALLTHROUGH 0542 # define U_FALLTHROUGH 0543 #endif 0544 0545 /** @} */ 0546 0547 /*===========================================================================*/ 0548 /** @{ Character data types */ 0549 /*===========================================================================*/ 0550 0551 /** 0552 * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform. 0553 * @stable ICU 2.0 0554 */ 0555 #define U_ASCII_FAMILY 0 0556 0557 /** 0558 * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform. 0559 * @stable ICU 2.0 0560 */ 0561 #define U_EBCDIC_FAMILY 1 0562 0563 /** 0564 * \def U_CHARSET_FAMILY 0565 * 0566 * <p>These definitions allow to specify the encoding of text 0567 * in the char data type as defined by the platform and the compiler. 0568 * It is enough to determine the code point values of "invariant characters", 0569 * which are the ones shared by all encodings that are in use 0570 * on a given platform.</p> 0571 * 0572 * <p>Those "invariant characters" should be all the uppercase and lowercase 0573 * latin letters, the digits, the space, and "basic punctuation". 0574 * Also, '\\n', '\\r', '\\t' should be available.</p> 0575 * 0576 * <p>The list of "invariant characters" is:<br> 0577 * \code 0578 * A-Z a-z 0-9 SPACE " % & ' ( ) * + , - . / : ; < = > ? _ 0579 * \endcode 0580 * <br> 0581 * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)</p> 0582 * 0583 * <p>This matches the IBM Syntactic Character Set (CS 640).</p> 0584 * 0585 * <p>In other words, all the graphic characters in 7-bit ASCII should 0586 * be safely accessible except the following:</p> 0587 * 0588 * \code 0589 * '\' <backslash> 0590 * '[' <left bracket> 0591 * ']' <right bracket> 0592 * '{' <left brace> 0593 * '}' <right brace> 0594 * '^' <circumflex> 0595 * '~' <tilde> 0596 * '!' <exclamation mark> 0597 * '#' <number sign> 0598 * '|' <vertical line> 0599 * '$' <dollar sign> 0600 * '@' <commercial at> 0601 * '`' <grave accent> 0602 * \endcode 0603 * @stable ICU 2.0 0604 */ 0605 #ifdef U_CHARSET_FAMILY 0606 /* Use the predefined value. */ 0607 #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB) 0608 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY 0609 #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__) 0610 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY 0611 #else 0612 # define U_CHARSET_FAMILY U_ASCII_FAMILY 0613 #endif 0614 0615 /** 0616 * \def U_CHARSET_IS_UTF8 0617 * 0618 * Hardcode the default charset to UTF-8. 0619 * 0620 * If this is set to 1, then 0621 * - ICU will assume that all non-invariant char*, StringPiece, std::string etc. 0622 * contain UTF-8 text, regardless of what the system API uses 0623 * - some ICU code will use fast functions like u_strFromUTF8() 0624 * rather than the more general and more heavy-weight conversion API (ucnv.h) 0625 * - ucnv_getDefaultName() always returns "UTF-8" 0626 * - ucnv_setDefaultName() is disabled and will not change the default charset 0627 * - static builds of ICU are smaller 0628 * - more functionality is available with the UCONFIG_NO_CONVERSION build-time 0629 * configuration option (see unicode/uconfig.h) 0630 * - the UCONFIG_NO_CONVERSION build option in uconfig.h is more usable 0631 * 0632 * @stable ICU 4.2 0633 * @see UCONFIG_NO_CONVERSION 0634 */ 0635 #ifdef U_CHARSET_IS_UTF8 0636 /* Use the predefined value. */ 0637 #elif U_PLATFORM_IS_LINUX_BASED || U_PLATFORM_IS_DARWIN_BASED || \ 0638 U_PLATFORM == U_PF_EMSCRIPTEN 0639 # define U_CHARSET_IS_UTF8 1 0640 #else 0641 # define U_CHARSET_IS_UTF8 0 0642 #endif 0643 0644 /** @} */ 0645 0646 /*===========================================================================*/ 0647 /** @{ Information about wchar support */ 0648 /*===========================================================================*/ 0649 0650 /** 0651 * \def U_HAVE_WCHAR_H 0652 * Indicates whether <wchar.h> is available (1) or not (0). Set to 1 by default. 0653 * 0654 * @stable ICU 2.0 0655 */ 0656 #ifdef U_HAVE_WCHAR_H 0657 /* Use the predefined value. */ 0658 #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9 0659 /* 0660 * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t. 0661 * The type and header existed, but the library functions did not work as expected. 0662 * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway. 0663 */ 0664 # define U_HAVE_WCHAR_H 0 0665 #else 0666 # define U_HAVE_WCHAR_H 1 0667 #endif 0668 0669 /** 0670 * \def U_SIZEOF_WCHAR_T 0671 * U_SIZEOF_WCHAR_T==sizeof(wchar_t) 0672 * 0673 * @stable ICU 2.0 0674 */ 0675 #ifdef U_SIZEOF_WCHAR_T 0676 /* Use the predefined value. */ 0677 #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9) 0678 /* 0679 * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring. 0680 * Newer Mac OS X has size 4. 0681 */ 0682 # define U_SIZEOF_WCHAR_T 1 0683 #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN 0684 # define U_SIZEOF_WCHAR_T 2 0685 #elif U_PLATFORM == U_PF_AIX 0686 /* 0687 * AIX 6.1 information, section "Wide character data representation": 0688 * "... the wchar_t datatype is 32-bit in the 64-bit environment and 0689 * 16-bit in the 32-bit environment." 0690 * and 0691 * "All locales use Unicode for their wide character code values (process code), 0692 * except the IBM-eucTW codeset." 0693 */ 0694 # ifdef __64BIT__ 0695 # define U_SIZEOF_WCHAR_T 4 0696 # else 0697 # define U_SIZEOF_WCHAR_T 2 0698 # endif 0699 #elif U_PLATFORM == U_PF_OS390 0700 /* 0701 * z/OS V1R11 information center, section "LP64 | ILP32": 0702 * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes. 0703 * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes." 0704 */ 0705 # ifdef _LP64 0706 # define U_SIZEOF_WCHAR_T 4 0707 # else 0708 # define U_SIZEOF_WCHAR_T 2 0709 # endif 0710 #elif U_PLATFORM == U_PF_OS400 0711 # if defined(__UTF32__) 0712 /* 0713 * LOCALETYPE(*LOCALEUTF) is specified. 0714 * Wide-character strings are in UTF-32, 0715 * narrow-character strings are in UTF-8. 0716 */ 0717 # define U_SIZEOF_WCHAR_T 4 0718 # elif defined(__UCS2__) 0719 /* 0720 * LOCALETYPE(*LOCALEUCS2) is specified. 0721 * Wide-character strings are in UCS-2, 0722 * narrow-character strings are in EBCDIC. 0723 */ 0724 # define U_SIZEOF_WCHAR_T 2 0725 # else 0726 /* 0727 * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified. 0728 * Wide-character strings are in 16-bit EBCDIC, 0729 * narrow-character strings are in EBCDIC. 0730 */ 0731 # define U_SIZEOF_WCHAR_T 2 0732 # endif 0733 #else 0734 # define U_SIZEOF_WCHAR_T 4 0735 #endif 0736 0737 #ifndef U_HAVE_WCSCPY 0738 #define U_HAVE_WCSCPY U_HAVE_WCHAR_H 0739 #endif 0740 0741 /** @} */ 0742 0743 /** 0744 * \def U_HAVE_CHAR16_T 0745 * Defines whether the char16_t type is available for UTF-16 0746 * and u"abc" UTF-16 string literals are supported. 0747 * This is a new standard type and standard string literal syntax in C++11 0748 * but has been available in some compilers before. 0749 * @internal 0750 */ 0751 #ifdef U_HAVE_CHAR16_T 0752 /* Use the predefined value. */ 0753 #else 0754 /* 0755 * Notes: 0756 * C++11 and C11 require support for UTF-16 literals 0757 * TODO: Fix for plain C. Doesn't work on Mac. 0758 */ 0759 # if U_CPLUSPLUS_VERSION >= 11 || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) 0760 # define U_HAVE_CHAR16_T 1 0761 # else 0762 # define U_HAVE_CHAR16_T 0 0763 # endif 0764 #endif 0765 0766 /** 0767 * @{ 0768 * \def U_DECLARE_UTF16 0769 * Do not use this macro because it is not defined on all platforms. 0770 * Use the UNICODE_STRING or U_STRING_DECL macros instead. 0771 * @internal 0772 */ 0773 #ifdef U_DECLARE_UTF16 0774 /* Use the predefined value. */ 0775 #elif U_HAVE_CHAR16_T \ 0776 || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \ 0777 || (defined(__HP_aCC) && __HP_aCC >= 035000) \ 0778 || (defined(__HP_cc) && __HP_cc >= 111106) \ 0779 || (defined(U_IN_DOXYGEN)) 0780 # define U_DECLARE_UTF16(string) u ## string 0781 #elif U_SIZEOF_WCHAR_T == 2 \ 0782 && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__))) 0783 # define U_DECLARE_UTF16(string) L ## string 0784 #else 0785 /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */ 0786 #endif 0787 0788 /** @} */ 0789 0790 /*===========================================================================*/ 0791 /** @{ Symbol import-export control */ 0792 /*===========================================================================*/ 0793 0794 #ifdef U_EXPORT 0795 /* Use the predefined value. */ 0796 #elif defined(U_STATIC_IMPLEMENTATION) 0797 # define U_EXPORT 0798 #elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllexport__) && \ 0799 UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllimport__)) 0800 # define U_EXPORT __declspec(dllexport) 0801 #elif defined(__GNUC__) 0802 # define U_EXPORT __attribute__((visibility("default"))) 0803 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \ 0804 || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) 0805 # define U_EXPORT __global 0806 /*#elif defined(__HP_aCC) || defined(__HP_cc) 0807 # define U_EXPORT __declspec(dllexport)*/ 0808 #else 0809 # define U_EXPORT 0810 #endif 0811 0812 /* U_CALLCONV is related to U_EXPORT2 */ 0813 #ifdef U_EXPORT2 0814 /* Use the predefined value. */ 0815 #elif defined(_MSC_VER) 0816 # define U_EXPORT2 __cdecl 0817 #else 0818 # define U_EXPORT2 0819 #endif 0820 0821 #ifdef U_IMPORT 0822 /* Use the predefined value. */ 0823 #elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllexport__) && \ 0824 UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllimport__)) 0825 /* Windows needs to export/import data. */ 0826 # define U_IMPORT __declspec(dllimport) 0827 #else 0828 # define U_IMPORT 0829 #endif 0830 0831 /** 0832 * \def U_HIDDEN 0833 * This is used to mark internal structs declared within external classes, 0834 * to prevent the internal structs from having the same visibility as the 0835 * class within which they are declared. 0836 * @internal 0837 */ 0838 #ifdef U_HIDDEN 0839 /* Use the predefined value. */ 0840 #elif defined(__GNUC__) 0841 # define U_HIDDEN __attribute__((visibility("hidden"))) 0842 #else 0843 # define U_HIDDEN 0844 #endif 0845 0846 /** 0847 * \def U_CALLCONV 0848 * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary 0849 * in callback function typedefs to make sure that the calling convention 0850 * is compatible. 0851 * 0852 * This is only used for non-ICU-API functions. 0853 * When a function is a public ICU API, 0854 * you must use the U_CAPI and U_EXPORT2 qualifiers. 0855 * 0856 * Please note, you need to use U_CALLCONV after the *. 0857 * 0858 * NO : "static const char U_CALLCONV *func( . . . )" 0859 * YES: "static const char* U_CALLCONV func( . . . )" 0860 * 0861 * @stable ICU 2.0 0862 */ 0863 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus) 0864 # define U_CALLCONV __cdecl 0865 #else 0866 # define U_CALLCONV U_EXPORT2 0867 #endif 0868 0869 /** 0870 * \def U_CALLCONV_FPTR 0871 * Similar to U_CALLCONV, but only used on function pointers. 0872 * @internal 0873 */ 0874 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus) 0875 # define U_CALLCONV_FPTR U_CALLCONV 0876 #else 0877 # define U_CALLCONV_FPTR 0878 #endif 0879 /** @} */ 0880 0881 #endif // _PLATFORM_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |