ICU 49.1.2
49.1.2
|
00001 /* 00002 ****************************************************************************** 00003 * 00004 * Copyright (C) 1997-2012, International Business Machines 00005 * Corporation and others. All Rights Reserved. 00006 * 00007 ****************************************************************************** 00008 * 00009 * FILE NAME : platform.h 00010 * 00011 * Date Name Description 00012 * 05/13/98 nos Creation (content moved here from ptypes.h). 00013 * 03/02/99 stephen Added AS400 support. 00014 * 03/30/99 stephen Added Linux support. 00015 * 04/13/99 stephen Reworked for autoconf. 00016 ****************************************************************************** 00017 */ 00018 00019 #ifndef _PLATFORM_H 00020 #define _PLATFORM_H 00021 00022 #include "unicode/uconfig.h" 00023 #include "unicode/uvernum.h" 00024 00074 #define U_PF_UNKNOWN 0 00075 00076 #define U_PF_WINDOWS 1000 00077 00078 #define U_PF_MINGW 1800 00079 00084 #define U_PF_CYGWIN 1900 00085 /* Reserve 2000 for U_PF_UNIX? */ 00087 #define U_PF_HPUX 2100 00088 00089 #define U_PF_SOLARIS 2600 00090 00091 #define U_PF_BSD 3000 00092 00093 #define U_PF_AIX 3100 00094 00095 #define U_PF_IRIX 3200 00096 00104 #define U_PF_DARWIN 3500 00105 00106 #define U_PF_IPHONE 3550 00107 00108 #define U_PF_QNX 3700 00109 00110 #define U_PF_LINUX 4000 00111 00112 #define U_PF_ANDROID 4050 00113 00114 #define U_PF_CLASSIC_MACOS 8000 00115 00116 #define U_PF_OS390 9000 00117 00118 #define U_PF_OS400 9400 00119 00120 #ifdef U_PLATFORM 00121 /* Use the predefined value. */ 00122 #elif defined(__MINGW32__) 00123 # define U_PLATFORM U_PF_MINGW 00124 #elif defined(__CYGWIN__) 00125 # define U_PLATFORM U_PF_CYGWIN 00126 #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) 00127 # define U_PLATFORM U_PF_WINDOWS 00128 #elif defined(__ANDROID__) 00129 # define U_PLATFORM U_PF_ANDROID 00130 /* Android wchar_t support depends on the API level. */ 00131 # include <android/api-level.h> 00132 #elif defined(linux) || defined(__linux__) || defined(__linux) 00133 # define U_PLATFORM U_PF_LINUX 00134 #elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) 00135 # define U_PLATFORM U_PF_BSD 00136 #elif defined(sun) || defined(__sun) 00137 /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */ 00138 # define U_PLATFORM U_PF_SOLARIS 00139 # if defined(__GNUC__) 00140 /* Solaris/GCC needs this header file to get the proper endianness. Normally, this 00141 * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h 00142 * is included which does not include this header file. 00143 */ 00144 # include <sys/isa_defs.h> 00145 # endif 00146 #elif defined(_AIX) || defined(__TOS_AIX__) 00147 # define U_PLATFORM U_PF_AIX 00148 #elif defined(_hpux) || defined(hpux) || defined(__hpux) 00149 # define U_PLATFORM U_PF_HPUX 00150 #elif defined(sgi) || defined(__sgi) 00151 # define U_PLATFORM U_PF_IRIX 00152 #elif defined(__APPLE__) && defined(__MACH__) 00153 # include <TargetConditionals.h> 00154 # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* variant of TARGET_OS_MAC */ 00155 # define U_PLATFORM U_PF_IPHONE 00156 # else 00157 # define U_PLATFORM U_PF_DARWIN 00158 # endif 00159 #elif defined(macintosh) 00160 # define U_PLATFORM U_PF_CLASSIC_MACOS 00161 #elif defined(__QNX__) || defined(__QNXNTO__) 00162 # define U_PLATFORM U_PF_QNX 00163 #elif defined(__TOS_MVS__) 00164 # define U_PLATFORM U_PF_OS390 00165 #elif defined(__OS400__) || defined(__TOS_OS400__) 00166 # define U_PLATFORM U_PF_OS400 00167 #else 00168 # define U_PLATFORM U_PF_UNKNOWN 00169 #endif 00170 00177 /* Commented out because this is already set in mh-cygwin-msvc 00178 #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER) 00179 # define CYGWINMSVC 00180 #endif 00181 */ 00182 00189 #ifdef U_PLATFORM_USES_ONLY_WIN32_API 00190 /* Use the predefined value. */ 00191 #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC) 00192 # define U_PLATFORM_USES_ONLY_WIN32_API 1 00193 #else 00194 /* Cygwin implements POSIX. */ 00195 # define U_PLATFORM_USES_ONLY_WIN32_API 0 00196 #endif 00197 00204 #ifdef U_PLATFORM_HAS_WIN32_API 00205 /* Use the predefined value. */ 00206 #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN 00207 # define U_PLATFORM_HAS_WIN32_API 1 00208 #else 00209 # define U_PLATFORM_HAS_WIN32_API 0 00210 #endif 00211 00218 #ifdef U_PLATFORM_IMPLEMENTS_POSIX 00219 /* Use the predefined value. */ 00220 #elif U_PLATFORM_USES_ONLY_WIN32_API || U_PLATFORM == U_PF_CLASSIC_MACOS 00221 # define U_PLATFORM_IMPLEMENTS_POSIX 0 00222 #else 00223 # define U_PLATFORM_IMPLEMENTS_POSIX 1 00224 #endif 00225 00231 #ifdef U_PLATFORM_IS_LINUX_BASED 00232 /* Use the predefined value. */ 00233 #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= U_PF_ANDROID 00234 # define U_PLATFORM_IS_LINUX_BASED 1 00235 #else 00236 # define U_PLATFORM_IS_LINUX_BASED 0 00237 #endif 00238 00244 #ifdef U_PLATFORM_IS_DARWIN_BASED 00245 /* Use the predefined value. */ 00246 #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE 00247 # define U_PLATFORM_IS_DARWIN_BASED 1 00248 #else 00249 # define U_PLATFORM_IS_DARWIN_BASED 0 00250 #endif 00251 00259 #ifdef U_HAVE_STDINT_H 00260 /* Use the predefined value. */ 00261 #elif U_PLATFORM_USES_ONLY_WIN32_API 00262 # if defined(__BORLANDC__) || (defined(_MSC_VER) && _MSC_VER>=1600) 00263 /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */ 00264 # define U_HAVE_STDINT_H 1 00265 # else 00266 # define U_HAVE_STDINT_H 0 00267 # endif 00268 #elif U_PLATFORM == U_PF_SOLARIS 00269 /* Solaris has inttypes.h but not stdint.h. */ 00270 # define U_HAVE_STDINT_H 0 00271 #else 00272 # define U_HAVE_STDINT_H 1 00273 #endif 00274 00281 #ifdef U_HAVE_INTTYPES_H 00282 /* Use the predefined value. */ 00283 #elif U_PLATFORM == U_PF_SOLARIS 00284 /* Solaris has inttypes.h but not stdint.h. */ 00285 # define U_HAVE_INTTYPES_H 1 00286 #else 00287 /* Most platforms have both inttypes.h and stdint.h, or neither. */ 00288 # define U_HAVE_INTTYPES_H U_HAVE_STDINT_H 00289 #endif 00290 00312 #ifndef U_IOSTREAM_SOURCE 00313 #define U_IOSTREAM_SOURCE 199711 00314 #endif 00315 00321 #ifdef U_HAVE_STD_STRING 00322 /* Use the predefined value. */ 00323 #elif U_PLATFORM == U_PF_ANDROID 00324 # define U_HAVE_STD_STRING 0 00325 #else 00326 # define U_HAVE_STD_STRING 1 00327 #endif 00328 00329 /*===========================================================================*/ 00331 /*===========================================================================*/ 00332 00338 #ifdef U_IS_BIG_ENDIAN 00339 /* Use the predefined value. */ 00340 #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN) 00341 # define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN) 00342 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) 00343 /* gcc */ 00344 # define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) 00345 #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN) 00346 # define U_IS_BIG_ENDIAN 1 00347 #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN) 00348 # define U_IS_BIG_ENDIAN 0 00349 #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__) 00350 /* These platforms do not appear to predefine any endianness macros. */ 00351 # define U_IS_BIG_ENDIAN 1 00352 #elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0) 00353 /* HPPA do not appear to predefine any endianness macros. */ 00354 # define U_IS_BIG_ENDIAN 1 00355 #else 00356 # define U_IS_BIG_ENDIAN 0 00357 #endif 00358 00364 #ifdef U_HAVE_PLACEMENT_NEW 00365 /* Use the predefined value. */ 00366 #elif defined(__BORLANDC__) 00367 # define U_HAVE_PLACEMENT_NEW 0 00368 #else 00369 # define U_HAVE_PLACEMENT_NEW 1 00370 #endif 00371 00378 #ifdef U_HAVE_DEBUG_LOCATION_NEW 00379 /* Use the predefined value. */ 00380 #elif defined(_MSC_VER) 00381 # define U_HAVE_DEBUG_LOCATION_NEW 1 00382 #else 00383 # define U_HAVE_DEBUG_LOCATION_NEW 0 00384 #endif 00385 00388 /*===========================================================================*/ 00390 /*===========================================================================*/ 00391 00396 #define U_ASCII_FAMILY 0 00397 00402 #define U_EBCDIC_FAMILY 1 00403 00446 #ifdef U_CHARSET_FAMILY 00447 /* Use the predefined value. */ 00448 #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB) 00449 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY 00450 #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__) 00451 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY 00452 #else 00453 # define U_CHARSET_FAMILY U_ASCII_FAMILY 00454 #endif 00455 00476 #ifdef U_CHARSET_IS_UTF8 00477 /* Use the predefined value. */ 00478 #elif U_PLATFORM == U_PF_ANDROID || U_PLATFORM_IS_DARWIN_BASED 00479 # define U_CHARSET_IS_UTF8 1 00480 #else 00481 # define U_CHARSET_IS_UTF8 0 00482 #endif 00483 00486 /*===========================================================================*/ 00488 /*===========================================================================*/ 00489 00496 #ifdef U_HAVE_WCHAR_H 00497 /* Use the predefined value. */ 00498 #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9 00499 /* 00500 * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t. 00501 * The type and header existed, but the library functions did not work as expected. 00502 * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway. 00503 */ 00504 # define U_HAVE_WCHAR_H 0 00505 #else 00506 # define U_HAVE_WCHAR_H 1 00507 #endif 00508 00515 #ifdef U_SIZEOF_WCHAR_T 00516 /* Use the predefined value. */ 00517 #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9) || U_PLATFORM == U_PF_CLASSIC_MACOS 00518 /* 00519 * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring. 00520 * Newer Mac OS X has size 4. 00521 */ 00522 # define U_SIZEOF_WCHAR_T 1 00523 #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN 00524 # define U_SIZEOF_WCHAR_T 2 00525 #elif U_PLATFORM == U_PF_AIX 00526 /* 00527 * AIX 6.1 information, section "Wide character data representation": 00528 * "... the wchar_t datatype is 32-bit in the 64-bit environment and 00529 * 16-bit in the 32-bit environment." 00530 * and 00531 * "All locales use Unicode for their wide character code values (process code), 00532 * except the IBM-eucTW codeset." 00533 */ 00534 # ifdef __64BIT__ 00535 # define U_SIZEOF_WCHAR_T 4 00536 # else 00537 # define U_SIZEOF_WCHAR_T 2 00538 # endif 00539 #elif U_PLATFORM == U_PF_OS390 00540 /* 00541 * z/OS V1R11 information center, section "LP64 | ILP32": 00542 * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes. 00543 * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes." 00544 */ 00545 # ifdef _LP64 00546 # define U_SIZEOF_WCHAR_T 4 00547 # else 00548 # define U_SIZEOF_WCHAR_T 2 00549 # endif 00550 #elif U_PLATFORM == U_PF_OS400 00551 # if defined(__UTF32__) 00552 /* 00553 * LOCALETYPE(*LOCALEUTF) is specified. 00554 * Wide-character strings are in UTF-32, 00555 * narrow-character strings are in UTF-8. 00556 */ 00557 # define U_SIZEOF_WCHAR_T 4 00558 # elif defined(__UCS2__) 00559 /* 00560 * LOCALETYPE(*LOCALEUCS2) is specified. 00561 * Wide-character strings are in UCS-2, 00562 * narrow-character strings are in EBCDIC. 00563 */ 00564 # define U_SIZEOF_WCHAR_T 2 00565 #else 00566 /* 00567 * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified. 00568 * Wide-character strings are in 16-bit EBCDIC, 00569 * narrow-character strings are in EBCDIC. 00570 */ 00571 # define U_SIZEOF_WCHAR_T 2 00572 # endif 00573 #else 00574 # define U_SIZEOF_WCHAR_T 4 00575 #endif 00576 00577 #ifndef U_HAVE_WCSCPY 00578 #define U_HAVE_WCSCPY U_HAVE_WCHAR_H 00579 #endif 00580 00591 #ifdef U_HAVE_CHAR16_T 00592 /* Use the predefined value. */ 00593 #else 00594 /* 00595 * Notes: 00596 * Visual Studio 10 (_MSC_VER>=1600) defines char16_t but 00597 * does not support u"abc" string literals. 00598 * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but 00599 * does not support u"abc" string literals. 00600 */ 00601 # define U_HAVE_CHAR16_T 0 00602 #endif 00603 00611 #ifdef U_DECLARE_UTF16 00612 /* Use the predefined value. */ 00613 #elif (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \ 00614 || (defined(__HP_aCC) && __HP_aCC >= 035000) \ 00615 || (defined(__HP_cc) && __HP_cc >= 111106) \ 00616 || U_HAVE_CHAR16_T 00617 # define U_DECLARE_UTF16(string) u ## string 00618 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) 00619 /* || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x580) */ 00620 /* Sun's C compiler has issues with this notation, and it's unreliable. */ 00621 # define U_DECLARE_UTF16(string) U ## string 00622 #elif U_SIZEOF_WCHAR_T == 2 \ 00623 && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__))) 00624 # define U_DECLARE_UTF16(string) L ## string 00625 #else 00626 /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */ 00627 #endif 00628 00631 /*===========================================================================*/ 00633 /*===========================================================================*/ 00634 00635 #ifdef U_EXPORT 00636 /* Use the predefined value. */ 00637 #elif defined(U_STATIC_IMPLEMENTATION) 00638 # define U_EXPORT 00639 #elif defined(__GNUC__) 00640 # define U_EXPORT __attribute__((visibility("default"))) 00641 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \ 00642 || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) 00643 # define U_EXPORT __global 00644 /*#elif defined(__HP_aCC) || defined(__HP_cc) 00645 # define U_EXPORT __declspec(dllexport)*/ 00646 #elif defined(_MSC_VER) 00647 # define U_EXPORT __declspec(dllexport) 00648 #else 00649 # define U_EXPORT 00650 #endif 00651 00652 /* U_CALLCONV is releated to U_EXPORT2 */ 00653 #ifdef U_EXPORT2 00654 /* Use the predefined value. */ 00655 #elif defined(_MSC_VER) 00656 # define U_EXPORT2 __cdecl 00657 #else 00658 # define U_EXPORT2 00659 #endif 00660 00661 #ifdef U_IMPORT 00662 /* Use the predefined value. */ 00663 #elif defined(_MSC_VER) 00664 /* Windows needs to export/import data. */ 00665 # define U_IMPORT __declspec(dllimport) 00666 #else 00667 # define U_IMPORT 00668 #endif 00669 00681 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus) 00682 # define U_CALLCONV __cdecl 00683 #else 00684 # define U_CALLCONV U_EXPORT2 00685 #endif 00686 00687 /* @} */ 00688 00689 #endif