os/textandloc/fontservices/textshaperplugin/IcuSource/common/unicode/umachine.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 ******************************************************************************
     3 *
     4 *   Copyright (C) 1999-2005, International Business Machines
     5 *   Corporation and others.  All Rights Reserved.
     6 *
     7 ******************************************************************************
     8 *   file name:  umachine.h
     9 *   encoding:   US-ASCII
    10 *   tab size:   8 (not used)
    11 *   indentation:4
    12 *
    13 *   created on: 1999sep13
    14 *   created by: Markus W. Scherer
    15 *
    16 *   This file defines basic types and constants for utf.h to be
    17 *   platform-independent. umachine.h and utf.h are included into
    18 *   utypes.h to provide all the general definitions for ICU.
    19 *   All of these definitions used to be in utypes.h before
    20 *   the UTF-handling macros made this unmaintainable.
    21 */
    22 
    23 #ifndef __UMACHINE_H__
    24 #define __UMACHINE_H__
    25 
    26 
    27 /**
    28  * \file
    29  * \brief Basic types and constants for UTF 
    30  * 
    31  * <h2> Basic types and constants for UTF </h2>
    32  *   This file defines basic types and constants for utf.h to be
    33  *   platform-independent. umachine.h and utf.h are included into
    34  *   utypes.h to provide all the general definitions for ICU.
    35  *   All of these definitions used to be in utypes.h before
    36  *   the UTF-handling macros made this unmaintainable.
    37  * 
    38  */
    39 /*==========================================================================*/
    40 /* Include platform-dependent definitions                                   */
    41 /* which are contained in the platform-specific file platform.h             */
    42 /*==========================================================================*/
    43 
    44 #if defined(__SYMBIAN32__)
    45 #include "SymbianPlatform.h"
    46 #elif defined(U_PALMOS)
    47 #   include "unicode/ppalmos.h"
    48 #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
    49 #   include "unicode/pwin32.h"
    50 #else
    51 #   include "unicode/platform.h"
    52 #endif
    53 
    54 /*
    55  * ANSI C headers:
    56  * stddef.h defines wchar_t
    57  */
    58 #include <stddef.h>
    59 
    60 /*==========================================================================*/
    61 /* XP_CPLUSPLUS is a cross-platform symbol which should be defined when     */
    62 /* using C++.  It should not be defined when compiling under C.             */
    63 /*==========================================================================*/
    64 
    65 #ifdef __cplusplus
    66 #   ifndef XP_CPLUSPLUS
    67 #       define XP_CPLUSPLUS
    68 #   endif
    69 #else
    70 #   undef XP_CPLUSPLUS
    71 #endif
    72 
    73 /*==========================================================================*/
    74 /* For C wrappers, we use the symbol U_STABLE.                                */
    75 /* This works properly if the includer is C or C++.                         */
    76 /* Functions are declared   U_STABLE return-type U_EXPORT2 function-name()... */
    77 /*==========================================================================*/
    78 
    79 /**
    80  * \def U_CFUNC
    81  * This is used in a declaration of a library private ICU C function.
    82  * @stable ICU 2.4
    83  */
    84 
    85 /**
    86  * \def U_CDECL_BEGIN
    87  * This is used to begin a declaration of a library private ICU C API.
    88  * @stable ICU 2.4
    89  */
    90 
    91 /**
    92  * \def U_CDECL_END
    93  * This is used to end a declaration of a library private ICU C API 
    94  * @stable ICU 2.4
    95  */
    96 
    97 #ifdef XP_CPLUSPLUS
    98 #   define U_CFUNC extern "C"
    99 #   define U_CDECL_BEGIN extern "C" {
   100 #   define U_CDECL_END   }
   101 #else
   102 #   define U_CFUNC extern
   103 #   define U_CDECL_BEGIN
   104 #   define U_CDECL_END
   105 #endif
   106 
   107 /**
   108  * \def U_NAMESPACE_BEGIN
   109  * This is used to begin a declaration of a public ICU C++ API.
   110  * If the compiler doesn't support namespaces, this does nothing.
   111  * @stable ICU 2.4
   112  */
   113 
   114 /**
   115  * \def U_NAMESPACE_END
   116  * This is used to end a declaration of a public ICU C++ API 
   117  * If the compiler doesn't support namespaces, this does nothing.
   118  * @stable ICU 2.4
   119  */
   120 
   121 /**
   122  * \def U_NAMESPACE_USE
   123  * This is used to specify that the rest of the code uses the
   124  * public ICU C++ API namespace.
   125  * If the compiler doesn't support namespaces, this does nothing.
   126  * @stable ICU 2.4
   127  */
   128 
   129 /**
   130  * \def U_NAMESPACE_QUALIFIER
   131  * This is used to qualify that a function or class is part of
   132  * the public ICU C++ API namespace.
   133  * If the compiler doesn't support namespaces, this does nothing.
   134  * @stable ICU 2.4
   135  */
   136 
   137 /* Define namespace symbols if the compiler supports it. */
   138 #if U_HAVE_NAMESPACE
   139 #   define U_NAMESPACE_BEGIN namespace U_ICU_NAMESPACE {
   140 #   define U_NAMESPACE_END  }
   141 #   define U_NAMESPACE_USE using namespace U_ICU_NAMESPACE;
   142 #   define U_NAMESPACE_QUALIFIER U_ICU_NAMESPACE::
   143 #else
   144 #   define U_NAMESPACE_BEGIN
   145 #   define U_NAMESPACE_END
   146 #   define U_NAMESPACE_USE
   147 #   define U_NAMESPACE_QUALIFIER
   148 #endif
   149 
   150 /** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
   151 #define U_CAPI U_CFUNC U_EXPORT
   152 #define U_STABLE U_CAPI
   153 #define U_DRAFT  U_CAPI
   154 #define U_DEPRECATED U_CAPI
   155 #define U_OBSOLETE U_CAPI
   156 #define U_INTERNAL U_CAPI
   157 
   158 /*==========================================================================*/
   159 /* limits for int32_t etc., like in POSIX inttypes.h                        */
   160 /*==========================================================================*/
   161 
   162 #ifndef INT8_MIN
   163 /** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */
   164 #   define INT8_MIN        ((int8_t)(-128))
   165 #endif
   166 #ifndef INT16_MIN
   167 /** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */
   168 #   define INT16_MIN       ((int16_t)(-32767-1))
   169 #endif
   170 #ifndef INT32_MIN
   171 /** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */
   172 #   define INT32_MIN       ((int32_t)(-2147483647-1))
   173 #endif
   174 
   175 #ifndef INT8_MAX
   176 /** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */
   177 #   define INT8_MAX        ((int8_t)(127))
   178 #endif
   179 #ifndef INT16_MAX
   180 /** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */
   181 #   define INT16_MAX       ((int16_t)(32767))
   182 #endif
   183 #ifndef INT32_MAX
   184 /** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */
   185 #   define INT32_MAX       ((int32_t)(2147483647))
   186 #endif
   187 
   188 #ifndef UINT8_MAX
   189 /** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */
   190 #   define UINT8_MAX       ((uint8_t)(255U))
   191 #endif
   192 #ifndef UINT16_MAX
   193 /** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */
   194 #   define UINT16_MAX      ((uint16_t)(65535U))
   195 #endif
   196 #ifndef UINT32_MAX
   197 /** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */
   198 #   define UINT32_MAX      ((uint32_t)(4294967295U))
   199 #endif
   200 
   201 #if defined(U_INT64_T_UNAVAILABLE)
   202 # error int64_t is required for decimal format and rule-based number format.
   203 #else
   204 # ifndef INT64_C
   205 /**
   206  * Provides a platform independent way to specify a signed 64-bit integer constant.
   207  * note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C
   208  * @stable ICU 2.8
   209  */
   210 #   define INT64_C(c) c ## LL
   211 # endif
   212 # ifndef UINT64_C
   213 /**
   214  * Provides a platform independent way to specify an unsigned 64-bit integer constant.
   215  * note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C
   216  * @stable ICU 2.8
   217  */
   218 #   define UINT64_C(c) c ## ULL
   219 # endif
   220 # ifndef U_INT64_MIN
   221 /** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */
   222 #     define U_INT64_MIN       ((int64_t)(INT64_C(-9223372036854775807)-1))
   223 # endif
   224 # ifndef U_INT64_MAX
   225 /** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */
   226 #     define U_INT64_MAX       ((int64_t)(INT64_C(9223372036854775807)))
   227 # endif
   228 # ifndef U_UINT64_MAX
   229 /** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */
   230 #     define U_UINT64_MAX      ((uint64_t)(UINT64_C(18446744073709551615)))
   231 # endif
   232 #endif
   233 
   234 /*==========================================================================*/
   235 /* Boolean data type                                                        */
   236 /*==========================================================================*/
   237 
   238 /** The ICU boolean type @stable ICU 2.0 */
   239 typedef int8_t UBool;
   240 
   241 #ifndef TRUE
   242 /** The TRUE value of a UBool @stable ICU 2.0 */
   243 #   define TRUE  1
   244 #endif
   245 #ifndef FALSE
   246 /** The FALSE value of a UBool @stable ICU 2.0 */
   247 #   define FALSE 0
   248 #endif
   249 
   250 
   251 /*==========================================================================*/
   252 /* Unicode data types                                                       */
   253 /*==========================================================================*/
   254 
   255 /* wchar_t-related definitions -------------------------------------------- */
   256 
   257 /**
   258  * \def U_HAVE_WCHAR_H
   259  * Indicates whether <wchar.h> is available (1) or not (0). Set to 1 by default.
   260  *
   261  * @stable ICU 2.0
   262  */
   263 #ifndef U_HAVE_WCHAR_H
   264 #   define U_HAVE_WCHAR_H 1
   265 #endif
   266 
   267 /**
   268  * \def U_SIZEOF_WCHAR_T
   269  * U_SIZEOF_WCHAR_T==sizeof(wchar_t) (0 means it is not defined or autoconf could not set it)
   270  *
   271  * @stable ICU 2.0
   272  */
   273 #if U_SIZEOF_WCHAR_T==0
   274 #   undef U_SIZEOF_WCHAR_T
   275 #   define U_SIZEOF_WCHAR_T 4
   276 #endif
   277 
   278 /*
   279  * \def U_WCHAR_IS_UTF16
   280  * Defined if wchar_t uses UTF-16.
   281  *
   282  * @stable ICU 2.0
   283  */
   284 /*
   285  * \def U_WCHAR_IS_UTF32
   286  * Defined if wchar_t uses UTF-32.
   287  *
   288  * @stable ICU 2.0
   289  */
   290 #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
   291 #   ifdef __STDC_ISO_10646__ 
   292 #       if (U_SIZEOF_WCHAR_T==2)
   293 #           define U_WCHAR_IS_UTF16
   294 #       elif (U_SIZEOF_WCHAR_T==4)
   295 #           define  U_WCHAR_IS_UTF32
   296 #       endif
   297 #   elif defined __UCS2__
   298 #       if (__OS390__ || __OS400__) && (U_SIZEOF_WCHAR_T==2)
   299 #           define U_WCHAR_IS_UTF16
   300 #       endif
   301 #   elif defined __UCS4__
   302 #       if (U_SIZEOF_WCHAR_T==4)
   303 #           define U_WCHAR_IS_UTF32
   304 #       endif
   305 #   elif defined(U_WINDOWS)
   306 #       define U_WCHAR_IS_UTF16    
   307 #   endif
   308 #endif
   309 
   310 /* UChar and UChar32 definitions -------------------------------------------- */
   311 
   312 /** Number of bytes in a UChar. @stable ICU 2.0 */
   313 #define U_SIZEOF_UCHAR 2
   314 
   315 /**
   316  * \var UChar
   317  * Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
   318  * If wchar_t is not 16 bits wide, then define UChar to be uint16_t.
   319  * This makes the definition of UChar platform-dependent
   320  * but allows direct string type compatibility with platforms with
   321  * 16-bit wchar_t types.
   322  *
   323  * @stable ICU 2.0
   324  */
   325 
   326 /* Define UChar to be compatible with wchar_t if possible. */
   327 #if U_SIZEOF_WCHAR_T==2
   328     typedef wchar_t UChar;
   329 #else
   330     typedef uint16_t UChar;
   331 #endif
   332 
   333 /**
   334  * Define UChar32 as a type for single Unicode code points.
   335  * UChar32 is a signed 32-bit integer (same as int32_t).
   336  *
   337  * The Unicode code point range is 0..0x10ffff.
   338  * All other values (negative or >=0x110000) are illegal as Unicode code points.
   339  * They may be used as sentinel values to indicate "done", "error"
   340  * or similar non-code point conditions.
   341  *
   342  * Before ICU 2.4 (Jitterbug 2146), UChar32 was defined
   343  * to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned)
   344  * or else to be uint32_t.
   345  * That is, the definition of UChar32 was platform-dependent.
   346  *
   347  * @see U_SENTINEL
   348  * @stable ICU 2.4
   349  */
   350 typedef int32_t UChar32;
   351 
   352 /*==========================================================================*/
   353 /* U_INLINE and U_ALIGN_CODE   Set default values if these are not already  */
   354 /*                             defined.  Definitions normally are in        */
   355 /*                             platform.h or the corresponding file for     */
   356 /*                             the OS in use.                               */
   357 /*==========================================================================*/
   358 
   359 /**
   360  * \def U_ALIGN_CODE
   361  * This is used to align code fragments to a specific byte boundary.
   362  * This is useful for getting consistent performance test results.
   363  * @internal
   364  */
   365 #ifndef U_ALIGN_CODE
   366 #   define U_ALIGN_CODE(n)
   367 #endif
   368 
   369 #ifndef U_INLINE
   370 #   ifdef XP_CPLUSPLUS
   371 #       define U_INLINE inline
   372 #   else
   373 #       define U_INLINE
   374 #   endif
   375 #endif
   376 
   377 #include "unicode/urename.h"
   378 
   379 #endif