intl/icu/source/common/unicode/umachine.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 ******************************************************************************
michael@0 3 *
michael@0 4 * Copyright (C) 1999-2012, International Business Machines
michael@0 5 * Corporation and others. All Rights Reserved.
michael@0 6 *
michael@0 7 ******************************************************************************
michael@0 8 * file name: umachine.h
michael@0 9 * encoding: US-ASCII
michael@0 10 * tab size: 8 (not used)
michael@0 11 * indentation:4
michael@0 12 *
michael@0 13 * created on: 1999sep13
michael@0 14 * created by: Markus W. Scherer
michael@0 15 *
michael@0 16 * This file defines basic types and constants for utf.h to be
michael@0 17 * platform-independent. umachine.h and utf.h are included into
michael@0 18 * utypes.h to provide all the general definitions for ICU.
michael@0 19 * All of these definitions used to be in utypes.h before
michael@0 20 * the UTF-handling macros made this unmaintainable.
michael@0 21 */
michael@0 22
michael@0 23 #ifndef __UMACHINE_H__
michael@0 24 #define __UMACHINE_H__
michael@0 25
michael@0 26
michael@0 27 /**
michael@0 28 * \file
michael@0 29 * \brief Basic types and constants for UTF
michael@0 30 *
michael@0 31 * <h2> Basic types and constants for UTF </h2>
michael@0 32 * This file defines basic types and constants for utf.h to be
michael@0 33 * platform-independent. umachine.h and utf.h are included into
michael@0 34 * utypes.h to provide all the general definitions for ICU.
michael@0 35 * All of these definitions used to be in utypes.h before
michael@0 36 * the UTF-handling macros made this unmaintainable.
michael@0 37 *
michael@0 38 */
michael@0 39 /*==========================================================================*/
michael@0 40 /* Include platform-dependent definitions */
michael@0 41 /* which are contained in the platform-specific file platform.h */
michael@0 42 /*==========================================================================*/
michael@0 43
michael@0 44 #include "unicode/ptypes.h" /* platform.h is included in ptypes.h */
michael@0 45
michael@0 46 /*
michael@0 47 * ANSI C headers:
michael@0 48 * stddef.h defines wchar_t
michael@0 49 */
michael@0 50 #include <stddef.h>
michael@0 51
michael@0 52 /*==========================================================================*/
michael@0 53 /* For C wrappers, we use the symbol U_STABLE. */
michael@0 54 /* This works properly if the includer is C or C++. */
michael@0 55 /* Functions are declared U_STABLE return-type U_EXPORT2 function-name()... */
michael@0 56 /*==========================================================================*/
michael@0 57
michael@0 58 /**
michael@0 59 * \def U_CFUNC
michael@0 60 * This is used in a declaration of a library private ICU C function.
michael@0 61 * @stable ICU 2.4
michael@0 62 */
michael@0 63
michael@0 64 /**
michael@0 65 * \def U_CDECL_BEGIN
michael@0 66 * This is used to begin a declaration of a library private ICU C API.
michael@0 67 * @stable ICU 2.4
michael@0 68 */
michael@0 69
michael@0 70 /**
michael@0 71 * \def U_CDECL_END
michael@0 72 * This is used to end a declaration of a library private ICU C API
michael@0 73 * @stable ICU 2.4
michael@0 74 */
michael@0 75
michael@0 76 #ifdef __cplusplus
michael@0 77 # define U_CFUNC extern "C"
michael@0 78 # define U_CDECL_BEGIN extern "C" {
michael@0 79 # define U_CDECL_END }
michael@0 80 #else
michael@0 81 # define U_CFUNC extern
michael@0 82 # define U_CDECL_BEGIN
michael@0 83 # define U_CDECL_END
michael@0 84 #endif
michael@0 85
michael@0 86 #ifndef U_ATTRIBUTE_DEPRECATED
michael@0 87 /**
michael@0 88 * \def U_ATTRIBUTE_DEPRECATED
michael@0 89 * This is used for GCC specific attributes
michael@0 90 * @internal
michael@0 91 */
michael@0 92 #if U_GCC_MAJOR_MINOR >= 302
michael@0 93 # define U_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))
michael@0 94 /**
michael@0 95 * \def U_ATTRIBUTE_DEPRECATED
michael@0 96 * This is used for Visual C++ specific attributes
michael@0 97 * @internal
michael@0 98 */
michael@0 99 #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
michael@0 100 # define U_ATTRIBUTE_DEPRECATED __declspec(deprecated)
michael@0 101 #else
michael@0 102 # define U_ATTRIBUTE_DEPRECATED
michael@0 103 #endif
michael@0 104 #endif
michael@0 105
michael@0 106 /** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
michael@0 107 #define U_CAPI U_CFUNC U_EXPORT
michael@0 108 /** This is used to declare a function as a stable public ICU C API*/
michael@0 109 #define U_STABLE U_CAPI
michael@0 110 /** This is used to declare a function as a draft public ICU C API */
michael@0 111 #define U_DRAFT U_CAPI
michael@0 112 /** This is used to declare a function as a deprecated public ICU C API */
michael@0 113 #define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED
michael@0 114 /** This is used to declare a function as an obsolete public ICU C API */
michael@0 115 #define U_OBSOLETE U_CAPI
michael@0 116 /** This is used to declare a function as an internal ICU C API */
michael@0 117 #define U_INTERNAL U_CAPI
michael@0 118
michael@0 119 /*==========================================================================*/
michael@0 120 /* limits for int32_t etc., like in POSIX inttypes.h */
michael@0 121 /*==========================================================================*/
michael@0 122
michael@0 123 #ifndef INT8_MIN
michael@0 124 /** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */
michael@0 125 # define INT8_MIN ((int8_t)(-128))
michael@0 126 #endif
michael@0 127 #ifndef INT16_MIN
michael@0 128 /** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */
michael@0 129 # define INT16_MIN ((int16_t)(-32767-1))
michael@0 130 #endif
michael@0 131 #ifndef INT32_MIN
michael@0 132 /** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */
michael@0 133 # define INT32_MIN ((int32_t)(-2147483647-1))
michael@0 134 #endif
michael@0 135
michael@0 136 #ifndef INT8_MAX
michael@0 137 /** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */
michael@0 138 # define INT8_MAX ((int8_t)(127))
michael@0 139 #endif
michael@0 140 #ifndef INT16_MAX
michael@0 141 /** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */
michael@0 142 # define INT16_MAX ((int16_t)(32767))
michael@0 143 #endif
michael@0 144 #ifndef INT32_MAX
michael@0 145 /** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */
michael@0 146 # define INT32_MAX ((int32_t)(2147483647))
michael@0 147 #endif
michael@0 148
michael@0 149 #ifndef UINT8_MAX
michael@0 150 /** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */
michael@0 151 # define UINT8_MAX ((uint8_t)(255U))
michael@0 152 #endif
michael@0 153 #ifndef UINT16_MAX
michael@0 154 /** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */
michael@0 155 # define UINT16_MAX ((uint16_t)(65535U))
michael@0 156 #endif
michael@0 157 #ifndef UINT32_MAX
michael@0 158 /** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */
michael@0 159 # define UINT32_MAX ((uint32_t)(4294967295U))
michael@0 160 #endif
michael@0 161
michael@0 162 #if defined(U_INT64_T_UNAVAILABLE)
michael@0 163 # error int64_t is required for decimal format and rule-based number format.
michael@0 164 #else
michael@0 165 # ifndef INT64_C
michael@0 166 /**
michael@0 167 * Provides a platform independent way to specify a signed 64-bit integer constant.
michael@0 168 * note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C
michael@0 169 * @stable ICU 2.8
michael@0 170 */
michael@0 171 # define INT64_C(c) c ## LL
michael@0 172 # endif
michael@0 173 # ifndef UINT64_C
michael@0 174 /**
michael@0 175 * Provides a platform independent way to specify an unsigned 64-bit integer constant.
michael@0 176 * note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C
michael@0 177 * @stable ICU 2.8
michael@0 178 */
michael@0 179 # define UINT64_C(c) c ## ULL
michael@0 180 # endif
michael@0 181 # ifndef U_INT64_MIN
michael@0 182 /** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */
michael@0 183 # define U_INT64_MIN ((int64_t)(INT64_C(-9223372036854775807)-1))
michael@0 184 # endif
michael@0 185 # ifndef U_INT64_MAX
michael@0 186 /** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */
michael@0 187 # define U_INT64_MAX ((int64_t)(INT64_C(9223372036854775807)))
michael@0 188 # endif
michael@0 189 # ifndef U_UINT64_MAX
michael@0 190 /** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */
michael@0 191 # define U_UINT64_MAX ((uint64_t)(UINT64_C(18446744073709551615)))
michael@0 192 # endif
michael@0 193 #endif
michael@0 194
michael@0 195 /*==========================================================================*/
michael@0 196 /* Boolean data type */
michael@0 197 /*==========================================================================*/
michael@0 198
michael@0 199 /** The ICU boolean type @stable ICU 2.0 */
michael@0 200 typedef int8_t UBool;
michael@0 201
michael@0 202 #ifndef TRUE
michael@0 203 /** The TRUE value of a UBool @stable ICU 2.0 */
michael@0 204 # define TRUE 1
michael@0 205 #endif
michael@0 206 #ifndef FALSE
michael@0 207 /** The FALSE value of a UBool @stable ICU 2.0 */
michael@0 208 # define FALSE 0
michael@0 209 #endif
michael@0 210
michael@0 211
michael@0 212 /*==========================================================================*/
michael@0 213 /* Unicode data types */
michael@0 214 /*==========================================================================*/
michael@0 215
michael@0 216 /* wchar_t-related definitions -------------------------------------------- */
michael@0 217
michael@0 218 /*
michael@0 219 * \def U_WCHAR_IS_UTF16
michael@0 220 * Defined if wchar_t uses UTF-16.
michael@0 221 *
michael@0 222 * @stable ICU 2.0
michael@0 223 */
michael@0 224 /*
michael@0 225 * \def U_WCHAR_IS_UTF32
michael@0 226 * Defined if wchar_t uses UTF-32.
michael@0 227 *
michael@0 228 * @stable ICU 2.0
michael@0 229 */
michael@0 230 #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
michael@0 231 # ifdef __STDC_ISO_10646__
michael@0 232 # if (U_SIZEOF_WCHAR_T==2)
michael@0 233 # define U_WCHAR_IS_UTF16
michael@0 234 # elif (U_SIZEOF_WCHAR_T==4)
michael@0 235 # define U_WCHAR_IS_UTF32
michael@0 236 # endif
michael@0 237 # elif defined __UCS2__
michael@0 238 # if (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400) && (U_SIZEOF_WCHAR_T==2)
michael@0 239 # define U_WCHAR_IS_UTF16
michael@0 240 # endif
michael@0 241 # elif defined(__UCS4__) || (U_PLATFORM == U_PF_OS400 && defined(__UTF32__))
michael@0 242 # if (U_SIZEOF_WCHAR_T==4)
michael@0 243 # define U_WCHAR_IS_UTF32
michael@0 244 # endif
michael@0 245 # elif U_PLATFORM_IS_DARWIN_BASED || (U_SIZEOF_WCHAR_T==4 && U_PLATFORM_IS_LINUX_BASED)
michael@0 246 # define U_WCHAR_IS_UTF32
michael@0 247 # elif U_PLATFORM_HAS_WIN32_API
michael@0 248 # define U_WCHAR_IS_UTF16
michael@0 249 # endif
michael@0 250 #endif
michael@0 251
michael@0 252 /* UChar and UChar32 definitions -------------------------------------------- */
michael@0 253
michael@0 254 /** Number of bytes in a UChar. @stable ICU 2.0 */
michael@0 255 #define U_SIZEOF_UCHAR 2
michael@0 256
michael@0 257 /**
michael@0 258 * \var UChar
michael@0 259 * Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t),
michael@0 260 * or wchar_t if that is 16 bits wide; always assumed to be unsigned.
michael@0 261 * If neither is available, then define UChar to be uint16_t.
michael@0 262 *
michael@0 263 * This makes the definition of UChar platform-dependent
michael@0 264 * but allows direct string type compatibility with platforms with
michael@0 265 * 16-bit wchar_t types.
michael@0 266 *
michael@0 267 * @stable ICU 4.4
michael@0 268 */
michael@0 269 #if defined(UCHAR_TYPE)
michael@0 270 typedef UCHAR_TYPE UChar;
michael@0 271 /* Not #elif U_HAVE_CHAR16_T -- because that is type-incompatible with pre-C++11 callers
michael@0 272 typedef char16_t UChar; */
michael@0 273 #elif U_SIZEOF_WCHAR_T==2
michael@0 274 typedef wchar_t UChar;
michael@0 275 #elif defined(__CHAR16_TYPE__)
michael@0 276 typedef __CHAR16_TYPE__ UChar;
michael@0 277 #else
michael@0 278 typedef uint16_t UChar;
michael@0 279 #endif
michael@0 280
michael@0 281 /**
michael@0 282 * Define UChar32 as a type for single Unicode code points.
michael@0 283 * UChar32 is a signed 32-bit integer (same as int32_t).
michael@0 284 *
michael@0 285 * The Unicode code point range is 0..0x10ffff.
michael@0 286 * All other values (negative or >=0x110000) are illegal as Unicode code points.
michael@0 287 * They may be used as sentinel values to indicate "done", "error"
michael@0 288 * or similar non-code point conditions.
michael@0 289 *
michael@0 290 * Before ICU 2.4 (Jitterbug 2146), UChar32 was defined
michael@0 291 * to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned)
michael@0 292 * or else to be uint32_t.
michael@0 293 * That is, the definition of UChar32 was platform-dependent.
michael@0 294 *
michael@0 295 * @see U_SENTINEL
michael@0 296 * @stable ICU 2.4
michael@0 297 */
michael@0 298 typedef int32_t UChar32;
michael@0 299
michael@0 300 /**
michael@0 301 * This value is intended for sentinel values for APIs that
michael@0 302 * (take or) return single code points (UChar32).
michael@0 303 * It is outside of the Unicode code point range 0..0x10ffff.
michael@0 304 *
michael@0 305 * For example, a "done" or "error" value in a new API
michael@0 306 * could be indicated with U_SENTINEL.
michael@0 307 *
michael@0 308 * ICU APIs designed before ICU 2.4 usually define service-specific "done"
michael@0 309 * values, mostly 0xffff.
michael@0 310 * Those may need to be distinguished from
michael@0 311 * actual U+ffff text contents by calling functions like
michael@0 312 * CharacterIterator::hasNext() or UnicodeString::length().
michael@0 313 *
michael@0 314 * @return -1
michael@0 315 * @see UChar32
michael@0 316 * @stable ICU 2.4
michael@0 317 */
michael@0 318 #define U_SENTINEL (-1)
michael@0 319
michael@0 320 #include "unicode/urename.h"
michael@0 321
michael@0 322 #endif

mercurial