Home | History | Annotate | Download | only in unicode
      1 /*
      2 ******************************************************************************
      3 *
      4 *   Copyright (C) 1997-2007, 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 /**
     20  * \file
     21  * \brief Basic types for the platform
     22  */
     23 
     24 /* Define the platform we're on. */
     25 #ifndef U_BSD
     26 #define U_BSD
     27 #endif
     28 
     29 /* Define whether inttypes.h is available */
     30 #ifndef U_HAVE_INTTYPES_H
     31 #define U_HAVE_INTTYPES_H 1
     32 #endif
     33 
     34 /*
     35  * Define what support for C++ streams is available.
     36  *     If U_IOSTREAM_SOURCE is set to 199711, then <iostream> is available
     37  * (1997711 is the date the ISO/IEC C++ FDIS was published), and then
     38  * one should qualify streams using the std namespace in ICU header
     39  * files.
     40  *     If U_IOSTREAM_SOURCE is set to 198506, then <iostream.h> is
     41  * available instead (198506 is the date when Stroustrup published
     42  * "An Extensible I/O Facility for C++" at the summer USENIX conference).
     43  *     If U_IOSTREAM_SOURCE is 0, then C++ streams are not available and
     44  * support for them will be silently suppressed in ICU.
     45  *
     46  */
     47 
     48 #ifndef U_IOSTREAM_SOURCE
     49 #define U_IOSTREAM_SOURCE 199711
     50 #endif
     51 
     52 /* Determines whether specific types are available */
     53 #ifndef U_HAVE_INT8_T
     54 #define U_HAVE_INT8_T 1
     55 #endif
     56 
     57 #ifndef U_HAVE_UINT8_T
     58 #define U_HAVE_UINT8_T 1
     59 #endif
     60 
     61 #ifndef U_HAVE_INT16_T
     62 #define U_HAVE_INT16_T 1
     63 #endif
     64 
     65 #ifndef U_HAVE_UINT16_T
     66 #define U_HAVE_UINT16_T 1
     67 #endif
     68 
     69 #ifndef U_HAVE_INT32_T
     70 #define U_HAVE_INT32_T 1
     71 #endif
     72 
     73 #ifndef U_HAVE_UINT32_T
     74 #define U_HAVE_UINT32_T 1
     75 #endif
     76 
     77 #ifndef U_HAVE_INT64_T
     78 #define U_HAVE_INT64_T 1
     79 #endif
     80 
     81 #ifndef U_HAVE_UINT64_T
     82 #define U_HAVE_UINT64_T 1
     83 #endif
     84 
     85 /*===========================================================================*/
     86 /* Generic data types                                                        */
     87 /*===========================================================================*/
     88 
     89 #include <sys/types.h>
     90 
     91 /* If your platform does not have the <inttypes.h> header, you may
     92    need to edit the typedefs below. */
     93 #if U_HAVE_INTTYPES_H
     94 
     95 /* autoconf 2.13 sometimes can't properly find the data types in <inttypes.h> */
     96 /* os/390 needs <inttypes.h>, but it doesn't have int8_t, and it sometimes */
     97 /* doesn't have uint8_t depending on the OS version. */
     98 /* So we have this work around. */
     99 #ifdef OS390
    100 /* The features header is needed to get (u)int64_t sometimes. */
    101 #include <features.h>
    102 #if ! U_HAVE_INT8_T
    103 typedef signed char int8_t;
    104 #endif
    105 #if !defined(__uint8_t)
    106 #define __uint8_t 1
    107 typedef unsigned char uint8_t;
    108 #endif
    109 #endif /* OS390 */
    110 
    111 #include <inttypes.h>
    112 
    113 #else /* U_HAVE_INTTYPES_H */
    114 
    115 #if ! U_HAVE_INT8_T
    116 typedef signed char int8_t;
    117 #endif
    118 
    119 #if ! U_HAVE_UINT8_T
    120 typedef unsigned char uint8_t;
    121 #endif
    122 
    123 #if ! U_HAVE_INT16_T
    124 typedef signed short int16_t;
    125 #endif
    126 
    127 #if ! U_HAVE_UINT16_T
    128 typedef unsigned short uint16_t;
    129 #endif
    130 
    131 #if ! U_HAVE_INT32_T
    132 typedef signed int int32_t;
    133 #endif
    134 
    135 #if ! U_HAVE_UINT32_T
    136 typedef unsigned int uint32_t;
    137 #endif
    138 
    139 #if ! U_HAVE_INT64_T
    140     typedef signed long long int64_t;
    141 /* else we may not have a 64-bit type */
    142 #endif
    143 
    144 #if ! U_HAVE_UINT64_T
    145     typedef unsigned long long uint64_t;
    146 /* else we may not have a 64-bit type */
    147 #endif
    148 
    149 #endif
    150 
    151 /*===========================================================================*/
    152 /* Compiler and environment features                                         */
    153 /*===========================================================================*/
    154 
    155 /* Define whether namespace is supported */
    156 #ifndef U_HAVE_NAMESPACE
    157 #define U_HAVE_NAMESPACE 1
    158 #endif
    159 
    160 /* Determines the endianness of the platform
    161    It's done this way in case multiple architectures are being built at once.
    162    For example, Darwin supports fat binaries, which can be both PPC and x86 based. */
    163 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN)
    164 #define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
    165 #else
    166 #define U_IS_BIG_ENDIAN 0
    167 #endif
    168 
    169 /* 1 or 0 to enable or disable threads.  If undefined, default is: enable threads. */
    170 #define ICU_USE_THREADS 1
    171 
    172 /* On strong memory model CPUs (e.g. x86 CPUs), we use a safe & quick double check lock. */
    173 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
    174 #define UMTX_STRONG_MEMORY_MODEL 1
    175 #endif
    176 
    177 #ifndef U_DEBUG
    178 #define U_DEBUG 0
    179 #endif
    180 
    181 #ifndef U_RELEASE
    182 #define U_RELEASE 1
    183 #endif
    184 
    185 /* Determine whether to disable renaming or not. This overrides the
    186    setting in umachine.h which is for all platforms. */
    187 #ifndef U_DISABLE_RENAMING
    188 #define U_DISABLE_RENAMING 0
    189 #endif
    190 
    191 /* Determine whether to override new and delete. */
    192 #ifndef U_OVERRIDE_CXX_ALLOCATION
    193 #define U_OVERRIDE_CXX_ALLOCATION 1
    194 #endif
    195 /* Determine whether to override placement new and delete for STL. */
    196 #ifndef U_HAVE_PLACEMENT_NEW
    197 #define U_HAVE_PLACEMENT_NEW 1
    198 #endif
    199 
    200 /* Determine whether to enable tracing. */
    201 #ifndef U_ENABLE_TRACING
    202 #define U_ENABLE_TRACING 0
    203 #endif
    204 
    205 /* Do we allow ICU users to use the draft APIs by default? */
    206 #ifndef U_DEFAULT_SHOW_DRAFT
    207 #define U_DEFAULT_SHOW_DRAFT 1
    208 #endif
    209 
    210 /* Define the library suffix in a C syntax. */
    211 #define U_HAVE_LIB_SUFFIX 0
    212 #define U_LIB_SUFFIX_C_NAME
    213 #define U_LIB_SUFFIX_C_NAME_STRING ""
    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 /* Information about wchar support                                           */
    225 /*===========================================================================*/
    226 
    227 #define U_HAVE_WCHAR_H      1
    228 #define U_SIZEOF_WCHAR_T    4
    229 
    230 #define U_HAVE_WCSCPY       1
    231 
    232 /**
    233  * \def U_DECLARE_UTF16
    234  * Do not use this macro. Use the UNICODE_STRING or U_STRING_DECL macros
    235  * instead.
    236  * @internal
    237  */
    238 #if 1 || defined(U_CHECK_UTF16_STRING)
    239 #if (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
    240     || (defined(__HP_aCC) && __HP_aCC >= 035000) \
    241     || (defined(__HP_cc) && __HP_cc >= 111106)
    242 #define U_DECLARE_UTF16(string) u ## string
    243 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550)
    244 /* || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x580) */
    245 /* Sun's C compiler has issues with this notation, and it's unreliable. */
    246 #define U_DECLARE_UTF16(string) U ## string
    247 #elif U_SIZEOF_WCHAR_T == 2 \
    248     && (U_CHARSET_FAMILY == 0 || ((defined(OS390) || defined(OS400)) && defined(__UCS2__)))
    249 #define U_DECLARE_UTF16(string) L ## string
    250 #endif
    251 #endif
    252 
    253 /*===========================================================================*/
    254 /* Information about POSIX support                                           */
    255 /*===========================================================================*/
    256 
    257 #define U_HAVE_NL_LANGINFO_CODESET  1
    258 #define U_NL_LANGINFO_CODESET       CODESET
    259 
    260 #if 1
    261 #define U_TZSET         tzset
    262 #endif
    263 #if 0
    264 #define U_TIMEZONE
    265 #endif
    266 #if 1
    267 #define U_TZNAME        tzname
    268 #endif
    269 
    270 #define U_HAVE_MMAP     1
    271 #define U_HAVE_POPEN    1
    272 
    273 /*===========================================================================*/
    274 /* Symbol import-export control                                              */
    275 /*===========================================================================*/
    276 
    277 #if 1
    278 #define U_EXPORT __attribute__((visibility("default")))
    279 /*#elif defined(__HP_aCC) || defined(__HP_cc)
    280 #define U_EXPORT __declspec(dllexport)*/
    281 #else
    282 #define U_EXPORT
    283 #endif
    284 
    285 /* U_CALLCONV is releated to U_EXPORT2 */
    286 #define U_EXPORT2
    287 
    288 /* cygwin needs to export/import data */
    289 #ifdef U_CYGWIN
    290 #define U_IMPORT __declspec(dllimport)
    291 #else
    292 #define U_IMPORT
    293 #endif
    294 
    295 /*===========================================================================*/
    296 /* Code alignment and C function inlining                                    */
    297 /*===========================================================================*/
    298 
    299 #ifndef U_INLINE
    300 #   ifdef __cplusplus
    301 #       define U_INLINE inline
    302 #   else
    303 #       define U_INLINE inline
    304 #   endif
    305 #endif
    306 
    307 #define U_ALIGN_CODE(n)
    308 
    309 /*===========================================================================*/
    310 /* Programs used by ICU code                                                 */
    311 /*===========================================================================*/
    312 
    313 #define U_MAKE  "/usr/local/bin/gmake"
    314