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