1/* 2****************************************************************************** 3* 4* Copyright (C) 1997-2013, 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/** Native Client is pretty close to Linux. @internal */ 125#define U_PF_NATIVE_CLIENT 4050 126/** Android is based on Linux. @internal */ 127#define U_PF_ANDROID 4100 128/** "Classic" Mac OS (1984-2001) @internal */ 129#define U_PF_CLASSIC_MACOS 8000 130/** z/OS is the successor to OS/390 which was the successor to MVS. @internal */ 131#define U_PF_OS390 9000 132/** "IBM i" is the current name of what used to be i5/OS and earlier OS/400. @internal */ 133#define U_PF_OS400 9400 134 135#ifdef U_PLATFORM 136 /* Use the predefined value. */ 137#elif defined(__MINGW32__) 138# define U_PLATFORM U_PF_MINGW 139#elif defined(__CYGWIN__) 140# define U_PLATFORM U_PF_CYGWIN 141#elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) 142# define U_PLATFORM U_PF_WINDOWS 143#elif defined(__ANDROID__) 144# define U_PLATFORM U_PF_ANDROID 145 /* Android wchar_t support depends on the API level. */ 146# include <android/api-level.h> 147#elif defined(__native_client__) 148# define U_PLATFORM U_PF_NATIVE_CLIENT 149#elif defined(linux) || defined(__linux__) || defined(__linux) 150# define U_PLATFORM U_PF_LINUX 151#elif defined(__APPLE__) && defined(__MACH__) 152# include <TargetConditionals.h> 153# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* variant of TARGET_OS_MAC */ 154# define U_PLATFORM U_PF_IPHONE 155# else 156# define U_PLATFORM U_PF_DARWIN 157# endif 158#elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__) 159# define U_PLATFORM U_PF_BSD 160#elif defined(sun) || defined(__sun) 161 /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */ 162# define U_PLATFORM U_PF_SOLARIS 163# if defined(__GNUC__) 164 /* Solaris/GCC needs this header file to get the proper endianness. Normally, this 165 * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h 166 * is included which does not include this header file. 167 */ 168# include <sys/isa_defs.h> 169# endif 170#elif defined(_AIX) || defined(__TOS_AIX__) 171# define U_PLATFORM U_PF_AIX 172#elif defined(_hpux) || defined(hpux) || defined(__hpux) 173# define U_PLATFORM U_PF_HPUX 174#elif defined(sgi) || defined(__sgi) 175# define U_PLATFORM U_PF_IRIX 176#elif defined(macintosh) 177# define U_PLATFORM U_PF_CLASSIC_MACOS 178#elif defined(__QNX__) || defined(__QNXNTO__) 179# define U_PLATFORM U_PF_QNX 180#elif defined(__TOS_MVS__) 181# define U_PLATFORM U_PF_OS390 182#elif defined(__OS400__) || defined(__TOS_OS400__) 183# define U_PLATFORM U_PF_OS400 184#else 185# define U_PLATFORM U_PF_UNKNOWN 186#endif 187 188/** 189 * \def CYGWINMSVC 190 * Defined if this is Windows with Cygwin, but using MSVC rather than gcc. 191 * Otherwise undefined. 192 * @internal 193 */ 194/* Commented out because this is already set in mh-cygwin-msvc 195#if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER) 196# define CYGWINMSVC 197#endif 198*/ 199 200/** 201 * \def U_PLATFORM_USES_ONLY_WIN32_API 202 * Defines whether the platform uses only the Win32 API. 203 * Set to 1 for Windows/MSVC and MinGW but not Cygwin. 204 * @internal 205 */ 206#ifdef U_PLATFORM_USES_ONLY_WIN32_API 207 /* Use the predefined value. */ 208#elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC) 209# define U_PLATFORM_USES_ONLY_WIN32_API 1 210#else 211 /* Cygwin implements POSIX. */ 212# define U_PLATFORM_USES_ONLY_WIN32_API 0 213#endif 214 215/** 216 * \def U_PLATFORM_HAS_WIN32_API 217 * Defines whether the Win32 API is available on the platform. 218 * Set to 1 for Windows/MSVC, MinGW and Cygwin. 219 * @internal 220 */ 221#ifdef U_PLATFORM_HAS_WIN32_API 222 /* Use the predefined value. */ 223#elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN 224# define U_PLATFORM_HAS_WIN32_API 1 225#else 226# define U_PLATFORM_HAS_WIN32_API 0 227#endif 228 229/** 230 * \def U_PLATFORM_IMPLEMENTS_POSIX 231 * Defines whether the platform implements (most of) the POSIX API. 232 * Set to 1 for Cygwin and most other platforms. 233 * @internal 234 */ 235#ifdef U_PLATFORM_IMPLEMENTS_POSIX 236 /* Use the predefined value. */ 237#elif U_PLATFORM_USES_ONLY_WIN32_API || U_PLATFORM == U_PF_CLASSIC_MACOS 238# define U_PLATFORM_IMPLEMENTS_POSIX 0 239#else 240# define U_PLATFORM_IMPLEMENTS_POSIX 1 241#endif 242 243/** 244 * \def U_PLATFORM_IS_LINUX_BASED 245 * Defines whether the platform is Linux or one of its derivatives. 246 * @internal 247 */ 248#ifdef U_PLATFORM_IS_LINUX_BASED 249 /* Use the predefined value. */ 250#elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= U_PF_ANDROID 251# define U_PLATFORM_IS_LINUX_BASED 1 252#else 253# define U_PLATFORM_IS_LINUX_BASED 0 254#endif 255 256/** 257 * \def U_PLATFORM_IS_DARWIN_BASED 258 * Defines whether the platform is Darwin or one of its derivatives. 259 * @internal 260 */ 261#ifdef U_PLATFORM_IS_DARWIN_BASED 262 /* Use the predefined value. */ 263#elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE 264# define U_PLATFORM_IS_DARWIN_BASED 1 265#else 266# define U_PLATFORM_IS_DARWIN_BASED 0 267#endif 268 269/** 270 * \def U_HAVE_STDINT_H 271 * Defines whether stdint.h is available. It is a C99 standard header. 272 * We used to include inttypes.h which includes stdint.h but we usually do not need 273 * the additional definitions from inttypes.h. 274 * @internal 275 */ 276#ifdef U_HAVE_STDINT_H 277 /* Use the predefined value. */ 278#elif U_PLATFORM_USES_ONLY_WIN32_API 279# if defined(__BORLANDC__) || U_PLATFORM == U_PF_MINGW || (defined(_MSC_VER) && _MSC_VER>=1600) 280 /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */ 281# define U_HAVE_STDINT_H 1 282# else 283# define U_HAVE_STDINT_H 0 284# endif 285#elif U_PLATFORM == U_PF_SOLARIS 286 /* Solaris has inttypes.h but not stdint.h. */ 287# define U_HAVE_STDINT_H 0 288#elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER) 289 /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */ 290# define U_HAVE_STDINT_H 0 291#else 292# define U_HAVE_STDINT_H 1 293#endif 294 295/** 296 * \def U_HAVE_INTTYPES_H 297 * Defines whether inttypes.h is available. It is a C99 standard header. 298 * We include inttypes.h where it is available but stdint.h is not. 299 * @internal 300 */ 301#ifdef U_HAVE_INTTYPES_H 302 /* Use the predefined value. */ 303#elif U_PLATFORM == U_PF_SOLARIS 304 /* Solaris has inttypes.h but not stdint.h. */ 305# define U_HAVE_INTTYPES_H 1 306#elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER) 307 /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */ 308# define U_HAVE_INTTYPES_H 1 309#else 310 /* Most platforms have both inttypes.h and stdint.h, or neither. */ 311# define U_HAVE_INTTYPES_H U_HAVE_STDINT_H 312#endif 313 314/** 315 * \def U_IOSTREAM_SOURCE 316 * Defines what support for C++ streams is available. 317 * 318 * If U_IOSTREAM_SOURCE is set to 199711, then <iostream> is available 319 * (the ISO/IEC C++ FDIS was published in November 1997), and then 320 * one should qualify streams using the std namespace in ICU header 321 * files. 322 * Starting with ICU 49, this is the only supported version. 323 * 324 * If U_IOSTREAM_SOURCE is set to 198506, then <iostream.h> is 325 * available instead (in June 1985 Stroustrup published 326 * "An Extensible I/O Facility for C++" at the summer USENIX conference). 327 * Starting with ICU 49, this version is not supported any more. 328 * 329 * If U_IOSTREAM_SOURCE is 0 (or any value less than 199711), 330 * then C++ streams are not available and 331 * support for them will be silently suppressed in ICU. 332 * 333 * @internal 334 */ 335#ifndef U_IOSTREAM_SOURCE 336#define U_IOSTREAM_SOURCE 199711 337#endif 338 339/** 340 * \def U_HAVE_STD_STRING 341 * Defines whether the standard C++ (STL) <string> header is available. 342 * @internal 343 */ 344#ifdef U_HAVE_STD_STRING 345 /* Use the predefined value. */ 346#else 347# define U_HAVE_STD_STRING 1 348#endif 349 350/*===========================================================================*/ 351/** @{ Compiler and environment features */ 352/*===========================================================================*/ 353 354/** 355 * \def U_GCC_MAJOR_MINOR 356 * Indicates whether the compiler is gcc (test for != 0), 357 * and if so, contains its major (times 100) and minor version numbers. 358 * If the compiler is not gcc, then U_GCC_MAJOR_MINOR == 0. 359 * 360 * For example, for testing for whether we have gcc, and whether it's 4.6 or higher, 361 * use "#if U_GCC_MAJOR_MINOR >= 406". 362 * @internal 363 */ 364#ifdef __GNUC__ 365# define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__) 366#else 367# define U_GCC_MAJOR_MINOR 0 368#endif 369 370/** 371 * \def U_IS_BIG_ENDIAN 372 * Determines the endianness of the platform. 373 * @internal 374 */ 375#ifdef U_IS_BIG_ENDIAN 376 /* Use the predefined value. */ 377#elif defined(BYTE_ORDER) && defined(BIG_ENDIAN) 378# define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN) 379#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) 380 /* gcc */ 381# define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) 382#elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN) 383# define U_IS_BIG_ENDIAN 1 384#elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN) 385# define U_IS_BIG_ENDIAN 0 386#elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__) 387 /* These platforms do not appear to predefine any endianness macros. */ 388# define U_IS_BIG_ENDIAN 1 389#elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) 390 /* HPPA do not appear to predefine any endianness macros. */ 391# define U_IS_BIG_ENDIAN 1 392#elif defined(sparc) || defined(__sparc) || defined(__sparc__) 393 /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */ 394# define U_IS_BIG_ENDIAN 1 395#else 396# define U_IS_BIG_ENDIAN 0 397#endif 398 399/** 400 * \def U_HAVE_PLACEMENT_NEW 401 * Determines whether to override placement new and delete for STL. 402 * @stable ICU 2.6 403 */ 404#ifdef U_HAVE_PLACEMENT_NEW 405 /* Use the predefined value. */ 406#elif defined(__BORLANDC__) 407# define U_HAVE_PLACEMENT_NEW 0 408#else 409# define U_HAVE_PLACEMENT_NEW 1 410#endif 411 412/** 413 * \def U_HAVE_DEBUG_LOCATION_NEW 414 * Define this to define the MFC debug version of the operator new. 415 * 416 * @stable ICU 3.4 417 */ 418#ifdef U_HAVE_DEBUG_LOCATION_NEW 419 /* Use the predefined value. */ 420#elif defined(_MSC_VER) 421# define U_HAVE_DEBUG_LOCATION_NEW 1 422#else 423# define U_HAVE_DEBUG_LOCATION_NEW 0 424#endif 425 426/* Compatibility with non clang compilers */ 427#ifndef __has_attribute 428# define __has_attribute(x) 0 429#endif 430 431/** 432 * \def U_MALLOC_ATTR 433 * Attribute to mark functions as malloc-like 434 * @internal 435 */ 436#if defined(__GNUC__) && __GNUC__>=3 437# define U_MALLOC_ATTR __attribute__ ((__malloc__)) 438#else 439# define U_MALLOC_ATTR 440#endif 441 442/** 443 * \def U_ALLOC_SIZE_ATTR 444 * Attribute to specify the size of the allocated buffer for malloc-like functions 445 * @internal 446 */ 447#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || __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 457/*===========================================================================*/ 458/** @{ Character data types */ 459/*===========================================================================*/ 460 461/** 462 * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform. 463 * @stable ICU 2.0 464 */ 465#define U_ASCII_FAMILY 0 466 467/** 468 * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform. 469 * @stable ICU 2.0 470 */ 471#define U_EBCDIC_FAMILY 1 472 473/** 474 * \def U_CHARSET_FAMILY 475 * 476 * <p>These definitions allow to specify the encoding of text 477 * in the char data type as defined by the platform and the compiler. 478 * It is enough to determine the code point values of "invariant characters", 479 * which are the ones shared by all encodings that are in use 480 * on a given platform.</p> 481 * 482 * <p>Those "invariant characters" should be all the uppercase and lowercase 483 * latin letters, the digits, the space, and "basic punctuation". 484 * Also, '\\n', '\\r', '\\t' should be available.</p> 485 * 486 * <p>The list of "invariant characters" is:<br> 487 * \code 488 * A-Z a-z 0-9 SPACE " % & ' ( ) * + , - . / : ; < = > ? _ 489 * \endcode 490 * <br> 491 * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)</p> 492 * 493 * <p>This matches the IBM Syntactic Character Set (CS 640).</p> 494 * 495 * <p>In other words, all the graphic characters in 7-bit ASCII should 496 * be safely accessible except the following:</p> 497 * 498 * \code 499 * '\' <backslash> 500 * '[' <left bracket> 501 * ']' <right bracket> 502 * '{' <left brace> 503 * '}' <right brace> 504 * '^' <circumflex> 505 * '~' <tilde> 506 * '!' <exclamation mark> 507 * '#' <number sign> 508 * '|' <vertical line> 509 * '$' <dollar sign> 510 * '@' <commercial at> 511 * '`' <grave accent> 512 * \endcode 513 * @stable ICU 2.0 514 */ 515#ifdef U_CHARSET_FAMILY 516 /* Use the predefined value. */ 517#elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB) 518# define U_CHARSET_FAMILY U_EBCDIC_FAMILY 519#elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__) 520# define U_CHARSET_FAMILY U_EBCDIC_FAMILY 521#else 522# define U_CHARSET_FAMILY U_ASCII_FAMILY 523#endif 524 525/** 526 * \def U_CHARSET_IS_UTF8 527 * 528 * Hardcode the default charset to UTF-8. 529 * 530 * If this is set to 1, then 531 * - ICU will assume that all non-invariant char*, StringPiece, std::string etc. 532 * contain UTF-8 text, regardless of what the system API uses 533 * - some ICU code will use fast functions like u_strFromUTF8() 534 * rather than the more general and more heavy-weight conversion API (ucnv.h) 535 * - ucnv_getDefaultName() always returns "UTF-8" 536 * - ucnv_setDefaultName() is disabled and will not change the default charset 537 * - static builds of ICU are smaller 538 * - more functionality is available with the UCONFIG_NO_CONVERSION build-time 539 * configuration option (see unicode/uconfig.h) 540 * - the UCONFIG_NO_CONVERSION build option in uconfig.h is more usable 541 * 542 * @stable ICU 4.2 543 * @see UCONFIG_NO_CONVERSION 544 */ 545#ifdef U_CHARSET_IS_UTF8 546 /* Use the predefined value. */ 547#elif U_PLATFORM == U_PF_ANDROID || U_PLATFORM_IS_DARWIN_BASED 548# define U_CHARSET_IS_UTF8 1 549#else 550# define U_CHARSET_IS_UTF8 0 551#endif 552 553/** @} */ 554 555/*===========================================================================*/ 556/** @{ Information about wchar support */ 557/*===========================================================================*/ 558 559/** 560 * \def U_HAVE_WCHAR_H 561 * Indicates whether <wchar.h> is available (1) or not (0). Set to 1 by default. 562 * 563 * @stable ICU 2.0 564 */ 565#ifdef U_HAVE_WCHAR_H 566 /* Use the predefined value. */ 567#elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9 568 /* 569 * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t. 570 * The type and header existed, but the library functions did not work as expected. 571 * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway. 572 */ 573# define U_HAVE_WCHAR_H 0 574#else 575# define U_HAVE_WCHAR_H 1 576#endif 577 578/** 579 * \def U_SIZEOF_WCHAR_T 580 * U_SIZEOF_WCHAR_T==sizeof(wchar_t) 581 * 582 * @stable ICU 2.0 583 */ 584#ifdef U_SIZEOF_WCHAR_T 585 /* Use the predefined value. */ 586#elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9) || U_PLATFORM == U_PF_CLASSIC_MACOS 587 /* 588 * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring. 589 * Newer Mac OS X has size 4. 590 */ 591# define U_SIZEOF_WCHAR_T 1 592#elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN 593# define U_SIZEOF_WCHAR_T 2 594#elif U_PLATFORM == U_PF_AIX 595 /* 596 * AIX 6.1 information, section "Wide character data representation": 597 * "... the wchar_t datatype is 32-bit in the 64-bit environment and 598 * 16-bit in the 32-bit environment." 599 * and 600 * "All locales use Unicode for their wide character code values (process code), 601 * except the IBM-eucTW codeset." 602 */ 603# ifdef __64BIT__ 604# define U_SIZEOF_WCHAR_T 4 605# else 606# define U_SIZEOF_WCHAR_T 2 607# endif 608#elif U_PLATFORM == U_PF_OS390 609 /* 610 * z/OS V1R11 information center, section "LP64 | ILP32": 611 * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes. 612 * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes." 613 */ 614# ifdef _LP64 615# define U_SIZEOF_WCHAR_T 4 616# else 617# define U_SIZEOF_WCHAR_T 2 618# endif 619#elif U_PLATFORM == U_PF_OS400 620# if defined(__UTF32__) 621 /* 622 * LOCALETYPE(*LOCALEUTF) is specified. 623 * Wide-character strings are in UTF-32, 624 * narrow-character strings are in UTF-8. 625 */ 626# define U_SIZEOF_WCHAR_T 4 627# elif defined(__UCS2__) 628 /* 629 * LOCALETYPE(*LOCALEUCS2) is specified. 630 * Wide-character strings are in UCS-2, 631 * narrow-character strings are in EBCDIC. 632 */ 633# define U_SIZEOF_WCHAR_T 2 634#else 635 /* 636 * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified. 637 * Wide-character strings are in 16-bit EBCDIC, 638 * narrow-character strings are in EBCDIC. 639 */ 640# define U_SIZEOF_WCHAR_T 2 641# endif 642#else 643# define U_SIZEOF_WCHAR_T 4 644#endif 645 646#ifndef U_HAVE_WCSCPY 647#define U_HAVE_WCSCPY U_HAVE_WCHAR_H 648#endif 649 650/** @} */ 651 652/** 653 * \def U_HAVE_CHAR16_T 654 * Defines whether the char16_t type is available for UTF-16 655 * and u"abc" UTF-16 string literals are supported. 656 * This is a new standard type and standard string literal syntax in C++0x 657 * but has been available in some compilers before. 658 * @internal 659 */ 660#ifdef U_HAVE_CHAR16_T 661 /* Use the predefined value. */ 662#else 663 /* 664 * Notes: 665 * Visual Studio 10 (_MSC_VER>=1600) defines char16_t but 666 * does not support u"abc" string literals. 667 * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but 668 * does not support u"abc" string literals. 669 * C++11 and C11 require support for UTF-16 literals 670 */ 671# if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) 672# define U_HAVE_CHAR16_T 1 673# else 674# define U_HAVE_CHAR16_T 0 675# endif 676#endif 677 678/** 679 * @{ 680 * \def U_DECLARE_UTF16 681 * Do not use this macro because it is not defined on all platforms. 682 * Use the UNICODE_STRING or U_STRING_DECL macros instead. 683 * @internal 684 */ 685#ifdef U_DECLARE_UTF16 686 /* Use the predefined value. */ 687#elif U_HAVE_CHAR16_T \ 688 || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \ 689 || (defined(__HP_aCC) && __HP_aCC >= 035000) \ 690 || (defined(__HP_cc) && __HP_cc >= 111106) 691# define U_DECLARE_UTF16(string) u ## string 692#elif U_SIZEOF_WCHAR_T == 2 \ 693 && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__))) 694# define U_DECLARE_UTF16(string) L ## string 695#else 696 /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */ 697#endif 698 699/** @} */ 700 701/*===========================================================================*/ 702/** @{ Symbol import-export control */ 703/*===========================================================================*/ 704 705#ifdef U_EXPORT 706 /* Use the predefined value. */ 707#elif defined(U_STATIC_IMPLEMENTATION) 708# define U_EXPORT 709#elif defined(__GNUC__) 710# define U_EXPORT __attribute__((visibility("default"))) 711#elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \ 712 || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) 713# define U_EXPORT __global 714/*#elif defined(__HP_aCC) || defined(__HP_cc) 715# define U_EXPORT __declspec(dllexport)*/ 716#elif defined(_MSC_VER) 717# define U_EXPORT __declspec(dllexport) 718#else 719# define U_EXPORT 720#endif 721 722/* U_CALLCONV is releated to U_EXPORT2 */ 723#ifdef U_EXPORT2 724 /* Use the predefined value. */ 725#elif defined(_MSC_VER) 726# define U_EXPORT2 __cdecl 727#else 728# define U_EXPORT2 729#endif 730 731#ifdef U_IMPORT 732 /* Use the predefined value. */ 733#elif defined(_MSC_VER) 734 /* Windows needs to export/import data. */ 735# define U_IMPORT __declspec(dllimport) 736#else 737# define U_IMPORT 738#endif 739 740/** 741 * \def U_CALLCONV 742 * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary 743 * in callback function typedefs to make sure that the calling convention 744 * is compatible. 745 * 746 * This is only used for non-ICU-API functions. 747 * When a function is a public ICU API, 748 * you must use the U_CAPI and U_EXPORT2 qualifiers. 749 * @stable ICU 2.0 750 */ 751#if U_PLATFORM == U_PF_OS390 && defined(__cplusplus) 752# define U_CALLCONV __cdecl 753#else 754# define U_CALLCONV U_EXPORT2 755#endif 756 757/* @} */ 758 759#endif 760