michael@0: /* michael@0: ****************************************************************************** michael@0: * michael@0: * Copyright (C) 1997-2013, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: * michael@0: ****************************************************************************** michael@0: * michael@0: * FILE NAME : platform.h michael@0: * michael@0: * Date Name Description michael@0: * 05/13/98 nos Creation (content moved here from ptypes.h). michael@0: * 03/02/99 stephen Added AS400 support. michael@0: * 03/30/99 stephen Added Linux support. michael@0: * 04/13/99 stephen Reworked for autoconf. michael@0: ****************************************************************************** michael@0: */ michael@0: michael@0: #ifndef _PLATFORM_H michael@0: #define _PLATFORM_H michael@0: michael@0: #include "unicode/uconfig.h" michael@0: #include "unicode/uvernum.h" michael@0: michael@0: /** michael@0: * \file michael@0: * \brief Basic types for the platform. michael@0: * michael@0: * This file used to be generated by autoconf/configure. michael@0: * Starting with ICU 49, platform.h is a normal source file, michael@0: * to simplify cross-compiling and working with non-autoconf/make build systems. michael@0: * michael@0: * When a value in this file does not work on a platform, then please michael@0: * try to derive it from the U_PLATFORM value michael@0: * (for which we might need a new value constant in rare cases) michael@0: * and/or from other macros that are predefined by the compiler michael@0: * or defined in standard (POSIX or platform or compiler) headers. michael@0: * michael@0: * As a temporary workaround, you can add an explicit #define for some macros michael@0: * before it is first tested, or add an equivalent -D macro definition michael@0: * to the compiler's command line. michael@0: * michael@0: * Note: Some compilers provide ways to show the predefined macros. michael@0: * For example, with gcc you can compile an empty .c file and have the compiler michael@0: * print the predefined macros with michael@0: * \code michael@0: * gcc -E -dM -x c /dev/null | sort michael@0: * \endcode michael@0: * (You can provide an actual empty .c file rather than /dev/null. michael@0: * -x c++ is for C++.) michael@0: */ michael@0: michael@0: /** michael@0: * Define some things so that they can be documented. michael@0: * @internal michael@0: */ michael@0: #ifdef U_IN_DOXYGEN michael@0: /* michael@0: * Problem: "platform.h:335: warning: documentation for unknown define U_HAVE_STD_STRING found." means that U_HAVE_STD_STRING is not documented. michael@0: * 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. michael@0: */ michael@0: michael@0: /* None for now. */ michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_PLATFORM michael@0: * The U_PLATFORM macro defines the platform we're on. michael@0: * michael@0: * We used to define one different, value-less macro per platform. michael@0: * That made it hard to know the set of relevant platforms and macros, michael@0: * and hard to deal with variants of platforms. michael@0: * michael@0: * Starting with ICU 49, we define platforms as numeric macros, michael@0: * with ranges of values for related platforms and their variants. michael@0: * The U_PLATFORM macro is set to one of these values. michael@0: * michael@0: * Historical note from the Solaris Wikipedia article: michael@0: * AT&T and Sun collaborated on a project to merge the most popular Unix variants michael@0: * on the market at that time: BSD, System V, and Xenix. michael@0: * This became Unix System V Release 4 (SVR4). michael@0: * michael@0: * @internal michael@0: */ michael@0: michael@0: /** Unknown platform. @internal */ michael@0: #define U_PF_UNKNOWN 0 michael@0: /** Windows @internal */ michael@0: #define U_PF_WINDOWS 1000 michael@0: /** MinGW. Windows, calls to Win32 API, but using GNU gcc and binutils. @internal */ michael@0: #define U_PF_MINGW 1800 michael@0: /** michael@0: * Cygwin. Windows, calls to cygwin1.dll for Posix functions, michael@0: * using MSVC or GNU gcc and binutils. michael@0: * @internal michael@0: */ michael@0: #define U_PF_CYGWIN 1900 michael@0: /* Reserve 2000 for U_PF_UNIX? */ michael@0: /** HP-UX is based on UNIX System V. @internal */ michael@0: #define U_PF_HPUX 2100 michael@0: /** Solaris is a Unix operating system based on SVR4. @internal */ michael@0: #define U_PF_SOLARIS 2600 michael@0: /** BSD is a UNIX operating system derivative. @internal */ michael@0: #define U_PF_BSD 3000 michael@0: /** AIX is based on UNIX System V Releases and 4.3 BSD. @internal */ michael@0: #define U_PF_AIX 3100 michael@0: /** IRIX is based on UNIX System V with BSD extensions. @internal */ michael@0: #define U_PF_IRIX 3200 michael@0: /** michael@0: * Darwin is a POSIX-compliant operating system, composed of code developed by Apple, michael@0: * as well as code derived from NeXTSTEP, BSD, and other projects, michael@0: * built around the Mach kernel. michael@0: * Darwin forms the core set of components upon which Mac OS X, Apple TV, and iOS are based. michael@0: * (Original description modified from WikiPedia.) michael@0: * @internal michael@0: */ michael@0: #define U_PF_DARWIN 3500 michael@0: /** iPhone OS (iOS) is a derivative of Mac OS X. @internal */ michael@0: #define U_PF_IPHONE 3550 michael@0: /** QNX is a commercial Unix-like real-time operating system related to BSD. @internal */ michael@0: #define U_PF_QNX 3700 michael@0: /** Linux is a Unix-like operating system. @internal */ michael@0: #define U_PF_LINUX 4000 michael@0: /** Android is based on Linux. @internal */ michael@0: #define U_PF_ANDROID 4050 michael@0: /** "Classic" Mac OS (1984-2001) @internal */ michael@0: #define U_PF_CLASSIC_MACOS 8000 michael@0: /** z/OS is the successor to OS/390 which was the successor to MVS. @internal */ michael@0: #define U_PF_OS390 9000 michael@0: /** "IBM i" is the current name of what used to be i5/OS and earlier OS/400. @internal */ michael@0: #define U_PF_OS400 9400 michael@0: michael@0: #ifdef U_PLATFORM michael@0: /* Use the predefined value. */ michael@0: #elif defined(__MINGW32__) michael@0: # define U_PLATFORM U_PF_MINGW michael@0: #elif defined(__CYGWIN__) michael@0: # define U_PLATFORM U_PF_CYGWIN michael@0: #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) michael@0: # define U_PLATFORM U_PF_WINDOWS michael@0: #elif defined(__ANDROID__) michael@0: # define U_PLATFORM U_PF_ANDROID michael@0: /* Android wchar_t support depends on the API level. */ michael@0: # include michael@0: #elif defined(linux) || defined(__linux__) || defined(__linux) michael@0: # define U_PLATFORM U_PF_LINUX michael@0: #elif defined(__APPLE__) && defined(__MACH__) michael@0: # include michael@0: # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* variant of TARGET_OS_MAC */ michael@0: # define U_PLATFORM U_PF_IPHONE michael@0: # else michael@0: # define U_PLATFORM U_PF_DARWIN michael@0: # endif michael@0: #elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__) michael@0: # define U_PLATFORM U_PF_BSD michael@0: #elif defined(sun) || defined(__sun) michael@0: /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */ michael@0: # define U_PLATFORM U_PF_SOLARIS michael@0: # if defined(__GNUC__) michael@0: /* Solaris/GCC needs this header file to get the proper endianness. Normally, this michael@0: * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h michael@0: * is included which does not include this header file. michael@0: */ michael@0: # include michael@0: # endif michael@0: #elif defined(_AIX) || defined(__TOS_AIX__) michael@0: # define U_PLATFORM U_PF_AIX michael@0: #elif defined(_hpux) || defined(hpux) || defined(__hpux) michael@0: # define U_PLATFORM U_PF_HPUX michael@0: #elif defined(sgi) || defined(__sgi) michael@0: # define U_PLATFORM U_PF_IRIX michael@0: #elif defined(macintosh) michael@0: # define U_PLATFORM U_PF_CLASSIC_MACOS michael@0: #elif defined(__QNX__) || defined(__QNXNTO__) michael@0: # define U_PLATFORM U_PF_QNX michael@0: #elif defined(__TOS_MVS__) michael@0: # define U_PLATFORM U_PF_OS390 michael@0: #elif defined(__OS400__) || defined(__TOS_OS400__) michael@0: # define U_PLATFORM U_PF_OS400 michael@0: #else michael@0: # define U_PLATFORM U_PF_UNKNOWN michael@0: #endif michael@0: michael@0: /** michael@0: * \def CYGWINMSVC michael@0: * Defined if this is Windows with Cygwin, but using MSVC rather than gcc. michael@0: * Otherwise undefined. michael@0: * @internal michael@0: */ michael@0: /* Commented out because this is already set in mh-cygwin-msvc michael@0: #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER) michael@0: # define CYGWINMSVC michael@0: #endif michael@0: */ michael@0: michael@0: /** michael@0: * \def U_PLATFORM_USES_ONLY_WIN32_API michael@0: * Defines whether the platform uses only the Win32 API. michael@0: * Set to 1 for Windows/MSVC and MinGW but not Cygwin. michael@0: * @internal michael@0: */ michael@0: #ifdef U_PLATFORM_USES_ONLY_WIN32_API michael@0: /* Use the predefined value. */ michael@0: #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC) michael@0: # define U_PLATFORM_USES_ONLY_WIN32_API 1 michael@0: #else michael@0: /* Cygwin implements POSIX. */ michael@0: # define U_PLATFORM_USES_ONLY_WIN32_API 0 michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_PLATFORM_HAS_WIN32_API michael@0: * Defines whether the Win32 API is available on the platform. michael@0: * Set to 1 for Windows/MSVC, MinGW and Cygwin. michael@0: * @internal michael@0: */ michael@0: #ifdef U_PLATFORM_HAS_WIN32_API michael@0: /* Use the predefined value. */ michael@0: #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN michael@0: # define U_PLATFORM_HAS_WIN32_API 1 michael@0: #else michael@0: # define U_PLATFORM_HAS_WIN32_API 0 michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_PLATFORM_IMPLEMENTS_POSIX michael@0: * Defines whether the platform implements (most of) the POSIX API. michael@0: * Set to 1 for Cygwin and most other platforms. michael@0: * @internal michael@0: */ michael@0: #ifdef U_PLATFORM_IMPLEMENTS_POSIX michael@0: /* Use the predefined value. */ michael@0: #elif U_PLATFORM_USES_ONLY_WIN32_API || U_PLATFORM == U_PF_CLASSIC_MACOS michael@0: # define U_PLATFORM_IMPLEMENTS_POSIX 0 michael@0: #else michael@0: # define U_PLATFORM_IMPLEMENTS_POSIX 1 michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_PLATFORM_IS_LINUX_BASED michael@0: * Defines whether the platform is Linux or one of its derivatives. michael@0: * @internal michael@0: */ michael@0: #ifdef U_PLATFORM_IS_LINUX_BASED michael@0: /* Use the predefined value. */ michael@0: #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= U_PF_ANDROID michael@0: # define U_PLATFORM_IS_LINUX_BASED 1 michael@0: #else michael@0: # define U_PLATFORM_IS_LINUX_BASED 0 michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_PLATFORM_IS_DARWIN_BASED michael@0: * Defines whether the platform is Darwin or one of its derivatives. michael@0: * @internal michael@0: */ michael@0: #ifdef U_PLATFORM_IS_DARWIN_BASED michael@0: /* Use the predefined value. */ michael@0: #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE michael@0: # define U_PLATFORM_IS_DARWIN_BASED 1 michael@0: #else michael@0: # define U_PLATFORM_IS_DARWIN_BASED 0 michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_HAVE_STDINT_H michael@0: * Defines whether stdint.h is available. It is a C99 standard header. michael@0: * We used to include inttypes.h which includes stdint.h but we usually do not need michael@0: * the additional definitions from inttypes.h. michael@0: * @internal michael@0: */ michael@0: #ifdef U_HAVE_STDINT_H michael@0: /* Use the predefined value. */ michael@0: #elif U_PLATFORM_USES_ONLY_WIN32_API michael@0: # if defined(__BORLANDC__) || U_PLATFORM == U_PF_MINGW || (defined(_MSC_VER) && _MSC_VER>=1600) michael@0: /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */ michael@0: # define U_HAVE_STDINT_H 1 michael@0: # else michael@0: # define U_HAVE_STDINT_H 0 michael@0: # endif michael@0: #elif U_PLATFORM == U_PF_SOLARIS michael@0: /* Solaris has inttypes.h but not stdint.h. */ michael@0: # define U_HAVE_STDINT_H 0 michael@0: #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER) michael@0: /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */ michael@0: # define U_HAVE_STDINT_H 0 michael@0: #else michael@0: # define U_HAVE_STDINT_H 1 michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_HAVE_INTTYPES_H michael@0: * Defines whether inttypes.h is available. It is a C99 standard header. michael@0: * We include inttypes.h where it is available but stdint.h is not. michael@0: * @internal michael@0: */ michael@0: #ifdef U_HAVE_INTTYPES_H michael@0: /* Use the predefined value. */ michael@0: #elif U_PLATFORM == U_PF_SOLARIS michael@0: /* Solaris has inttypes.h but not stdint.h. */ michael@0: # define U_HAVE_INTTYPES_H 1 michael@0: #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER) michael@0: /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */ michael@0: # define U_HAVE_INTTYPES_H 1 michael@0: #else michael@0: /* Most platforms have both inttypes.h and stdint.h, or neither. */ michael@0: # define U_HAVE_INTTYPES_H U_HAVE_STDINT_H michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_IOSTREAM_SOURCE michael@0: * Defines what support for C++ streams is available. michael@0: * michael@0: * If U_IOSTREAM_SOURCE is set to 199711, then <iostream> is available michael@0: * (the ISO/IEC C++ FDIS was published in November 1997), and then michael@0: * one should qualify streams using the std namespace in ICU header michael@0: * files. michael@0: * Starting with ICU 49, this is the only supported version. michael@0: * michael@0: * If U_IOSTREAM_SOURCE is set to 198506, then <iostream.h> is michael@0: * available instead (in June 1985 Stroustrup published michael@0: * "An Extensible I/O Facility for C++" at the summer USENIX conference). michael@0: * Starting with ICU 49, this version is not supported any more. michael@0: * michael@0: * If U_IOSTREAM_SOURCE is 0 (or any value less than 199711), michael@0: * then C++ streams are not available and michael@0: * support for them will be silently suppressed in ICU. michael@0: * michael@0: * @internal michael@0: */ michael@0: #ifndef U_IOSTREAM_SOURCE michael@0: #define U_IOSTREAM_SOURCE 199711 michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_HAVE_STD_STRING michael@0: * Defines whether the standard C++ (STL) <string> header is available. michael@0: * @internal michael@0: */ michael@0: #ifdef U_HAVE_STD_STRING michael@0: /* Use the predefined value. */ michael@0: #else michael@0: # define U_HAVE_STD_STRING 1 michael@0: #endif michael@0: michael@0: /*===========================================================================*/ michael@0: /** @{ Compiler and environment features */ michael@0: /*===========================================================================*/ michael@0: michael@0: /** michael@0: * \def U_GCC_MAJOR_MINOR michael@0: * Indicates whether the compiler is gcc (test for != 0), michael@0: * and if so, contains its major (times 100) and minor version numbers. michael@0: * If the compiler is not gcc, then U_GCC_MAJOR_MINOR == 0. michael@0: * michael@0: * For example, for testing for whether we have gcc, and whether it's 4.6 or higher, michael@0: * use "#if U_GCC_MAJOR_MINOR >= 406". michael@0: * @internal michael@0: */ michael@0: #ifdef __GNUC__ michael@0: # define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__) michael@0: #else michael@0: # define U_GCC_MAJOR_MINOR 0 michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_IS_BIG_ENDIAN michael@0: * Determines the endianness of the platform. michael@0: * @internal michael@0: */ michael@0: #ifdef U_IS_BIG_ENDIAN michael@0: /* Use the predefined value. */ michael@0: #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN) michael@0: # define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN) michael@0: #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) michael@0: /* gcc */ michael@0: # define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) michael@0: #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN) michael@0: # define U_IS_BIG_ENDIAN 1 michael@0: #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN) michael@0: # define U_IS_BIG_ENDIAN 0 michael@0: #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__) michael@0: /* These platforms do not appear to predefine any endianness macros. */ michael@0: # define U_IS_BIG_ENDIAN 1 michael@0: #elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) michael@0: /* HPPA do not appear to predefine any endianness macros. */ michael@0: # define U_IS_BIG_ENDIAN 1 michael@0: #elif defined(sparc) || defined(__sparc) || defined(__sparc__) michael@0: /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */ michael@0: # define U_IS_BIG_ENDIAN 1 michael@0: #else michael@0: # define U_IS_BIG_ENDIAN 0 michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_HAVE_PLACEMENT_NEW michael@0: * Determines whether to override placement new and delete for STL. michael@0: * @stable ICU 2.6 michael@0: */ michael@0: #ifdef U_HAVE_PLACEMENT_NEW michael@0: /* Use the predefined value. */ michael@0: #elif defined(__BORLANDC__) michael@0: # define U_HAVE_PLACEMENT_NEW 0 michael@0: #else michael@0: # define U_HAVE_PLACEMENT_NEW 1 michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_HAVE_DEBUG_LOCATION_NEW michael@0: * Define this to define the MFC debug version of the operator new. michael@0: * michael@0: * @stable ICU 3.4 michael@0: */ michael@0: #ifdef U_HAVE_DEBUG_LOCATION_NEW michael@0: /* Use the predefined value. */ michael@0: #elif defined(_MSC_VER) michael@0: # define U_HAVE_DEBUG_LOCATION_NEW 1 michael@0: #else michael@0: # define U_HAVE_DEBUG_LOCATION_NEW 0 michael@0: #endif michael@0: michael@0: /* Compatibility with non clang compilers */ michael@0: #ifndef __has_attribute michael@0: # define __has_attribute(x) 0 michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_MALLOC_ATTR michael@0: * Attribute to mark functions as malloc-like michael@0: * @internal michael@0: */ michael@0: #if defined(__GNUC__) && __GNUC__>=3 michael@0: # define U_MALLOC_ATTR __attribute__ ((__malloc__)) michael@0: #else michael@0: # define U_MALLOC_ATTR michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_ALLOC_SIZE_ATTR michael@0: * Attribute to specify the size of the allocated buffer for malloc-like functions michael@0: * @internal michael@0: */ michael@0: #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || __has_attribute(alloc_size) michael@0: # define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X))) michael@0: # define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y))) michael@0: #else michael@0: # define U_ALLOC_SIZE_ATTR(X) michael@0: # define U_ALLOC_SIZE_ATTR2(X,Y) michael@0: #endif michael@0: michael@0: /** @} */ michael@0: michael@0: /*===========================================================================*/ michael@0: /** @{ Character data types */ michael@0: /*===========================================================================*/ michael@0: michael@0: /** michael@0: * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: #define U_ASCII_FAMILY 0 michael@0: michael@0: /** michael@0: * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: #define U_EBCDIC_FAMILY 1 michael@0: michael@0: /** michael@0: * \def U_CHARSET_FAMILY michael@0: * michael@0: *

These definitions allow to specify the encoding of text michael@0: * in the char data type as defined by the platform and the compiler. michael@0: * It is enough to determine the code point values of "invariant characters", michael@0: * which are the ones shared by all encodings that are in use michael@0: * on a given platform.

michael@0: * michael@0: *

Those "invariant characters" should be all the uppercase and lowercase michael@0: * latin letters, the digits, the space, and "basic punctuation". michael@0: * Also, '\\n', '\\r', '\\t' should be available.

michael@0: * michael@0: *

The list of "invariant characters" is:
michael@0: * \code michael@0: * A-Z a-z 0-9 SPACE " % & ' ( ) * + , - . / : ; < = > ? _ michael@0: * \endcode michael@0: *
michael@0: * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)

michael@0: * michael@0: *

This matches the IBM Syntactic Character Set (CS 640).

michael@0: * michael@0: *

In other words, all the graphic characters in 7-bit ASCII should michael@0: * be safely accessible except the following:

michael@0: * michael@0: * \code michael@0: * '\' michael@0: * '[' michael@0: * ']' michael@0: * '{' michael@0: * '}' michael@0: * '^' michael@0: * '~' michael@0: * '!' michael@0: * '#' michael@0: * '|' michael@0: * '$' michael@0: * '@' michael@0: * '`' michael@0: * \endcode michael@0: * @stable ICU 2.0 michael@0: */ michael@0: #ifdef U_CHARSET_FAMILY michael@0: /* Use the predefined value. */ michael@0: #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB) michael@0: # define U_CHARSET_FAMILY U_EBCDIC_FAMILY michael@0: #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__) michael@0: # define U_CHARSET_FAMILY U_EBCDIC_FAMILY michael@0: #else michael@0: # define U_CHARSET_FAMILY U_ASCII_FAMILY michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_CHARSET_IS_UTF8 michael@0: * michael@0: * Hardcode the default charset to UTF-8. michael@0: * michael@0: * If this is set to 1, then michael@0: * - ICU will assume that all non-invariant char*, StringPiece, std::string etc. michael@0: * contain UTF-8 text, regardless of what the system API uses michael@0: * - some ICU code will use fast functions like u_strFromUTF8() michael@0: * rather than the more general and more heavy-weight conversion API (ucnv.h) michael@0: * - ucnv_getDefaultName() always returns "UTF-8" michael@0: * - ucnv_setDefaultName() is disabled and will not change the default charset michael@0: * - static builds of ICU are smaller michael@0: * - more functionality is available with the UCONFIG_NO_CONVERSION build-time michael@0: * configuration option (see unicode/uconfig.h) michael@0: * - the UCONFIG_NO_CONVERSION build option in uconfig.h is more usable michael@0: * michael@0: * @stable ICU 4.2 michael@0: * @see UCONFIG_NO_CONVERSION michael@0: */ michael@0: #ifdef U_CHARSET_IS_UTF8 michael@0: /* Use the predefined value. */ michael@0: #elif U_PLATFORM == U_PF_ANDROID || U_PLATFORM_IS_DARWIN_BASED michael@0: # define U_CHARSET_IS_UTF8 1 michael@0: #else michael@0: # define U_CHARSET_IS_UTF8 0 michael@0: #endif michael@0: michael@0: /** @} */ michael@0: michael@0: /*===========================================================================*/ michael@0: /** @{ Information about wchar support */ michael@0: /*===========================================================================*/ michael@0: michael@0: /** michael@0: * \def U_HAVE_WCHAR_H michael@0: * Indicates whether is available (1) or not (0). Set to 1 by default. michael@0: * michael@0: * @stable ICU 2.0 michael@0: */ michael@0: #ifdef U_HAVE_WCHAR_H michael@0: /* Use the predefined value. */ michael@0: #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9 michael@0: /* michael@0: * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t. michael@0: * The type and header existed, but the library functions did not work as expected. michael@0: * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway. michael@0: */ michael@0: # define U_HAVE_WCHAR_H 0 michael@0: #else michael@0: # define U_HAVE_WCHAR_H 1 michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_SIZEOF_WCHAR_T michael@0: * U_SIZEOF_WCHAR_T==sizeof(wchar_t) michael@0: * michael@0: * @stable ICU 2.0 michael@0: */ michael@0: #ifdef U_SIZEOF_WCHAR_T michael@0: /* Use the predefined value. */ michael@0: #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9) || U_PLATFORM == U_PF_CLASSIC_MACOS michael@0: /* michael@0: * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring. michael@0: * Newer Mac OS X has size 4. michael@0: */ michael@0: # define U_SIZEOF_WCHAR_T 1 michael@0: #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN michael@0: # define U_SIZEOF_WCHAR_T 2 michael@0: #elif U_PLATFORM == U_PF_AIX michael@0: /* michael@0: * AIX 6.1 information, section "Wide character data representation": michael@0: * "... the wchar_t datatype is 32-bit in the 64-bit environment and michael@0: * 16-bit in the 32-bit environment." michael@0: * and michael@0: * "All locales use Unicode for their wide character code values (process code), michael@0: * except the IBM-eucTW codeset." michael@0: */ michael@0: # ifdef __64BIT__ michael@0: # define U_SIZEOF_WCHAR_T 4 michael@0: # else michael@0: # define U_SIZEOF_WCHAR_T 2 michael@0: # endif michael@0: #elif U_PLATFORM == U_PF_OS390 michael@0: /* michael@0: * z/OS V1R11 information center, section "LP64 | ILP32": michael@0: * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes. michael@0: * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes." michael@0: */ michael@0: # ifdef _LP64 michael@0: # define U_SIZEOF_WCHAR_T 4 michael@0: # else michael@0: # define U_SIZEOF_WCHAR_T 2 michael@0: # endif michael@0: #elif U_PLATFORM == U_PF_OS400 michael@0: # if defined(__UTF32__) michael@0: /* michael@0: * LOCALETYPE(*LOCALEUTF) is specified. michael@0: * Wide-character strings are in UTF-32, michael@0: * narrow-character strings are in UTF-8. michael@0: */ michael@0: # define U_SIZEOF_WCHAR_T 4 michael@0: # elif defined(__UCS2__) michael@0: /* michael@0: * LOCALETYPE(*LOCALEUCS2) is specified. michael@0: * Wide-character strings are in UCS-2, michael@0: * narrow-character strings are in EBCDIC. michael@0: */ michael@0: # define U_SIZEOF_WCHAR_T 2 michael@0: #else michael@0: /* michael@0: * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified. michael@0: * Wide-character strings are in 16-bit EBCDIC, michael@0: * narrow-character strings are in EBCDIC. michael@0: */ michael@0: # define U_SIZEOF_WCHAR_T 2 michael@0: # endif michael@0: #else michael@0: # define U_SIZEOF_WCHAR_T 4 michael@0: #endif michael@0: michael@0: #ifndef U_HAVE_WCSCPY michael@0: #define U_HAVE_WCSCPY U_HAVE_WCHAR_H michael@0: #endif michael@0: michael@0: /** @} */ michael@0: michael@0: /** michael@0: * \def U_HAVE_CHAR16_T michael@0: * Defines whether the char16_t type is available for UTF-16 michael@0: * and u"abc" UTF-16 string literals are supported. michael@0: * This is a new standard type and standard string literal syntax in C++0x michael@0: * but has been available in some compilers before. michael@0: * @internal michael@0: */ michael@0: #ifdef U_HAVE_CHAR16_T michael@0: /* Use the predefined value. */ michael@0: #else michael@0: /* michael@0: * Notes: michael@0: * Visual Studio 10 (_MSC_VER>=1600) defines char16_t but michael@0: * does not support u"abc" string literals. michael@0: * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but michael@0: * does not support u"abc" string literals. michael@0: * C++11 and C11 require support for UTF-16 literals michael@0: */ michael@0: # if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) michael@0: # define U_HAVE_CHAR16_T 1 michael@0: # else michael@0: # define U_HAVE_CHAR16_T 0 michael@0: # endif michael@0: #endif michael@0: michael@0: /** michael@0: * @{ michael@0: * \def U_DECLARE_UTF16 michael@0: * Do not use this macro because it is not defined on all platforms. michael@0: * Use the UNICODE_STRING or U_STRING_DECL macros instead. michael@0: * @internal michael@0: */ michael@0: #ifdef U_DECLARE_UTF16 michael@0: /* Use the predefined value. */ michael@0: #elif U_HAVE_CHAR16_T \ michael@0: || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \ michael@0: || (defined(__HP_aCC) && __HP_aCC >= 035000) \ michael@0: || (defined(__HP_cc) && __HP_cc >= 111106) michael@0: # define U_DECLARE_UTF16(string) u ## string michael@0: #elif U_SIZEOF_WCHAR_T == 2 \ michael@0: && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__))) michael@0: # define U_DECLARE_UTF16(string) L ## string michael@0: #else michael@0: /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */ michael@0: #endif michael@0: michael@0: /** @} */ michael@0: michael@0: /*===========================================================================*/ michael@0: /** @{ Symbol import-export control */ michael@0: /*===========================================================================*/ michael@0: michael@0: #ifdef U_EXPORT michael@0: /* Use the predefined value. */ michael@0: #elif defined(U_STATIC_IMPLEMENTATION) michael@0: # define U_EXPORT michael@0: #elif defined(__GNUC__) michael@0: # define U_EXPORT __attribute__((visibility("default"))) michael@0: #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \ michael@0: || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) michael@0: # define U_EXPORT __global michael@0: /*#elif defined(__HP_aCC) || defined(__HP_cc) michael@0: # define U_EXPORT __declspec(dllexport)*/ michael@0: #elif defined(_MSC_VER) michael@0: # define U_EXPORT __declspec(dllexport) michael@0: #else michael@0: # define U_EXPORT michael@0: #endif michael@0: michael@0: /* U_CALLCONV is releated to U_EXPORT2 */ michael@0: #ifdef U_EXPORT2 michael@0: /* Use the predefined value. */ michael@0: #elif defined(_MSC_VER) michael@0: # define U_EXPORT2 __cdecl michael@0: #else michael@0: # define U_EXPORT2 michael@0: #endif michael@0: michael@0: #ifdef U_IMPORT michael@0: /* Use the predefined value. */ michael@0: #elif defined(_MSC_VER) michael@0: /* Windows needs to export/import data. */ michael@0: # define U_IMPORT __declspec(dllimport) michael@0: #else michael@0: # define U_IMPORT michael@0: #endif michael@0: michael@0: /** michael@0: * \def U_CALLCONV michael@0: * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary michael@0: * in callback function typedefs to make sure that the calling convention michael@0: * is compatible. michael@0: * michael@0: * This is only used for non-ICU-API functions. michael@0: * When a function is a public ICU API, michael@0: * you must use the U_CAPI and U_EXPORT2 qualifiers. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus) michael@0: # define U_CALLCONV __cdecl michael@0: #else michael@0: # define U_CALLCONV U_EXPORT2 michael@0: #endif michael@0: michael@0: /* @} */ michael@0: michael@0: #endif