jpayne@69: // © 2016 and later: Unicode, Inc. and others. jpayne@69: // License & terms of use: http://www.unicode.org/copyright.html jpayne@69: /* jpayne@69: ****************************************************************************** jpayne@69: * jpayne@69: * Copyright (C) 1997-2016, International Business Machines jpayne@69: * Corporation and others. All Rights Reserved. jpayne@69: * jpayne@69: ****************************************************************************** jpayne@69: * jpayne@69: * FILE NAME : platform.h jpayne@69: * jpayne@69: * Date Name Description jpayne@69: * 05/13/98 nos Creation (content moved here from ptypes.h). jpayne@69: * 03/02/99 stephen Added AS400 support. jpayne@69: * 03/30/99 stephen Added Linux support. jpayne@69: * 04/13/99 stephen Reworked for autoconf. jpayne@69: ****************************************************************************** jpayne@69: */ jpayne@69: jpayne@69: #ifndef _PLATFORM_H jpayne@69: #define _PLATFORM_H jpayne@69: jpayne@69: #include "unicode/uconfig.h" jpayne@69: #include "unicode/uvernum.h" jpayne@69: jpayne@69: /** jpayne@69: * \file jpayne@69: * \brief Basic types for the platform. jpayne@69: * jpayne@69: * This file used to be generated by autoconf/configure. jpayne@69: * Starting with ICU 49, platform.h is a normal source file, jpayne@69: * to simplify cross-compiling and working with non-autoconf/make build systems. jpayne@69: * jpayne@69: * When a value in this file does not work on a platform, then please jpayne@69: * try to derive it from the U_PLATFORM value jpayne@69: * (for which we might need a new value constant in rare cases) jpayne@69: * and/or from other macros that are predefined by the compiler jpayne@69: * or defined in standard (POSIX or platform or compiler) headers. jpayne@69: * jpayne@69: * As a temporary workaround, you can add an explicit \#define for some macros jpayne@69: * before it is first tested, or add an equivalent -D macro definition jpayne@69: * to the compiler's command line. jpayne@69: * jpayne@69: * Note: Some compilers provide ways to show the predefined macros. jpayne@69: * For example, with gcc you can compile an empty .c file and have the compiler jpayne@69: * print the predefined macros with jpayne@69: * \code jpayne@69: * gcc -E -dM -x c /dev/null | sort jpayne@69: * \endcode jpayne@69: * (You can provide an actual empty .c file rather than /dev/null. jpayne@69: * -x c++ is for C++.) jpayne@69: */ jpayne@69: jpayne@69: /** jpayne@69: * Define some things so that they can be documented. jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef U_IN_DOXYGEN jpayne@69: /* jpayne@69: * Problem: "platform.h:335: warning: documentation for unknown define U_HAVE_STD_STRING found." means that U_HAVE_STD_STRING is not documented. jpayne@69: * 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. jpayne@69: */ jpayne@69: jpayne@69: /* None for now. */ jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_PLATFORM jpayne@69: * The U_PLATFORM macro defines the platform we're on. jpayne@69: * jpayne@69: * We used to define one different, value-less macro per platform. jpayne@69: * That made it hard to know the set of relevant platforms and macros, jpayne@69: * and hard to deal with variants of platforms. jpayne@69: * jpayne@69: * Starting with ICU 49, we define platforms as numeric macros, jpayne@69: * with ranges of values for related platforms and their variants. jpayne@69: * The U_PLATFORM macro is set to one of these values. jpayne@69: * jpayne@69: * Historical note from the Solaris Wikipedia article: jpayne@69: * AT&T and Sun collaborated on a project to merge the most popular Unix variants jpayne@69: * on the market at that time: BSD, System V, and Xenix. jpayne@69: * This became Unix System V Release 4 (SVR4). jpayne@69: * jpayne@69: * @internal jpayne@69: */ jpayne@69: jpayne@69: /** Unknown platform. @internal */ jpayne@69: #define U_PF_UNKNOWN 0 jpayne@69: /** Windows @internal */ jpayne@69: #define U_PF_WINDOWS 1000 jpayne@69: /** MinGW. Windows, calls to Win32 API, but using GNU gcc and binutils. @internal */ jpayne@69: #define U_PF_MINGW 1800 jpayne@69: /** jpayne@69: * Cygwin. Windows, calls to cygwin1.dll for Posix functions, jpayne@69: * using MSVC or GNU gcc and binutils. jpayne@69: * @internal jpayne@69: */ jpayne@69: #define U_PF_CYGWIN 1900 jpayne@69: /* Reserve 2000 for U_PF_UNIX? */ jpayne@69: /** HP-UX is based on UNIX System V. @internal */ jpayne@69: #define U_PF_HPUX 2100 jpayne@69: /** Solaris is a Unix operating system based on SVR4. @internal */ jpayne@69: #define U_PF_SOLARIS 2600 jpayne@69: /** BSD is a UNIX operating system derivative. @internal */ jpayne@69: #define U_PF_BSD 3000 jpayne@69: /** AIX is based on UNIX System V Releases and 4.3 BSD. @internal */ jpayne@69: #define U_PF_AIX 3100 jpayne@69: /** IRIX is based on UNIX System V with BSD extensions. @internal */ jpayne@69: #define U_PF_IRIX 3200 jpayne@69: /** jpayne@69: * Darwin is a POSIX-compliant operating system, composed of code developed by Apple, jpayne@69: * as well as code derived from NeXTSTEP, BSD, and other projects, jpayne@69: * built around the Mach kernel. jpayne@69: * Darwin forms the core set of components upon which Mac OS X, Apple TV, and iOS are based. jpayne@69: * (Original description modified from WikiPedia.) jpayne@69: * @internal jpayne@69: */ jpayne@69: #define U_PF_DARWIN 3500 jpayne@69: /** iPhone OS (iOS) is a derivative of Mac OS X. @internal */ jpayne@69: #define U_PF_IPHONE 3550 jpayne@69: /** QNX is a commercial Unix-like real-time operating system related to BSD. @internal */ jpayne@69: #define U_PF_QNX 3700 jpayne@69: /** Linux is a Unix-like operating system. @internal */ jpayne@69: #define U_PF_LINUX 4000 jpayne@69: /** jpayne@69: * Native Client is pretty close to Linux. jpayne@69: * See https://developer.chrome.com/native-client and jpayne@69: * http://www.chromium.org/nativeclient jpayne@69: * @internal jpayne@69: */ jpayne@69: #define U_PF_BROWSER_NATIVE_CLIENT 4020 jpayne@69: /** Android is based on Linux. @internal */ jpayne@69: #define U_PF_ANDROID 4050 jpayne@69: /** Fuchsia is a POSIX-ish platform. @internal */ jpayne@69: #define U_PF_FUCHSIA 4100 jpayne@69: /* Maximum value for Linux-based platform is 4499 */ jpayne@69: /** jpayne@69: * Emscripten is a C++ transpiler for the Web that can target asm.js or jpayne@69: * WebAssembly. It provides some POSIX-compatible wrappers and stubs and jpayne@69: * some Linux-like functionality, but is not fully compatible with jpayne@69: * either. jpayne@69: * @internal jpayne@69: */ jpayne@69: #define U_PF_EMSCRIPTEN 5010 jpayne@69: /** z/OS is the successor to OS/390 which was the successor to MVS. @internal */ jpayne@69: #define U_PF_OS390 9000 jpayne@69: /** "IBM i" is the current name of what used to be i5/OS and earlier OS/400. @internal */ jpayne@69: #define U_PF_OS400 9400 jpayne@69: jpayne@69: #ifdef U_PLATFORM jpayne@69: /* Use the predefined value. */ jpayne@69: #elif defined(__MINGW32__) jpayne@69: # define U_PLATFORM U_PF_MINGW jpayne@69: #elif defined(__CYGWIN__) jpayne@69: # define U_PLATFORM U_PF_CYGWIN jpayne@69: #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) jpayne@69: # define U_PLATFORM U_PF_WINDOWS jpayne@69: #elif defined(__ANDROID__) jpayne@69: # define U_PLATFORM U_PF_ANDROID jpayne@69: /* Android wchar_t support depends on the API level. */ jpayne@69: # include jpayne@69: #elif defined(__pnacl__) || defined(__native_client__) jpayne@69: # define U_PLATFORM U_PF_BROWSER_NATIVE_CLIENT jpayne@69: #elif defined(__Fuchsia__) jpayne@69: # define U_PLATFORM U_PF_FUCHSIA jpayne@69: #elif defined(linux) || defined(__linux__) || defined(__linux) jpayne@69: # define U_PLATFORM U_PF_LINUX jpayne@69: #elif defined(__APPLE__) && defined(__MACH__) jpayne@69: # include jpayne@69: # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* variant of TARGET_OS_MAC */ jpayne@69: # define U_PLATFORM U_PF_IPHONE jpayne@69: # else jpayne@69: # define U_PLATFORM U_PF_DARWIN jpayne@69: # endif jpayne@69: #elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__) jpayne@69: # if defined(__FreeBSD__) jpayne@69: # include jpayne@69: # endif jpayne@69: # define U_PLATFORM U_PF_BSD jpayne@69: #elif defined(sun) || defined(__sun) jpayne@69: /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */ jpayne@69: # define U_PLATFORM U_PF_SOLARIS jpayne@69: # if defined(__GNUC__) jpayne@69: /* Solaris/GCC needs this header file to get the proper endianness. Normally, this jpayne@69: * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h jpayne@69: * is included which does not include this header file. jpayne@69: */ jpayne@69: # include jpayne@69: # endif jpayne@69: #elif defined(_AIX) || defined(__TOS_AIX__) jpayne@69: # define U_PLATFORM U_PF_AIX jpayne@69: #elif defined(_hpux) || defined(hpux) || defined(__hpux) jpayne@69: # define U_PLATFORM U_PF_HPUX jpayne@69: #elif defined(sgi) || defined(__sgi) jpayne@69: # define U_PLATFORM U_PF_IRIX jpayne@69: #elif defined(__QNX__) || defined(__QNXNTO__) jpayne@69: # define U_PLATFORM U_PF_QNX jpayne@69: #elif defined(__TOS_MVS__) jpayne@69: # define U_PLATFORM U_PF_OS390 jpayne@69: #elif defined(__OS400__) || defined(__TOS_OS400__) jpayne@69: # define U_PLATFORM U_PF_OS400 jpayne@69: #elif defined(__EMSCRIPTEN__) jpayne@69: # define U_PLATFORM U_PF_EMSCRIPTEN jpayne@69: #else jpayne@69: # define U_PLATFORM U_PF_UNKNOWN jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def CYGWINMSVC jpayne@69: * Defined if this is Windows with Cygwin, but using MSVC rather than gcc. jpayne@69: * Otherwise undefined. jpayne@69: * @internal jpayne@69: */ jpayne@69: /* Commented out because this is already set in mh-cygwin-msvc jpayne@69: #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER) jpayne@69: # define CYGWINMSVC jpayne@69: #endif jpayne@69: */ jpayne@69: #ifdef U_IN_DOXYGEN jpayne@69: # define CYGWINMSVC jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_PLATFORM_USES_ONLY_WIN32_API jpayne@69: * Defines whether the platform uses only the Win32 API. jpayne@69: * Set to 1 for Windows/MSVC and MinGW but not Cygwin. jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef U_PLATFORM_USES_ONLY_WIN32_API jpayne@69: /* Use the predefined value. */ jpayne@69: #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC) jpayne@69: # define U_PLATFORM_USES_ONLY_WIN32_API 1 jpayne@69: #else jpayne@69: /* Cygwin implements POSIX. */ jpayne@69: # define U_PLATFORM_USES_ONLY_WIN32_API 0 jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_PLATFORM_HAS_WIN32_API jpayne@69: * Defines whether the Win32 API is available on the platform. jpayne@69: * Set to 1 for Windows/MSVC, MinGW and Cygwin. jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef U_PLATFORM_HAS_WIN32_API jpayne@69: /* Use the predefined value. */ jpayne@69: #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN jpayne@69: # define U_PLATFORM_HAS_WIN32_API 1 jpayne@69: #else jpayne@69: # define U_PLATFORM_HAS_WIN32_API 0 jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_PLATFORM_HAS_WINUWP_API jpayne@69: * Defines whether target is intended for Universal Windows Platform API jpayne@69: * Set to 1 for Windows10 Release Solution Configuration jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef U_PLATFORM_HAS_WINUWP_API jpayne@69: /* Use the predefined value. */ jpayne@69: #else jpayne@69: # define U_PLATFORM_HAS_WINUWP_API 0 jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_PLATFORM_IMPLEMENTS_POSIX jpayne@69: * Defines whether the platform implements (most of) the POSIX API. jpayne@69: * Set to 1 for Cygwin and most other platforms. jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef U_PLATFORM_IMPLEMENTS_POSIX jpayne@69: /* Use the predefined value. */ jpayne@69: #elif U_PLATFORM_USES_ONLY_WIN32_API jpayne@69: # define U_PLATFORM_IMPLEMENTS_POSIX 0 jpayne@69: #else jpayne@69: # define U_PLATFORM_IMPLEMENTS_POSIX 1 jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_PLATFORM_IS_LINUX_BASED jpayne@69: * Defines whether the platform is Linux or one of its derivatives. jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef U_PLATFORM_IS_LINUX_BASED jpayne@69: /* Use the predefined value. */ jpayne@69: #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= 4499 jpayne@69: # define U_PLATFORM_IS_LINUX_BASED 1 jpayne@69: #else jpayne@69: # define U_PLATFORM_IS_LINUX_BASED 0 jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_PLATFORM_IS_DARWIN_BASED jpayne@69: * Defines whether the platform is Darwin or one of its derivatives. jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef U_PLATFORM_IS_DARWIN_BASED jpayne@69: /* Use the predefined value. */ jpayne@69: #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE jpayne@69: # define U_PLATFORM_IS_DARWIN_BASED 1 jpayne@69: #else jpayne@69: # define U_PLATFORM_IS_DARWIN_BASED 0 jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_HAVE_STDINT_H jpayne@69: * Defines whether stdint.h is available. It is a C99 standard header. jpayne@69: * We used to include inttypes.h which includes stdint.h but we usually do not need jpayne@69: * the additional definitions from inttypes.h. jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef U_HAVE_STDINT_H jpayne@69: /* Use the predefined value. */ jpayne@69: #elif U_PLATFORM_USES_ONLY_WIN32_API jpayne@69: # if defined(__BORLANDC__) || U_PLATFORM == U_PF_MINGW || (defined(_MSC_VER) && _MSC_VER>=1600) jpayne@69: /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */ jpayne@69: # define U_HAVE_STDINT_H 1 jpayne@69: # else jpayne@69: # define U_HAVE_STDINT_H 0 jpayne@69: # endif jpayne@69: #elif U_PLATFORM == U_PF_SOLARIS jpayne@69: /* Solaris has inttypes.h but not stdint.h. */ jpayne@69: # define U_HAVE_STDINT_H 0 jpayne@69: #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER) jpayne@69: /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */ jpayne@69: # define U_HAVE_STDINT_H 0 jpayne@69: #else jpayne@69: # define U_HAVE_STDINT_H 1 jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_HAVE_INTTYPES_H jpayne@69: * Defines whether inttypes.h is available. It is a C99 standard header. jpayne@69: * We include inttypes.h where it is available but stdint.h is not. jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef U_HAVE_INTTYPES_H jpayne@69: /* Use the predefined value. */ jpayne@69: #elif U_PLATFORM == U_PF_SOLARIS jpayne@69: /* Solaris has inttypes.h but not stdint.h. */ jpayne@69: # define U_HAVE_INTTYPES_H 1 jpayne@69: #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER) jpayne@69: /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */ jpayne@69: # define U_HAVE_INTTYPES_H 1 jpayne@69: #else jpayne@69: /* Most platforms have both inttypes.h and stdint.h, or neither. */ jpayne@69: # define U_HAVE_INTTYPES_H U_HAVE_STDINT_H jpayne@69: #endif jpayne@69: jpayne@69: /*===========================================================================*/ jpayne@69: /** @{ Compiler and environment features */ jpayne@69: /*===========================================================================*/ jpayne@69: jpayne@69: /** jpayne@69: * \def U_GCC_MAJOR_MINOR jpayne@69: * Indicates whether the compiler is gcc (test for != 0), jpayne@69: * and if so, contains its major (times 100) and minor version numbers. jpayne@69: * If the compiler is not gcc, then U_GCC_MAJOR_MINOR == 0. jpayne@69: * jpayne@69: * For example, for testing for whether we have gcc, and whether it's 4.6 or higher, jpayne@69: * use "#if U_GCC_MAJOR_MINOR >= 406". jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef __GNUC__ jpayne@69: # define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__) jpayne@69: #else jpayne@69: # define U_GCC_MAJOR_MINOR 0 jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_IS_BIG_ENDIAN jpayne@69: * Determines the endianness of the platform. jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef U_IS_BIG_ENDIAN jpayne@69: /* Use the predefined value. */ jpayne@69: #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN) jpayne@69: # define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN) jpayne@69: #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) jpayne@69: /* gcc */ jpayne@69: # define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) jpayne@69: #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN) jpayne@69: # define U_IS_BIG_ENDIAN 1 jpayne@69: #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN) jpayne@69: # define U_IS_BIG_ENDIAN 0 jpayne@69: #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__) jpayne@69: /* These platforms do not appear to predefine any endianness macros. */ jpayne@69: # define U_IS_BIG_ENDIAN 1 jpayne@69: #elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) jpayne@69: /* HPPA do not appear to predefine any endianness macros. */ jpayne@69: # define U_IS_BIG_ENDIAN 1 jpayne@69: #elif defined(sparc) || defined(__sparc) || defined(__sparc__) jpayne@69: /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */ jpayne@69: # define U_IS_BIG_ENDIAN 1 jpayne@69: #else jpayne@69: # define U_IS_BIG_ENDIAN 0 jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_HAVE_PLACEMENT_NEW jpayne@69: * Determines whether to override placement new and delete for STL. jpayne@69: * @stable ICU 2.6 jpayne@69: */ jpayne@69: #ifdef U_HAVE_PLACEMENT_NEW jpayne@69: /* Use the predefined value. */ jpayne@69: #elif defined(__BORLANDC__) jpayne@69: # define U_HAVE_PLACEMENT_NEW 0 jpayne@69: #else jpayne@69: # define U_HAVE_PLACEMENT_NEW 1 jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_HAVE_DEBUG_LOCATION_NEW jpayne@69: * Define this to define the MFC debug version of the operator new. jpayne@69: * jpayne@69: * @stable ICU 3.4 jpayne@69: */ jpayne@69: #ifdef U_HAVE_DEBUG_LOCATION_NEW jpayne@69: /* Use the predefined value. */ jpayne@69: #elif defined(_MSC_VER) jpayne@69: # define U_HAVE_DEBUG_LOCATION_NEW 1 jpayne@69: #else jpayne@69: # define U_HAVE_DEBUG_LOCATION_NEW 0 jpayne@69: #endif jpayne@69: jpayne@69: /* Compatibility with compilers other than clang: http://clang.llvm.org/docs/LanguageExtensions.html */ jpayne@69: #ifdef __has_attribute jpayne@69: # define UPRV_HAS_ATTRIBUTE(x) __has_attribute(x) jpayne@69: #else jpayne@69: # define UPRV_HAS_ATTRIBUTE(x) 0 jpayne@69: #endif jpayne@69: #ifdef __has_cpp_attribute jpayne@69: # define UPRV_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) jpayne@69: #else jpayne@69: # define UPRV_HAS_CPP_ATTRIBUTE(x) 0 jpayne@69: #endif jpayne@69: #ifdef __has_declspec_attribute jpayne@69: # define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) __has_declspec_attribute(x) jpayne@69: #else jpayne@69: # define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) 0 jpayne@69: #endif jpayne@69: #ifdef __has_builtin jpayne@69: # define UPRV_HAS_BUILTIN(x) __has_builtin(x) jpayne@69: #else jpayne@69: # define UPRV_HAS_BUILTIN(x) 0 jpayne@69: #endif jpayne@69: #ifdef __has_feature jpayne@69: # define UPRV_HAS_FEATURE(x) __has_feature(x) jpayne@69: #else jpayne@69: # define UPRV_HAS_FEATURE(x) 0 jpayne@69: #endif jpayne@69: #ifdef __has_extension jpayne@69: # define UPRV_HAS_EXTENSION(x) __has_extension(x) jpayne@69: #else jpayne@69: # define UPRV_HAS_EXTENSION(x) 0 jpayne@69: #endif jpayne@69: #ifdef __has_warning jpayne@69: # define UPRV_HAS_WARNING(x) __has_warning(x) jpayne@69: #else jpayne@69: # define UPRV_HAS_WARNING(x) 0 jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_MALLOC_ATTR jpayne@69: * Attribute to mark functions as malloc-like jpayne@69: * @internal jpayne@69: */ jpayne@69: #if defined(__GNUC__) && __GNUC__>=3 jpayne@69: # define U_MALLOC_ATTR __attribute__ ((__malloc__)) jpayne@69: #else jpayne@69: # define U_MALLOC_ATTR jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_ALLOC_SIZE_ATTR jpayne@69: * Attribute to specify the size of the allocated buffer for malloc-like functions jpayne@69: * @internal jpayne@69: */ jpayne@69: #if (defined(__GNUC__) && \ jpayne@69: (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \ jpayne@69: UPRV_HAS_ATTRIBUTE(alloc_size) jpayne@69: # define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X))) jpayne@69: # define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y))) jpayne@69: #else jpayne@69: # define U_ALLOC_SIZE_ATTR(X) jpayne@69: # define U_ALLOC_SIZE_ATTR2(X,Y) jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_CPLUSPLUS_VERSION jpayne@69: * 0 if no C++; 1, 11, 14, ... if C++. jpayne@69: * Support for specific features cannot always be determined by the C++ version alone. jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef U_CPLUSPLUS_VERSION jpayne@69: # if U_CPLUSPLUS_VERSION != 0 && !defined(__cplusplus) jpayne@69: # undef U_CPLUSPLUS_VERSION jpayne@69: # define U_CPLUSPLUS_VERSION 0 jpayne@69: # endif jpayne@69: /* Otherwise use the predefined value. */ jpayne@69: #elif !defined(__cplusplus) jpayne@69: # define U_CPLUSPLUS_VERSION 0 jpayne@69: #elif __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) jpayne@69: # define U_CPLUSPLUS_VERSION 14 jpayne@69: #elif __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L) jpayne@69: # define U_CPLUSPLUS_VERSION 11 jpayne@69: #else jpayne@69: // C++98 or C++03 jpayne@69: # define U_CPLUSPLUS_VERSION 1 jpayne@69: #endif jpayne@69: jpayne@69: #if (U_PLATFORM == U_PF_AIX || U_PLATFORM == U_PF_OS390) && defined(__cplusplus) &&(U_CPLUSPLUS_VERSION < 11) jpayne@69: // add in std::nullptr_t jpayne@69: namespace std { jpayne@69: typedef decltype(nullptr) nullptr_t; jpayne@69: }; jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_NOEXCEPT jpayne@69: * "noexcept" if supported, otherwise empty. jpayne@69: * Some code, especially STL containers, uses move semantics of objects only jpayne@69: * if the move constructor and the move operator are declared as not throwing exceptions. jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifdef U_NOEXCEPT jpayne@69: /* Use the predefined value. */ jpayne@69: #else jpayne@69: # define U_NOEXCEPT noexcept jpayne@69: #endif jpayne@69: jpayne@69: /** jpayne@69: * \def U_FALLTHROUGH jpayne@69: * Annotate intentional fall-through between switch labels. jpayne@69: * http://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough jpayne@69: * @internal jpayne@69: */ jpayne@69: #ifndef __cplusplus jpayne@69: // Not for C. jpayne@69: #elif defined(U_FALLTHROUGH) jpayne@69: // Use the predefined value. jpayne@69: #elif defined(__clang__) jpayne@69: // Test for compiler vs. feature separately. jpayne@69: // Other compilers might choke on the feature test. jpayne@69: # if UPRV_HAS_CPP_ATTRIBUTE(clang::fallthrough) || \ jpayne@69: (UPRV_HAS_FEATURE(cxx_attributes) && \ jpayne@69: UPRV_HAS_WARNING("-Wimplicit-fallthrough")) jpayne@69: # define U_FALLTHROUGH [[clang::fallthrough]] jpayne@69: # endif jpayne@69: #elif defined(__GNUC__) && (__GNUC__ >= 7) jpayne@69: # define U_FALLTHROUGH __attribute__((fallthrough)) jpayne@69: #endif jpayne@69: jpayne@69: #ifndef U_FALLTHROUGH jpayne@69: # define U_FALLTHROUGH jpayne@69: #endif jpayne@69: jpayne@69: /** @} */ jpayne@69: jpayne@69: /*===========================================================================*/ jpayne@69: /** @{ Character data types */ jpayne@69: /*===========================================================================*/ jpayne@69: jpayne@69: /** jpayne@69: * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: #define U_ASCII_FAMILY 0 jpayne@69: jpayne@69: /** jpayne@69: * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform. jpayne@69: * @stable ICU 2.0 jpayne@69: */ jpayne@69: #define U_EBCDIC_FAMILY 1 jpayne@69: jpayne@69: /** jpayne@69: * \def U_CHARSET_FAMILY jpayne@69: * jpayne@69: *

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

jpayne@69: * jpayne@69: *

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

jpayne@69: * jpayne@69: *

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

jpayne@69: * jpayne@69: *

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

jpayne@69: * jpayne@69: *

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

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