platform.h

Go to the documentation of this file.
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 
00057 #ifdef U_IN_DOXYGEN
00058 /*
00059  * Problem: "platform.h:335: warning: documentation for unknown define U_HAVE_STD_STRING found." means that U_HAVE_STD_STRING is not documented.
00060  * 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.
00061  */
00062 
00063 /* None for now. */
00064 #endif
00065 
00087 #define U_PF_UNKNOWN 0
00088 
00089 #define U_PF_WINDOWS 1000
00090 
00091 #define U_PF_MINGW 1800
00092 
00097 #define U_PF_CYGWIN 1900
00098 /* Reserve 2000 for U_PF_UNIX? */
00100 #define U_PF_HPUX 2100
00101 
00102 #define U_PF_SOLARIS 2600
00103 
00104 #define U_PF_BSD 3000
00105 
00106 #define U_PF_AIX 3100
00107 
00108 #define U_PF_IRIX 3200
00109 
00117 #define U_PF_DARWIN 3500
00118 
00119 #define U_PF_IPHONE 3550
00120 
00121 #define U_PF_QNX 3700
00122 
00123 #define U_PF_LINUX 4000
00124 
00125 #define U_PF_ANDROID 4050
00126 
00127 #define U_PF_CLASSIC_MACOS 8000
00128 
00129 #define U_PF_OS390 9000
00130 
00131 #define U_PF_OS400 9400
00132 
00133 #ifdef U_PLATFORM
00134     /* Use the predefined value. */
00135 #elif defined(__MINGW32__)
00136 #   define U_PLATFORM U_PF_MINGW
00137 #elif defined(__CYGWIN__)
00138 #   define U_PLATFORM U_PF_CYGWIN
00139 #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
00140 #   define U_PLATFORM U_PF_WINDOWS
00141 #elif defined(__ANDROID__)
00142 #   define U_PLATFORM U_PF_ANDROID
00143     /* Android wchar_t support depends on the API level. */
00144 #   include <android/api-level.h>
00145 #elif defined(linux) || defined(__linux__) || defined(__linux)
00146 #   define U_PLATFORM U_PF_LINUX
00147 #elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__)
00148 #   define U_PLATFORM U_PF_BSD
00149 #elif defined(sun) || defined(__sun)
00150     /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */
00151 #   define U_PLATFORM U_PF_SOLARIS
00152 #   if defined(__GNUC__)
00153         /* Solaris/GCC needs this header file to get the proper endianness. Normally, this
00154          * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h
00155          *  is included which does not include this header file.
00156          */
00157 #       include <sys/isa_defs.h>
00158 #   endif
00159 #elif defined(_AIX) || defined(__TOS_AIX__)
00160 #   define U_PLATFORM U_PF_AIX
00161 #elif defined(_hpux) || defined(hpux) || defined(__hpux)
00162 #   define U_PLATFORM U_PF_HPUX
00163 #elif defined(sgi) || defined(__sgi)
00164 #   define U_PLATFORM U_PF_IRIX
00165 #elif defined(__APPLE__) && defined(__MACH__)
00166 #   include <TargetConditionals.h>
00167 #   if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE  /* variant of TARGET_OS_MAC */
00168 #       define U_PLATFORM U_PF_IPHONE
00169 #   else
00170 #       define U_PLATFORM U_PF_DARWIN
00171 #   endif
00172 #elif defined(macintosh)
00173 #   define U_PLATFORM U_PF_CLASSIC_MACOS
00174 #elif defined(__QNX__) || defined(__QNXNTO__)
00175 #   define U_PLATFORM U_PF_QNX
00176 #elif defined(__TOS_MVS__)
00177 #   define U_PLATFORM U_PF_OS390
00178 #elif defined(__OS400__) || defined(__TOS_OS400__)
00179 #   define U_PLATFORM U_PF_OS400
00180 #else
00181 #   define U_PLATFORM U_PF_UNKNOWN
00182 #endif
00183 
00190 /* Commented out because this is already set in mh-cygwin-msvc
00191 #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER)
00192 #   define CYGWINMSVC
00193 #endif
00194 */
00195 
00202 #ifdef U_PLATFORM_USES_ONLY_WIN32_API
00203     /* Use the predefined value. */
00204 #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC)
00205 #   define U_PLATFORM_USES_ONLY_WIN32_API 1
00206 #else
00207     /* Cygwin implements POSIX. */
00208 #   define U_PLATFORM_USES_ONLY_WIN32_API 0
00209 #endif
00210 
00217 #ifdef U_PLATFORM_HAS_WIN32_API
00218     /* Use the predefined value. */
00219 #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
00220 #   define U_PLATFORM_HAS_WIN32_API 1
00221 #else
00222 #   define U_PLATFORM_HAS_WIN32_API 0
00223 #endif
00224 
00231 #ifdef U_PLATFORM_IMPLEMENTS_POSIX
00232     /* Use the predefined value. */
00233 #elif U_PLATFORM_USES_ONLY_WIN32_API || U_PLATFORM == U_PF_CLASSIC_MACOS
00234 #   define U_PLATFORM_IMPLEMENTS_POSIX 0
00235 #else
00236 #   define U_PLATFORM_IMPLEMENTS_POSIX 1
00237 #endif
00238 
00244 #ifdef U_PLATFORM_IS_LINUX_BASED
00245     /* Use the predefined value. */
00246 #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= U_PF_ANDROID
00247 #   define U_PLATFORM_IS_LINUX_BASED 1
00248 #else
00249 #   define U_PLATFORM_IS_LINUX_BASED 0
00250 #endif
00251 
00257 #ifdef U_PLATFORM_IS_DARWIN_BASED
00258     /* Use the predefined value. */
00259 #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE
00260 #   define U_PLATFORM_IS_DARWIN_BASED 1
00261 #else
00262 #   define U_PLATFORM_IS_DARWIN_BASED 0
00263 #endif
00264 
00272 #ifdef U_HAVE_STDINT_H
00273     /* Use the predefined value. */
00274 #elif U_PLATFORM_USES_ONLY_WIN32_API
00275 #   if defined(__BORLANDC__) || (defined(_MSC_VER) && _MSC_VER>=1600)
00276         /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */
00277 #       define U_HAVE_STDINT_H 1
00278 #   else
00279 #       define U_HAVE_STDINT_H 0
00280 #   endif
00281 #elif U_PLATFORM == U_PF_SOLARIS
00282     /* Solaris has inttypes.h but not stdint.h. */
00283 #   define U_HAVE_STDINT_H 0
00284 #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
00285     /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
00286 #   define U_HAVE_STDINT_H 0
00287 #else
00288 #   define U_HAVE_STDINT_H 1
00289 #endif
00290 
00297 #ifdef U_HAVE_INTTYPES_H
00298     /* Use the predefined value. */
00299 #elif U_PLATFORM == U_PF_SOLARIS
00300     /* Solaris has inttypes.h but not stdint.h. */
00301 #   define U_HAVE_INTTYPES_H 1
00302 #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
00303     /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
00304 #   define U_HAVE_INTTYPES_H 1
00305 #else
00306     /* Most platforms have both inttypes.h and stdint.h, or neither. */
00307 #   define U_HAVE_INTTYPES_H U_HAVE_STDINT_H
00308 #endif
00309 
00331 #ifndef U_IOSTREAM_SOURCE
00332 #define U_IOSTREAM_SOURCE 199711
00333 #endif
00334 
00340 #ifdef U_HAVE_STD_STRING
00341     /* Use the predefined value. */
00342 #elif U_PLATFORM == U_PF_ANDROID
00343 #   define U_HAVE_STD_STRING 0
00344 #else
00345 #   define U_HAVE_STD_STRING 1
00346 #endif
00347 
00348 /*===========================================================================*/
00350 /*===========================================================================*/
00351 
00362 #ifdef __GNUC__
00363 #   define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__)
00364 #else
00365 #   define U_GCC_MAJOR_MINOR 0
00366 #endif
00367 
00373 #ifdef U_IS_BIG_ENDIAN
00374     /* Use the predefined value. */
00375 #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN)
00376 #   define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
00377 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
00378     /* gcc */
00379 #   define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
00380 #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
00381 #   define U_IS_BIG_ENDIAN 1
00382 #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)
00383 #   define U_IS_BIG_ENDIAN 0
00384 #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__)
00385     /* These platforms do not appear to predefine any endianness macros. */
00386 #   define U_IS_BIG_ENDIAN 1
00387 #elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0)
00388     /* HPPA do not appear to predefine any endianness macros. */
00389 #   define U_IS_BIG_ENDIAN 1
00390 #elif defined(sparc) || defined(__sparc) || defined(__sparc__)
00391     /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */
00392 #   define U_IS_BIG_ENDIAN 1
00393 #else
00394 #   define U_IS_BIG_ENDIAN 0
00395 #endif
00396 
00402 #ifdef U_HAVE_PLACEMENT_NEW
00403     /* Use the predefined value. */
00404 #elif defined(__BORLANDC__)
00405 #   define U_HAVE_PLACEMENT_NEW 0
00406 #else
00407 #   define U_HAVE_PLACEMENT_NEW 1
00408 #endif
00409 
00416 #ifdef U_HAVE_DEBUG_LOCATION_NEW
00417     /* Use the predefined value. */
00418 #elif defined(_MSC_VER)
00419 #   define U_HAVE_DEBUG_LOCATION_NEW 1
00420 #else
00421 #   define U_HAVE_DEBUG_LOCATION_NEW 0
00422 #endif
00423 
00424 /* Compatibility with non clang compilers */
00425 #ifndef __has_attribute
00426 #    define __has_attribute(x) 0
00427 #endif
00428 
00434 #if defined(__GNUC__) && __GNUC__>=3
00435 #    define U_MALLOC_ATTR __attribute__ ((__malloc__))
00436 #else
00437 #    define U_MALLOC_ATTR
00438 #endif
00439 
00445 #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || __has_attribute(alloc_size)
00446 #   define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X)))
00447 #   define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y)))
00448 #else
00449 #   define U_ALLOC_SIZE_ATTR(X)
00450 #   define U_ALLOC_SIZE_ATTR2(X,Y)
00451 #endif
00452 
00455 /*===========================================================================*/
00457 /*===========================================================================*/
00458 
00463 #define U_ASCII_FAMILY 0
00464 
00469 #define U_EBCDIC_FAMILY 1
00470 
00513 #ifdef U_CHARSET_FAMILY
00514     /* Use the predefined value. */
00515 #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB)
00516 #   define U_CHARSET_FAMILY U_EBCDIC_FAMILY
00517 #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__)
00518 #   define U_CHARSET_FAMILY U_EBCDIC_FAMILY
00519 #else
00520 #   define U_CHARSET_FAMILY U_ASCII_FAMILY
00521 #endif
00522 
00543 #ifdef U_CHARSET_IS_UTF8
00544     /* Use the predefined value. */
00545 #elif U_PLATFORM == U_PF_ANDROID || U_PLATFORM_IS_DARWIN_BASED
00546 #   define U_CHARSET_IS_UTF8 1
00547 #else
00548 #   define U_CHARSET_IS_UTF8 0
00549 #endif
00550 
00553 /*===========================================================================*/
00555 /*===========================================================================*/
00556 
00563 #ifdef U_HAVE_WCHAR_H
00564     /* Use the predefined value. */
00565 #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9
00566     /*
00567      * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t.
00568      * The type and header existed, but the library functions did not work as expected.
00569      * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway.
00570      */
00571 #   define U_HAVE_WCHAR_H 0
00572 #else
00573 #   define U_HAVE_WCHAR_H 1
00574 #endif
00575 
00582 #ifdef U_SIZEOF_WCHAR_T
00583     /* Use the predefined value. */
00584 #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9) || U_PLATFORM == U_PF_CLASSIC_MACOS
00585     /*
00586      * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring.
00587      * Newer Mac OS X has size 4.
00588      */
00589 #   define U_SIZEOF_WCHAR_T 1
00590 #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN
00591 #   define U_SIZEOF_WCHAR_T 2
00592 #elif U_PLATFORM == U_PF_AIX
00593     /*
00594      * AIX 6.1 information, section "Wide character data representation":
00595      * "... the wchar_t datatype is 32-bit in the 64-bit environment and
00596      * 16-bit in the 32-bit environment."
00597      * and
00598      * "All locales use Unicode for their wide character code values (process code),
00599      * except the IBM-eucTW codeset."
00600      */
00601 #   ifdef __64BIT__
00602 #       define U_SIZEOF_WCHAR_T 4
00603 #   else
00604 #       define U_SIZEOF_WCHAR_T 2
00605 #   endif
00606 #elif U_PLATFORM == U_PF_OS390
00607     /*
00608      * z/OS V1R11 information center, section "LP64 | ILP32":
00609      * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes.
00610      * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes."
00611      */
00612 #   ifdef _LP64
00613 #       define U_SIZEOF_WCHAR_T 4
00614 #   else
00615 #       define U_SIZEOF_WCHAR_T 2
00616 #   endif
00617 #elif U_PLATFORM == U_PF_OS400
00618 #   if defined(__UTF32__)
00619         /*
00620          * LOCALETYPE(*LOCALEUTF) is specified.
00621          * Wide-character strings are in UTF-32,
00622          * narrow-character strings are in UTF-8.
00623          */
00624 #       define U_SIZEOF_WCHAR_T 4
00625 #   elif defined(__UCS2__)
00626         /*
00627          * LOCALETYPE(*LOCALEUCS2) is specified.
00628          * Wide-character strings are in UCS-2,
00629          * narrow-character strings are in EBCDIC.
00630          */
00631 #       define U_SIZEOF_WCHAR_T 2
00632 #else
00633         /*
00634          * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified.
00635          * Wide-character strings are in 16-bit EBCDIC,
00636          * narrow-character strings are in EBCDIC.
00637          */
00638 #       define U_SIZEOF_WCHAR_T 2
00639 #   endif
00640 #else
00641 #   define U_SIZEOF_WCHAR_T 4
00642 #endif
00643 
00644 #ifndef U_HAVE_WCSCPY
00645 #define U_HAVE_WCSCPY U_HAVE_WCHAR_H
00646 #endif
00647 
00658 #ifdef U_HAVE_CHAR16_T
00659     /* Use the predefined value. */
00660 #else
00661     /*
00662      * Notes:
00663      * Visual Studio 10 (_MSC_VER>=1600) defines char16_t but
00664      * does not support u"abc" string literals.
00665      * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but
00666      * does not support u"abc" string literals.
00667      * C++11 and C11 require support for UTF-16 literals
00668      */
00669 #   if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
00670 #       define U_HAVE_CHAR16_T 1
00671 #   else
00672 #       define U_HAVE_CHAR16_T 0
00673 #   endif
00674 #endif
00675 
00683 #ifdef U_DECLARE_UTF16
00684     /* Use the predefined value. */
00685 #elif U_HAVE_CHAR16_T \
00686     || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
00687     || (defined(__HP_aCC) && __HP_aCC >= 035000) \
00688     || (defined(__HP_cc) && __HP_cc >= 111106)
00689 #   define U_DECLARE_UTF16(string) u ## string
00690 #elif U_SIZEOF_WCHAR_T == 2 \
00691     && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__)))
00692 #   define U_DECLARE_UTF16(string) L ## string
00693 #else
00694     /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */
00695 #endif
00696 
00699 /*===========================================================================*/
00701 /*===========================================================================*/
00702 
00703 #ifdef U_EXPORT
00704     /* Use the predefined value. */
00705 #elif defined(U_STATIC_IMPLEMENTATION)
00706 #   define U_EXPORT
00707 #elif defined(__GNUC__)
00708 #   define U_EXPORT __attribute__((visibility("default")))
00709 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
00710    || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) 
00711 #   define U_EXPORT __global
00712 /*#elif defined(__HP_aCC) || defined(__HP_cc)
00713 #   define U_EXPORT __declspec(dllexport)*/
00714 #elif defined(_MSC_VER)
00715 #   define U_EXPORT __declspec(dllexport)
00716 #else
00717 #   define U_EXPORT
00718 #endif
00719 
00720 /* U_CALLCONV is releated to U_EXPORT2 */
00721 #ifdef U_EXPORT2
00722     /* Use the predefined value. */
00723 #elif defined(_MSC_VER)
00724 #   define U_EXPORT2 __cdecl
00725 #else
00726 #   define U_EXPORT2
00727 #endif
00728 
00729 #ifdef U_IMPORT
00730     /* Use the predefined value. */
00731 #elif defined(_MSC_VER)
00732     /* Windows needs to export/import data. */
00733 #   define U_IMPORT __declspec(dllimport)
00734 #else
00735 #   define U_IMPORT 
00736 #endif
00737 
00749 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
00750 #    define U_CALLCONV __cdecl
00751 #else
00752 #    define U_CALLCONV U_EXPORT2
00753 #endif
00754 
00755 /* @} */
00756 
00757 #endif

Generated on 27 Oct 2013 for ICU 50.1.2 by  doxygen 1.4.7