Home | History | Annotate | Download | only in unicode
      1 /*
      2 ******************************************************************************
      3 *
      4 *   Copyright (C) 1997-2010, International Business Machines
      5 *   Corporation and others.  All Rights Reserved.
      6 *
      7 ******************************************************************************
      8 *
      9 * Note: autoconf creates platform.h from platform.h.in at configure time.
     10 *
     11 ******************************************************************************
     12 *
     13 *  FILE NAME : platform.h
     14 *
     15 *   Date        Name        Description
     16 *   05/13/98    nos         Creation (content moved here from ptypes.h).
     17 *   03/02/99    stephen     Added AS400 support.
     18 *   03/30/99    stephen     Added Linux support.
     19 *   04/13/99    stephen     Reworked for autoconf.
     20 ******************************************************************************
     21 */
     22 
     23 #ifndef _PLATFORM_H
     24 #define _PLATFORM_H
     25 
     26 /**
     27  * \file
     28  * \brief Basic types for the platform
     29  */
     30 
     31 /* This file should be included before uvernum.h. */
     32 #if defined(UVERNUM_H)
     33 # error Do not include unicode/uvernum.h before #including unicode/platform.h.  Instead of unicode/uvernum.h, #include unicode/uversion.h
     34 #endif
     35 
     36 /**
     37  * Determine wheter to enable auto cleanup of libraries.
     38  * @internal
     39  */
     40 #ifndef UCLN_NO_AUTO_CLEANUP
     41 #define UCLN_NO_AUTO_CLEANUP 1
     42 #endif
     43 
     44 /* Need platform.h when using CYGWINMSVC to get definitions above. Ignore everything else. */
     45 #ifndef CYGWINMSVC
     46 
     47 /** Define the platform we're on. */
     48 #ifndef U_LINUX
     49 #define U_LINUX
     50 #endif
     51 
     52 /**
     53  * \def U_HAVE_DIRENT_H
     54  * Define whether dirent.h is available
     55  * @internal
     56  */
     57 #ifndef U_HAVE_DIRENT_H
     58 #define U_HAVE_DIRENT_H 1
     59 #endif
     60 
     61 /** Define whether inttypes.h is available */
     62 #ifndef U_HAVE_INTTYPES_H
     63 #define U_HAVE_INTTYPES_H 1
     64 #endif
     65 
     66 /**
     67  * Define what support for C++ streams is available.
     68  *     If U_IOSTREAM_SOURCE is set to 199711, then <iostream> is available
     69  * (1997711 is the date the ISO/IEC C++ FDIS was published), and then
     70  * one should qualify streams using the std namespace in ICU header
     71  * files.
     72  *     If U_IOSTREAM_SOURCE is set to 198506, then <iostream.h> is
     73  * available instead (198506 is the date when Stroustrup published
     74  * "An Extensible I/O Facility for C++" at the summer USENIX conference).
     75  *     If U_IOSTREAM_SOURCE is 0, then C++ streams are not available and
     76  * support for them will be silently suppressed in ICU.
     77  *
     78  */
     79 
     80 #ifndef U_IOSTREAM_SOURCE
     81 #define U_IOSTREAM_SOURCE 199711
     82 #endif
     83 
     84 /**
     85  * \def U_HAVE_STD_STRING
     86  * Define whether the standard C++ (STL) <string> header is available.
     87  * For platforms that do not use platform.h and do not define this constant
     88  * in their platform-specific headers, std_string.h defaults
     89  * U_HAVE_STD_STRING to 1.
     90  * @internal
     91  */
     92 #ifdef HAVE_ANDROID_OS
     93 #define U_HAVE_STD_STRING 0
     94 #else
     95 #ifndef U_HAVE_STD_STRING
     96 #define U_HAVE_STD_STRING 1
     97 #endif
     98 #endif
     99 
    100 /** @{ Determines whether specific types are available */
    101 #ifndef U_HAVE_INT8_T
    102 #define U_HAVE_INT8_T 1
    103 #endif
    104 
    105 #ifndef U_HAVE_UINT8_T
    106 #define U_HAVE_UINT8_T 1
    107 #endif
    108 
    109 #ifndef U_HAVE_INT16_T
    110 #define U_HAVE_INT16_T 1
    111 #endif
    112 
    113 #ifndef U_HAVE_UINT16_T
    114 #define U_HAVE_UINT16_T 1
    115 #endif
    116 
    117 #ifndef U_HAVE_INT32_T
    118 #define U_HAVE_INT32_T 1
    119 #endif
    120 
    121 #ifndef U_HAVE_UINT32_T
    122 #define U_HAVE_UINT32_T 1
    123 #endif
    124 
    125 #ifndef U_HAVE_INT64_T
    126 #define U_HAVE_INT64_T 1
    127 #endif
    128 
    129 #ifndef U_HAVE_UINT64_T
    130 #define U_HAVE_UINT64_T 1
    131 #endif
    132 
    133 /** @} */
    134 
    135 /*===========================================================================*/
    136 /** @{ Compiler and environment features                                     */
    137 /*===========================================================================*/
    138 
    139 /* Define whether namespace is supported */
    140 #ifndef U_HAVE_NAMESPACE
    141 #define U_HAVE_NAMESPACE 1
    142 #endif
    143 
    144 /* Determines the endianness of the platform
    145    It's done this way in case multiple architectures are being built at once.
    146    For example, Darwin supports fat binaries, which can be both PPC and x86 based. */
    147 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN)
    148 #define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
    149 #else
    150 #define U_IS_BIG_ENDIAN 0
    151 #endif
    152 
    153 /* 1 or 0 to enable or disable threads.  If undefined, default is: enable threads. */
    154 #ifndef ICU_USE_THREADS
    155 #define ICU_USE_THREADS 1
    156 #endif
    157 
    158 /* On strong memory model CPUs (e.g. x86 CPUs), we use a safe & quick double check lock. */
    159 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
    160 #define UMTX_STRONG_MEMORY_MODEL 1
    161 #endif
    162 
    163 #ifndef U_DEBUG
    164 #define U_DEBUG 1
    165 #endif
    166 
    167 #ifndef U_RELEASE
    168 #define U_RELEASE 0
    169 #endif
    170 
    171 /* Determine whether to disable renaming or not. This overrides the
    172    setting in umachine.h which is for all platforms. */
    173 #ifndef U_DISABLE_RENAMING
    174 #define U_DISABLE_RENAMING 0
    175 #endif
    176 
    177 /* Determine whether to override new and delete. */
    178 #ifndef U_OVERRIDE_CXX_ALLOCATION
    179 #define U_OVERRIDE_CXX_ALLOCATION 1
    180 #endif
    181 /* Determine whether to override placement new and delete for STL. */
    182 #ifndef U_HAVE_PLACEMENT_NEW
    183 #define U_HAVE_PLACEMENT_NEW 1
    184 #endif
    185 
    186 /* Determine whether to enable tracing. */
    187 #ifndef U_ENABLE_TRACING
    188 #define U_ENABLE_TRACING 0
    189 #endif
    190 
    191 /**
    192  * Whether to enable Dynamic loading in ICU
    193  * @internal
    194  */
    195 #ifndef U_ENABLE_DYLOAD
    196 #define U_ENABLE_DYLOAD 1
    197 #endif
    198 
    199 /**
    200  * Whether to test Dynamic loading as an OS capabilty
    201  * @internal
    202  */
    203 #ifndef U_CHECK_DYLOAD
    204 #define U_CHECK_DYLOAD 1
    205 #endif
    206 
    207 
    208 /** Do we allow ICU users to use the draft APIs by default? */
    209 #ifndef U_DEFAULT_SHOW_DRAFT
    210 #define U_DEFAULT_SHOW_DRAFT 1
    211 #endif
    212 
    213 /** @} */
    214 
    215 /*===========================================================================*/
    216 /** @{ Character data types                                                      */
    217 /*===========================================================================*/
    218 
    219 #if ((defined(OS390) && (!defined(__CHARSET_LIB) || !__CHARSET_LIB))) || defined(OS400)
    220 #   define U_CHARSET_FAMILY 1
    221 #endif
    222 
    223 /** @} */
    224 
    225 /*===========================================================================*/
    226 /** @{ Information about wchar support                                           */
    227 /*===========================================================================*/
    228 // BEGIN android-note
    229 // We changed "ARM_FLAG" to "HAVE_ANDROID_OS" immediately below.
    230 // Consensus seems to be that the intent of ARM_FLAG is actually that
    231 // it represent whether we are compiling for Android, and if that's
    232 // the case then we might as well use the standard definition instead.
    233 // END android-note
    234 #ifdef HAVE_ANDROID_OS
    235 #define U_HAVE_WCHAR_H      0
    236 #define U_SIZEOF_WCHAR_T    1
    237 
    238 #define U_HAVE_WCSCPY       0
    239 
    240 #else
    241 
    242 #ifndef U_HAVE_WCHAR_H
    243 #define U_HAVE_WCHAR_H      1
    244 #endif
    245 
    246 #ifndef U_SIZEOF_WCHAR_T
    247 #define U_SIZEOF_WCHAR_T    4
    248 #endif
    249 
    250 #ifndef U_HAVE_WCSCPY
    251 #define U_HAVE_WCSCPY       1
    252 #endif
    253 
    254 #endif
    255 
    256 /** @} */
    257 
    258 /**
    259  * @{
    260  * \def U_DECLARE_UTF16
    261  * Do not use this macro. Use the UNICODE_STRING or U_STRING_DECL macros
    262  * instead.
    263  * @internal
    264  *
    265  * \def U_GNUC_UTF16_STRING
    266  * @internal
    267  */
    268 #ifndef U_GNUC_UTF16_STRING
    269 #define U_GNUC_UTF16_STRING 0
    270 #endif
    271 #if 1 || defined(U_CHECK_UTF16_STRING)
    272 #if (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
    273     || (defined(__HP_aCC) && __HP_aCC >= 035000) \
    274     || (defined(__HP_cc) && __HP_cc >= 111106) \
    275     || U_GNUC_UTF16_STRING
    276 #define U_DECLARE_UTF16(string) u ## string
    277 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550)
    278 /* || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x580) */
    279 /* Sun's C compiler has issues with this notation, and it's unreliable. */
    280 #define U_DECLARE_UTF16(string) U ## string
    281 #elif U_SIZEOF_WCHAR_T == 2 \
    282     && (U_CHARSET_FAMILY == 0 || ((defined(OS390) || defined(OS400)) && defined(__UCS2__)))
    283 #define U_DECLARE_UTF16(string) L ## string
    284 #endif
    285 #endif
    286 
    287 /** @} */
    288 
    289 /*===========================================================================*/
    290 /** @{ Information about POSIX support                                           */
    291 /*===========================================================================*/
    292 
    293 // BEGIN android-note
    294 // See Android comment above.
    295 // END android-note
    296 #if !HAVE_ANDROID_OS
    297 #define U_HAVE_NL_LANGINFO          1
    298 
    299 #ifndef U_HAVE_NL_LANGINFO_CODESET
    300 #define U_HAVE_NL_LANGINFO_CODESET  1
    301 #endif
    302 
    303 #endif
    304 
    305 #ifndef U_NL_LANGINFO_CODESET
    306 #define U_NL_LANGINFO_CODESET       CODESET
    307 #endif
    308 
    309 #if !HAVE_ANDROID_OS
    310 #if 1
    311 #define U_TZSET         tzset
    312 #endif
    313 #if 1
    314 #define U_TIMEZONE      __timezone
    315 #endif
    316 #if 1
    317 #define U_TZNAME        tzname
    318 #endif
    319 #endif
    320 
    321 #define U_HAVE_MMAP     1
    322 #define U_HAVE_POPEN    1
    323 
    324 /** @} */
    325 
    326 /*===========================================================================*/
    327 /** @{ Symbol import-export control                                              */
    328 /*===========================================================================*/
    329 
    330 #if 1
    331 #define U_EXPORT __attribute__((visibility("default")))
    332 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
    333    || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
    334 #define U_EXPORT __global
    335 /*#elif defined(__HP_aCC) || defined(__HP_cc)
    336 #define U_EXPORT __declspec(dllexport)*/
    337 #else
    338 #define U_EXPORT
    339 #endif
    340 
    341 /* U_CALLCONV is releated to U_EXPORT2 */
    342 #define U_EXPORT2
    343 
    344 /* cygwin needs to export/import data */
    345 #if defined(U_CYGWIN) && !defined(__GNUC__)
    346 #define U_IMPORT __declspec(dllimport)
    347 #else
    348 #define U_IMPORT
    349 #endif
    350 
    351 /* @} */
    352 
    353 /*===========================================================================*/
    354 /** @{ Code alignment and C function inlining                                    */
    355 /*===========================================================================*/
    356 
    357 #ifndef U_INLINE
    358 #   ifdef __cplusplus
    359 #       define U_INLINE inline
    360 #   else
    361 #       define U_INLINE __inline__
    362 #   endif
    363 #endif
    364 
    365 #ifndef U_ALIGN_CODE
    366 #define U_ALIGN_CODE(n)
    367 #endif
    368 
    369 /** @} */
    370 
    371 /*===========================================================================*/
    372 /** @{ GCC built in functions for atomic memory operations                       */
    373 /*===========================================================================*/
    374 
    375 // BEGIN android-added
    376 #if !defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)
    377 #define U_HAVE_GCC_ATOMICS 0
    378 #endif
    379 // END android-added
    380 
    381 /**
    382  * \def U_HAVE_GCC_ATOMICS
    383  * @internal
    384  */
    385 #ifndef U_HAVE_GCC_ATOMICS
    386 #define U_HAVE_GCC_ATOMICS 1
    387 #endif
    388 
    389 /** @} */
    390 
    391 /*===========================================================================*/
    392 /** @{ Programs used by ICU code                                                 */
    393 /*===========================================================================*/
    394 
    395 /**
    396  * \def U_MAKE
    397  * What program to execute to run 'make'
    398  */
    399 #ifndef U_MAKE
    400 #define U_MAKE  "make"
    401 #endif
    402 
    403 /** @} */
    404 
    405 #endif /* CYGWINMSVC */
    406 
    407 /*===========================================================================*/
    408 /* Custom icu entry point renaming                                                  */
    409 /*===========================================================================*/
    410 
    411 /**
    412  * Define the library suffix with C syntax.
    413  * @internal
    414  */
    415 # define U_LIB_SUFFIX_C_NAME
    416 /**
    417  * Define the library suffix as a string with C syntax
    418  * @internal
    419  */
    420 # define U_LIB_SUFFIX_C_NAME_STRING ""
    421 /**
    422  * 1 if a custom library suffix is set
    423  * @internal
    424  */
    425 # define U_HAVE_LIB_SUFFIX 0
    426 
    427 #if U_HAVE_LIB_SUFFIX
    428 # ifndef U_ICU_ENTRY_POINT_RENAME
    429 /* Renaming pattern:    u_strcpy_41_suffix */
    430 #  define U_ICU_ENTRY_POINT_RENAME(x)    x ## _ ## 46 ##
    431 #  define U_DEF_ICUDATA_ENTRY_POINT(major, minor) icudt####major##minor##_dat
    432 
    433 # endif
    434 #endif
    435 
    436 #endif
    437