X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/4388f060552cc537e71e957d32f35e9d75a61233..b801cf366c7671a99bdcef84d1e9c0ec64b36723:/icuSources/common/unicode/platform.h?ds=sidebyside diff --git a/icuSources/common/unicode/platform.h b/icuSources/common/unicode/platform.h index dccc7018..48290006 100644 --- a/icuSources/common/unicode/platform.h +++ b/icuSources/common/unicode/platform.h @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 1997-2012, International Business Machines +* Copyright (C) 1997-2015, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -36,7 +36,7 @@ * and/or from other macros that are predefined by the compiler * or defined in standard (POSIX or platform or compiler) headers. * - * As a temporary workaround, you can add an explicit #define for some macros + * As a temporary workaround, you can add an explicit #define for some macros * before it is first tested, or add an equivalent -D macro definition * to the compiler's command line. * @@ -50,6 +50,19 @@ * -x c++ is for C++.) */ +/** + * Define some things so that they can be documented. + * @internal + */ +#ifdef U_IN_DOXYGEN +/* + * Problem: "platform.h:335: warning: documentation for unknown define U_HAVE_STD_STRING found." means that U_HAVE_STD_STRING is not documented. + * 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. + */ + +/* None for now. */ +#endif + /** * \def U_PLATFORM * The U_PLATFORM macro defines the platform we're on. @@ -108,10 +121,16 @@ #define U_PF_QNX 3700 /** Linux is a Unix-like operating system. @internal */ #define U_PF_LINUX 4000 +/** + * Native Client is pretty close to Linux. + * See https://developer.chrome.com/native-client and + * http://www.chromium.org/nativeclient + * @internal + */ +#define U_PF_BROWSER_NATIVE_CLIENT 4020 /** Android is based on Linux. @internal */ #define U_PF_ANDROID 4050 -/** "Classic" Mac OS (1984-2001) @internal */ -#define U_PF_CLASSIC_MACOS 8000 +/* Maximum value for Linux-based platform is 4499 */ /** z/OS is the successor to OS/390 which was the successor to MVS. @internal */ #define U_PF_OS390 9000 /** "IBM i" is the current name of what used to be i5/OS and earlier OS/400. @internal */ @@ -129,9 +148,18 @@ # define U_PLATFORM U_PF_ANDROID /* Android wchar_t support depends on the API level. */ # include +#elif defined(__native_client__) +# define U_PLATFORM U_PF_BROWSER_NATIVE_CLIENT #elif defined(linux) || defined(__linux__) || defined(__linux) # define U_PLATFORM U_PF_LINUX -#elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#elif defined(__APPLE__) && defined(__MACH__) +# include +# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* variant of TARGET_OS_MAC */ +# define U_PLATFORM U_PF_IPHONE +# else +# define U_PLATFORM U_PF_DARWIN +# endif +#elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__) # define U_PLATFORM U_PF_BSD #elif defined(sun) || defined(__sun) /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */ @@ -149,15 +177,6 @@ # define U_PLATFORM U_PF_HPUX #elif defined(sgi) || defined(__sgi) # define U_PLATFORM U_PF_IRIX -#elif defined(__APPLE__) && defined(__MACH__) -# include -# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* variant of TARGET_OS_MAC */ -# define U_PLATFORM U_PF_IPHONE -# else -# define U_PLATFORM U_PF_DARWIN -# endif -#elif defined(macintosh) -# define U_PLATFORM U_PF_CLASSIC_MACOS #elif defined(__QNX__) || defined(__QNXNTO__) # define U_PLATFORM U_PF_QNX #elif defined(__TOS_MVS__) @@ -217,7 +236,7 @@ */ #ifdef U_PLATFORM_IMPLEMENTS_POSIX /* Use the predefined value. */ -#elif U_PLATFORM_USES_ONLY_WIN32_API || U_PLATFORM == U_PF_CLASSIC_MACOS +#elif U_PLATFORM_USES_ONLY_WIN32_API # define U_PLATFORM_IMPLEMENTS_POSIX 0 #else # define U_PLATFORM_IMPLEMENTS_POSIX 1 @@ -230,7 +249,7 @@ */ #ifdef U_PLATFORM_IS_LINUX_BASED /* Use the predefined value. */ -#elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= U_PF_ANDROID +#elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= 4499 # define U_PLATFORM_IS_LINUX_BASED 1 #else # define U_PLATFORM_IS_LINUX_BASED 0 @@ -259,7 +278,7 @@ #ifdef U_HAVE_STDINT_H /* Use the predefined value. */ #elif U_PLATFORM_USES_ONLY_WIN32_API -# if defined(__BORLANDC__) || (defined(_MSC_VER) && _MSC_VER>=1600) +# if defined(__BORLANDC__) || U_PLATFORM == U_PF_MINGW || (defined(_MSC_VER) && _MSC_VER>=1600) /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */ # define U_HAVE_STDINT_H 1 # else @@ -268,6 +287,9 @@ #elif U_PLATFORM == U_PF_SOLARIS /* Solaris has inttypes.h but not stdint.h. */ # define U_HAVE_STDINT_H 0 +#elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER) + /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */ +# define U_HAVE_STDINT_H 0 #else # define U_HAVE_STDINT_H 1 #endif @@ -283,6 +305,9 @@ #elif U_PLATFORM == U_PF_SOLARIS /* Solaris has inttypes.h but not stdint.h. */ # define U_HAVE_INTTYPES_H 1 +#elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER) + /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */ +# define U_HAVE_INTTYPES_H 1 #else /* Most platforms have both inttypes.h and stdint.h, or neither. */ # define U_HAVE_INTTYPES_H U_HAVE_STDINT_H @@ -320,8 +345,6 @@ */ #ifdef U_HAVE_STD_STRING /* Use the predefined value. */ -#elif U_PLATFORM == U_PF_ANDROID -# define U_HAVE_STD_STRING 0 #else # define U_HAVE_STD_STRING 1 #endif @@ -330,6 +353,22 @@ /** @{ Compiler and environment features */ /*===========================================================================*/ +/** + * \def U_GCC_MAJOR_MINOR + * Indicates whether the compiler is gcc (test for != 0), + * and if so, contains its major (times 100) and minor version numbers. + * If the compiler is not gcc, then U_GCC_MAJOR_MINOR == 0. + * + * For example, for testing for whether we have gcc, and whether it's 4.6 or higher, + * use "#if U_GCC_MAJOR_MINOR >= 406". + * @internal + */ +#ifdef __GNUC__ +# define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__) +#else +# define U_GCC_MAJOR_MINOR 0 +#endif + /** * \def U_IS_BIG_ENDIAN * Determines the endianness of the platform. @@ -346,9 +385,15 @@ # define U_IS_BIG_ENDIAN 1 #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN) # define U_IS_BIG_ENDIAN 0 -#elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 +#elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__) /* These platforms do not appear to predefine any endianness macros. */ # define U_IS_BIG_ENDIAN 1 +#elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) + /* HPPA do not appear to predefine any endianness macros. */ +# define U_IS_BIG_ENDIAN 1 +#elif defined(sparc) || defined(__sparc) || defined(__sparc__) + /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */ +# define U_IS_BIG_ENDIAN 1 #else # define U_IS_BIG_ENDIAN 0 #endif @@ -380,6 +425,35 @@ # define U_HAVE_DEBUG_LOCATION_NEW 0 #endif +/* Compatibility with non clang compilers */ +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + +/** + * \def U_MALLOC_ATTR + * Attribute to mark functions as malloc-like + * @internal + */ +#if defined(__GNUC__) && __GNUC__>=3 +# define U_MALLOC_ATTR __attribute__ ((__malloc__)) +#else +# define U_MALLOC_ATTR +#endif + +/** + * \def U_ALLOC_SIZE_ATTR + * Attribute to specify the size of the allocated buffer for malloc-like functions + * @internal + */ +#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || __has_attribute(alloc_size) +# define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X))) +# define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y))) +#else +# define U_ALLOC_SIZE_ATTR(X) +# define U_ALLOC_SIZE_ATTR2(X,Y) +#endif + /** @} */ /*===========================================================================*/ @@ -511,7 +585,7 @@ */ #ifdef U_SIZEOF_WCHAR_T /* Use the predefined value. */ -#elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9) || U_PLATFORM == U_PF_CLASSIC_MACOS +#elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9) /* * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring. * Newer Mac OS X has size 4. @@ -594,8 +668,13 @@ * does not support u"abc" string literals. * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but * does not support u"abc" string literals. + * C++11 and C11 require support for UTF-16 literals */ -# define U_HAVE_CHAR16_T 0 +# if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) +# define U_HAVE_CHAR16_T 1 +# else +# define U_HAVE_CHAR16_T 0 +# endif #endif /** @@ -607,15 +686,11 @@ */ #ifdef U_DECLARE_UTF16 /* Use the predefined value. */ -#elif (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \ +#elif U_HAVE_CHAR16_T \ + || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \ || (defined(__HP_aCC) && __HP_aCC >= 035000) \ - || (defined(__HP_cc) && __HP_cc >= 111106) \ - || U_HAVE_CHAR16_T + || (defined(__HP_cc) && __HP_cc >= 111106) # define U_DECLARE_UTF16(string) u ## string -#elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) -/* || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x580) */ -/* Sun's C compiler has issues with this notation, and it's unreliable. */ -# define U_DECLARE_UTF16(string) U ## string #elif U_SIZEOF_WCHAR_T == 2 \ && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__))) # define U_DECLARE_UTF16(string) L ## string