ICU 49.1.1
49.1.1
|
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 00350 /* These platforms do not appear to predefine any endianness macros. */ 00351 # define U_IS_BIG_ENDIAN 1 00352 #else 00353 # define U_IS_BIG_ENDIAN 0 00354 #endif 00355 00361 #ifdef U_HAVE_PLACEMENT_NEW 00362 /* Use the predefined value. */ 00363 #elif defined(__BORLANDC__) 00364 # define U_HAVE_PLACEMENT_NEW 0 00365 #else 00366 # define U_HAVE_PLACEMENT_NEW 1 00367 #endif 00368 00375 #ifdef U_HAVE_DEBUG_LOCATION_NEW 00376 /* Use the predefined value. */ 00377 #elif defined(_MSC_VER) 00378 # define U_HAVE_DEBUG_LOCATION_NEW 1 00379 #else 00380 # define U_HAVE_DEBUG_LOCATION_NEW 0 00381 #endif 00382 00385 /*===========================================================================*/ 00387 /*===========================================================================*/ 00388 00393 #define U_ASCII_FAMILY 0 00394 00399 #define U_EBCDIC_FAMILY 1 00400 00443 #ifdef U_CHARSET_FAMILY 00444 /* Use the predefined value. */ 00445 #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB) 00446 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY 00447 #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__) 00448 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY 00449 #else 00450 # define U_CHARSET_FAMILY U_ASCII_FAMILY 00451 #endif 00452 00473 #ifdef U_CHARSET_IS_UTF8 00474 /* Use the predefined value. */ 00475 #elif U_PLATFORM == U_PF_ANDROID || U_PLATFORM_IS_DARWIN_BASED 00476 # define U_CHARSET_IS_UTF8 1 00477 #else 00478 # define U_CHARSET_IS_UTF8 0 00479 #endif 00480 00483 /*===========================================================================*/ 00485 /*===========================================================================*/ 00486 00493 #ifdef U_HAVE_WCHAR_H 00494 /* Use the predefined value. */ 00495 #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9 00496 /* 00497 * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t. 00498 * The type and header existed, but the library functions did not work as expected. 00499 * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway. 00500 */ 00501 # define U_HAVE_WCHAR_H 0 00502 #else 00503 # define U_HAVE_WCHAR_H 1 00504 #endif 00505 00512 #ifdef U_SIZEOF_WCHAR_T 00513 /* Use the predefined value. */ 00514 #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9) || U_PLATFORM == U_PF_CLASSIC_MACOS 00515 /* 00516 * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring. 00517 * Newer Mac OS X has size 4. 00518 */ 00519 # define U_SIZEOF_WCHAR_T 1 00520 #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN 00521 # define U_SIZEOF_WCHAR_T 2 00522 #elif U_PLATFORM == U_PF_AIX 00523 /* 00524 * AIX 6.1 information, section "Wide character data representation": 00525 * "... the wchar_t datatype is 32-bit in the 64-bit environment and 00526 * 16-bit in the 32-bit environment." 00527 * and 00528 * "All locales use Unicode for their wide character code values (process code), 00529 * except the IBM-eucTW codeset." 00530 */ 00531 # ifdef __64BIT__ 00532 # define U_SIZEOF_WCHAR_T 4 00533 # else 00534 # define U_SIZEOF_WCHAR_T 2 00535 # endif 00536 #elif U_PLATFORM == U_PF_OS390 00537 /* 00538 * z/OS V1R11 information center, section "LP64 | ILP32": 00539 * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes. 00540 * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes." 00541 */ 00542 # ifdef _LP64 00543 # define U_SIZEOF_WCHAR_T 4 00544 # else 00545 # define U_SIZEOF_WCHAR_T 2 00546 # endif 00547 #elif U_PLATFORM == U_PF_OS400 00548 # if defined(__UTF32__) 00549 /* 00550 * LOCALETYPE(*LOCALEUTF) is specified. 00551 * Wide-character strings are in UTF-32, 00552 * narrow-character strings are in UTF-8. 00553 */ 00554 # define U_SIZEOF_WCHAR_T 4 00555 # elif defined(__UCS2__) 00556 /* 00557 * LOCALETYPE(*LOCALEUCS2) is specified. 00558 * Wide-character strings are in UCS-2, 00559 * narrow-character strings are in EBCDIC. 00560 */ 00561 # define U_SIZEOF_WCHAR_T 2 00562 #else 00563 /* 00564 * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified. 00565 * Wide-character strings are in 16-bit EBCDIC, 00566 * narrow-character strings are in EBCDIC. 00567 */ 00568 # define U_SIZEOF_WCHAR_T 2 00569 # endif 00570 #else 00571 # define U_SIZEOF_WCHAR_T 4 00572 #endif 00573 00574 #ifndef U_HAVE_WCSCPY 00575 #define U_HAVE_WCSCPY U_HAVE_WCHAR_H 00576 #endif 00577 00588 #ifdef U_HAVE_CHAR16_T 00589 /* Use the predefined value. */ 00590 #else 00591 /* 00592 * Notes: 00593 * Visual Studio 10 (_MSC_VER>=1600) defines char16_t but 00594 * does not support u"abc" string literals. 00595 * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but 00596 * does not support u"abc" string literals. 00597 */ 00598 # define U_HAVE_CHAR16_T 0 00599 #endif 00600 00608 #ifdef U_DECLARE_UTF16 00609 /* Use the predefined value. */ 00610 #elif (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \ 00611 || (defined(__HP_aCC) && __HP_aCC >= 035000) \ 00612 || (defined(__HP_cc) && __HP_cc >= 111106) \ 00613 || U_HAVE_CHAR16_T 00614 # define U_DECLARE_UTF16(string) u ## string 00615 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) 00616 /* || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x580) */ 00617 /* Sun's C compiler has issues with this notation, and it's unreliable. */ 00618 # define U_DECLARE_UTF16(string) U ## string 00619 #elif U_SIZEOF_WCHAR_T == 2 \ 00620 && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__))) 00621 # define U_DECLARE_UTF16(string) L ## string 00622 #else 00623 /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */ 00624 #endif 00625 00628 /*===========================================================================*/ 00630 /*===========================================================================*/ 00631 00632 #ifdef U_EXPORT 00633 /* Use the predefined value. */ 00634 #elif defined(U_STATIC_IMPLEMENTATION) 00635 # define U_EXPORT 00636 #elif defined(__GNUC__) 00637 # define U_EXPORT __attribute__((visibility("default"))) 00638 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \ 00639 || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) 00640 # define U_EXPORT __global 00641 /*#elif defined(__HP_aCC) || defined(__HP_cc) 00642 # define U_EXPORT __declspec(dllexport)*/ 00643 #elif defined(_MSC_VER) 00644 # define U_EXPORT __declspec(dllexport) 00645 #else 00646 # define U_EXPORT 00647 #endif 00648 00649 /* U_CALLCONV is releated to U_EXPORT2 */ 00650 #ifdef U_EXPORT2 00651 /* Use the predefined value. */ 00652 #elif defined(_MSC_VER) 00653 # define U_EXPORT2 __cdecl 00654 #else 00655 # define U_EXPORT2 00656 #endif 00657 00658 #ifdef U_IMPORT 00659 /* Use the predefined value. */ 00660 #elif defined(_MSC_VER) 00661 /* Windows needs to export/import data. */ 00662 # define U_IMPORT __declspec(dllimport) 00663 #else 00664 # define U_IMPORT 00665 #endif 00666 00678 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus) 00679 # define U_CALLCONV __cdecl 00680 #else 00681 # define U_CALLCONV U_EXPORT2 00682 #endif 00683 00684 /* @} */ 00685 00686 #endif