Home | History | Annotate | Download | only in unicode
      1 /*
      2 ******************************************************************************
      3 *
      4 *   Copyright (C) 1997-2009, International Business Machines
      5 *   Corporation and others.  All Rights Reserved.
      6 *
      7 ******************************************************************************
      8 *
      9 *  FILE NAME : platform.h
     10 *
     11 *   Date        Name        Description
     12 *   05/13/98    nos         Creation (content moved here from ptypes.h).
     13 *   03/02/99    stephen     Added AS400 support.
     14 *   03/30/99    stephen     Added Linux support.
     15 *   04/13/99    stephen     Reworked for autoconf.
     16 ******************************************************************************
     17 */
     18 
     19 #ifndef _PLATFORM_H
     20 #define _PLATFORM_H
     21 
     22 /**
     23  * \file
     24  * \brief Basic types for the platform
     25  */
     26 
     27 /* Define the platform we're on. */
     28 #ifndef U_DARWIN
     29 #define U_DARWIN
     30 #endif
     31 
     32 #include <AvailabilityMacros.h>
     33 
     34 /**
     35  * \def U_HAVE_DIRENT_H
     36  * Define whether dirent.h is available */
     37 #ifndef U_HAVE_DIRENT_H
     38 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
     39 #define U_HAVE_DIRENT_H 0
     40 #else
     41 #define U_HAVE_DIRENT_H 1
     42 #endif
     43 #endif
     44 
     45 /** Define whether inttypes.h is available */
     46 #ifndef U_HAVE_INTTYPES_H
     47 #define U_HAVE_INTTYPES_H 1
     48 #endif
     49 
     50 /**
     51  * Define what support for C++ streams is available.
     52  *     If U_IOSTREAM_SOURCE is set to 199711, then &lt;iostream&gt; is available
     53  * (1997711 is the date the ISO/IEC C++ FDIS was published), and then
     54  * one should qualify streams using the std namespace in ICU header
     55  * files.
     56  *     If U_IOSTREAM_SOURCE is set to 198506, then &lt;iostream.h&gt; is
     57  * available instead (198506 is the date when Stroustrup published
     58  * "An Extensible I/O Facility for C++" at the summer USENIX conference).
     59  *     If U_IOSTREAM_SOURCE is 0, then C++ streams are not available and
     60  * support for them will be silently suppressed in ICU.
     61  *
     62  */
     63 
     64 #ifndef U_IOSTREAM_SOURCE
     65 #define U_IOSTREAM_SOURCE 199711
     66 #endif
     67 
     68 /**
     69  * \def U_HAVE_STD_STRING
     70  * Define whether the standard C++ (STL) <string> header is available.
     71  * For platforms that do not use platform.h and do not define this constant
     72  * in their platform-specific headers, std_string.h defaults
     73  * U_HAVE_STD_STRING to 1.
     74  * @draft ICU 4.2
     75  */
     76 #ifndef U_HAVE_STD_STRING
     77 #define U_HAVE_STD_STRING 1
     78 #endif
     79 
     80 /** @{ Determines whether specific types are available */
     81 #ifndef U_HAVE_INT8_T
     82 #define U_HAVE_INT8_T 1
     83 #endif
     84 
     85 #ifndef U_HAVE_UINT8_T
     86 #define U_HAVE_UINT8_T 1
     87 #endif
     88 
     89 #ifndef U_HAVE_INT16_T
     90 #define U_HAVE_INT16_T 1
     91 #endif
     92 
     93 #ifndef U_HAVE_UINT16_T
     94 #define U_HAVE_UINT16_T 1
     95 #endif
     96 
     97 #ifndef U_HAVE_INT32_T
     98 #define U_HAVE_INT32_T 1
     99 #endif
    100 
    101 #ifndef U_HAVE_UINT32_T
    102 #define U_HAVE_UINT32_T 1
    103 #endif
    104 
    105 #ifndef U_HAVE_INT64_T
    106 #define U_HAVE_INT64_T 1
    107 #endif
    108 
    109 #ifndef U_HAVE_UINT64_T
    110 #define U_HAVE_UINT64_T 1
    111 #endif
    112 
    113 /** @} */
    114 
    115 /*===========================================================================*/
    116 /** @{ Generic data types                                                        */
    117 /*===========================================================================*/
    118 
    119 #include <sys/types.h>
    120 
    121 /* If your platform does not have the <inttypes.h> header, you may
    122    need to edit the typedefs below. */
    123 #if U_HAVE_INTTYPES_H
    124 
    125 /* autoconf 2.13 sometimes can't properly find the data types in <inttypes.h> */
    126 /* os/390 needs <inttypes.h>, but it doesn't have int8_t, and it sometimes */
    127 /* doesn't have uint8_t depending on the OS version. */
    128 /* So we have this work around. */
    129 #ifdef OS390
    130 /* The features header is needed to get (u)int64_t sometimes. */
    131 #include <features.h>
    132 #if ! U_HAVE_INT8_T
    133 typedef signed char int8_t;
    134 #endif
    135 #if !defined(__uint8_t)
    136 #define __uint8_t 1
    137 typedef unsigned char uint8_t;
    138 #endif
    139 #endif /* OS390 */
    140 
    141 #include <inttypes.h>
    142 
    143 #else /* U_HAVE_INTTYPES_H */
    144 
    145 #if ! U_HAVE_INT8_T
    146 typedef signed char int8_t;
    147 #endif
    148 
    149 #if ! U_HAVE_UINT8_T
    150 typedef unsigned char uint8_t;
    151 #endif
    152 
    153 #if ! U_HAVE_INT16_T
    154 typedef signed short int16_t;
    155 #endif
    156 
    157 #if ! U_HAVE_UINT16_T
    158 typedef unsigned short uint16_t;
    159 #endif
    160 
    161 #if ! U_HAVE_INT32_T
    162 typedef signed int int32_t;
    163 #endif
    164 
    165 #if ! U_HAVE_UINT32_T
    166 typedef unsigned int uint32_t;
    167 #endif
    168 
    169 #if ! U_HAVE_INT64_T
    170     typedef signed long long int64_t;
    171 /* else we may not have a 64-bit type */
    172 #endif
    173 
    174 #if ! U_HAVE_UINT64_T
    175     typedef unsigned long long uint64_t;
    176 /* else we may not have a 64-bit type */
    177 #endif
    178 
    179 #endif
    180 
    181 /** @} */
    182 
    183 /*===========================================================================*/
    184 /** @{ Compiler and environment features                                         */
    185 /*===========================================================================*/
    186 
    187 /* Define whether namespace is supported */
    188 #ifndef U_HAVE_NAMESPACE
    189 #define U_HAVE_NAMESPACE 1
    190 #endif
    191 
    192 /* Determines the endianness of the platform
    193    It's done this way in case multiple architectures are being built at once.
    194    For example, Darwin supports fat binaries, which can be both PPC and x86 based. */
    195 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN)
    196 #define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
    197 #else
    198 #define U_IS_BIG_ENDIAN 0
    199 #endif
    200 
    201 /* 1 or 0 to enable or disable threads.  If undefined, default is: enable threads. */
    202 #define ICU_USE_THREADS 1
    203 
    204 /* On strong memory model CPUs (e.g. x86 CPUs), we use a safe & quick double check lock. */
    205 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
    206 #define UMTX_STRONG_MEMORY_MODEL 1
    207 #endif
    208 
    209 #ifndef U_DEBUG
    210 #define U_DEBUG 0
    211 #endif
    212 
    213 #ifndef U_RELEASE
    214 #define U_RELEASE 1
    215 #endif
    216 
    217 /* Determine whether to disable renaming or not. This overrides the
    218    setting in umachine.h which is for all platforms. */
    219 #ifndef U_DISABLE_RENAMING
    220 #define U_DISABLE_RENAMING 0
    221 #endif
    222 
    223 /* Determine whether to override new and delete. */
    224 #ifndef U_OVERRIDE_CXX_ALLOCATION
    225 #define U_OVERRIDE_CXX_ALLOCATION 1
    226 #endif
    227 /* Determine whether to override placement new and delete for STL. */
    228 #ifndef U_HAVE_PLACEMENT_NEW
    229 #define U_HAVE_PLACEMENT_NEW 1
    230 #endif
    231 
    232 /* Determine whether to enable tracing. */
    233 #ifndef U_ENABLE_TRACING
    234 #define U_ENABLE_TRACING 0
    235 #endif
    236 
    237 /* Do we allow ICU users to use the draft APIs by default? */
    238 #ifndef U_DEFAULT_SHOW_DRAFT
    239 #define U_DEFAULT_SHOW_DRAFT 1
    240 #endif
    241 
    242 /* Define the library suffix in a C syntax. */
    243 #define U_HAVE_LIB_SUFFIX 0
    244 #define U_LIB_SUFFIX_C_NAME
    245 #define U_LIB_SUFFIX_C_NAME_STRING ""
    246 
    247 /** @} */
    248 
    249 /*===========================================================================*/
    250 /** @{ Character data types                                                      */
    251 /*===========================================================================*/
    252 
    253 #if ((defined(OS390) && (!defined(__CHARSET_LIB) || !__CHARSET_LIB))) || defined(OS400)
    254 #   define U_CHARSET_FAMILY 1
    255 #endif
    256 
    257 /** @} */
    258 
    259 /*===========================================================================*/
    260 /** @{ Information about wchar support                                           */
    261 /*===========================================================================*/
    262 
    263 #ifndef U_HAVE_WCHAR_H
    264 #define U_HAVE_WCHAR_H      1
    265 #endif
    266 
    267 #ifndef U_SIZEOF_WCHAR_T
    268 #define U_SIZEOF_WCHAR_T    4
    269 #endif
    270 
    271 #ifndef U_HAVE_WCSCPY
    272 #define U_HAVE_WCSCPY       1
    273 #endif
    274 
    275 /** @} */
    276 
    277 /**
    278  * @{
    279  * \def U_DECLARE_UTF16
    280  * Do not use this macro. Use the UNICODE_STRING or U_STRING_DECL macros
    281  * instead.
    282  * @internal
    283  */
    284 #if 1 || defined(U_CHECK_UTF16_STRING)
    285 #if (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
    286     || (defined(__HP_aCC) && __HP_aCC >= 035000) \
    287     || (defined(__HP_cc) && __HP_cc >= 111106)
    288 #define U_DECLARE_UTF16(string) u ## string
    289 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550)
    290 /* || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x580) */
    291 /* Sun's C compiler has issues with this notation, and it's unreliable. */
    292 #define U_DECLARE_UTF16(string) U ## string
    293 #elif U_SIZEOF_WCHAR_T == 2 \
    294     && (U_CHARSET_FAMILY == 0 || ((defined(OS390) || defined(OS400)) && defined(__UCS2__)))
    295 #define U_DECLARE_UTF16(string) L ## string
    296 #endif
    297 #endif
    298 
    299 /** @} */
    300 
    301 /*===========================================================================*/
    302 /** @{ Information about POSIX support                                           */
    303 /*===========================================================================*/
    304 
    305 #ifndef U_HAVE_NL_LANGINFO_CODESET
    306 #define U_HAVE_NL_LANGINFO_CODESET  1
    307 #endif
    308 
    309 #ifndef U_NL_LANGINFO_CODESET
    310 #define U_NL_LANGINFO_CODESET       CODESET
    311 #endif
    312 
    313 #if 1
    314 #define U_TZSET         tzset
    315 #endif
    316 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
    317 #define U_TIMEZONE 0
    318 #else
    319 #define U_TIMEZONE timezone
    320 #endif
    321 #if 1
    322 #define U_TZNAME        tzname
    323 #endif
    324 
    325 #define U_HAVE_MMAP     1
    326 #define U_HAVE_POPEN    1
    327 
    328 /** @} */
    329 
    330 /*===========================================================================*/
    331 /** @{ Symbol import-export control                                              */
    332 /*===========================================================================*/
    333 
    334 #if 1
    335 /* Chrome-local change: on the Mac, ICU is exclusively used as a static
    336  * library, and nothing should ever be marked with default visibility.
    337  * Defining U_STATIC_IMPLEMENTATION handles most of this, but unfortunately
    338  * C functions declared with U_CAPI (defined in umachine.h) will still use
    339  * the definition of U_EXPORT. */
    340 #define U_EXPORT
    341 #elif 0
    342 #define U_EXPORT __attribute__((visibility("default")))
    343 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
    344    || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
    345 #define U_EXPORT __global
    346 /*#elif defined(__HP_aCC) || defined(__HP_cc)
    347 #define U_EXPORT __declspec(dllexport)*/
    348 #else
    349 #define U_EXPORT
    350 #endif
    351 
    352 /* U_CALLCONV is releated to U_EXPORT2 */
    353 #define U_EXPORT2
    354 
    355 /* cygwin needs to export/import data */
    356 #ifdef U_CYGWIN
    357 #define U_IMPORT __declspec(dllimport)
    358 #else
    359 #define U_IMPORT
    360 #endif
    361 
    362 /* @} */
    363 
    364 /*===========================================================================*/
    365 /** @{ Code alignment and C function inlining                                    */
    366 /*===========================================================================*/
    367 
    368 #ifndef U_INLINE
    369 #   ifdef __cplusplus
    370 #       define U_INLINE inline
    371 #   else
    372 #       define U_INLINE __inline__
    373 #   endif
    374 #endif
    375 
    376 #ifndef U_ALIGN_CODE
    377 #define U_ALIGN_CODE(n)
    378 #endif
    379 
    380 /** @} */
    381 
    382 /*===========================================================================*/
    383 /** @{ Programs used by ICU code                                                 */
    384 /*===========================================================================*/
    385 
    386 /**
    387  * \def U_MAKE
    388  * What program to execute to run 'make'
    389  */
    390 #ifndef U_MAKE
    391 #define U_MAKE  "/usr/bin/gnumake"
    392 #endif
    393 
    394 /** @} */
    395 
    396 /*===========================================================================*/
    397 /* Local defines                                                             */
    398 /*===========================================================================*/
    399 
    400 /* On the Mac, we define U_WCHAR_IS_UTF32 to treat wchar_t as though it
    401    contains UTF-32 at all times.  Strictly speaking, that's not entirely
    402    correct given the Mac's libc, but provided that we ignore libc's locale
    403    support (by not calling setlocale) and its multibyte string support, this
    404    should be fine.  Our codebase makes enough other assumptions about a UTF-8
    405    locale and UTF-32 wchar_t strings for this to make sense. */
    406 #define U_WCHAR_IS_UTF32
    407 
    408 #endif
    409