2 ******************************************************************************
4 * Copyright (C) 1999-2004, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
8 * file name: umachine.h
10 * tab size: 8 (not used)
13 * created on: 1999sep13
14 * created by: Markus W. Scherer
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.
23 #ifndef __UMACHINE_H__
24 #define __UMACHINE_H__
29 * \brief Basic types and constants for UTF
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.
39 /*==========================================================================*/
40 /* Include platform-dependent definitions */
41 /* which are contained in the platform-specific file platform.h */
42 /*==========================================================================*/
44 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
47 # include "platform.h"
52 * stddef.h defines wchar_t
56 /*==========================================================================*/
57 /* XP_CPLUSPLUS is a cross-platform symbol which should be defined when */
58 /* using C++. It should not be defined when compiling under C. */
59 /*==========================================================================*/
69 /*==========================================================================*/
70 /* For C wrappers, we use the symbol U_STABLE. */
71 /* This works properly if the includer is C or C++. */
72 /* Functions are declared U_STABLE return-type U_EXPORT2 function-name()... */
73 /*==========================================================================*/
77 * This is used in a declaration of a library private ICU C function.
83 * This is used to begin a declaration of a library private ICU C API.
89 * This is used to end a declaration of a library private ICU C API
94 # define U_CFUNC extern "C"
95 # define U_CDECL_BEGIN extern "C" {
96 # define U_CDECL_END }
98 # define U_CFUNC extern
99 # define U_CDECL_BEGIN
104 * \def U_NAMESPACE_BEGIN
105 * This is used to begin a declaration of a public ICU C++ API.
106 * If the compiler doesn't support namespaces, this does nothing.
111 * \def U_NAMESPACE_END
112 * This is used to end a declaration of a public ICU C++ API
113 * If the compiler doesn't support namespaces, this does nothing.
118 * \def U_NAMESPACE_USE
119 * This is used to specify that the rest of the code uses the
120 * public ICU C++ API namespace.
121 * If the compiler doesn't support namespaces, this does nothing.
126 * \def U_NAMESPACE_QUALIFIER
127 * This is used to qualify that a function or class is part of
128 * the public ICU C++ API namespace.
129 * If the compiler doesn't support namespaces, this does nothing.
133 /* Define namespace symbols if the compiler supports it. */
135 # define U_NAMESPACE_BEGIN namespace U_ICU_NAMESPACE {
136 # define U_NAMESPACE_END }
137 # define U_NAMESPACE_USE using namespace U_ICU_NAMESPACE;
138 # define U_NAMESPACE_QUALIFIER U_ICU_NAMESPACE::
140 # define U_NAMESPACE_BEGIN
141 # define U_NAMESPACE_END
142 # define U_NAMESPACE_USE
143 # define U_NAMESPACE_QUALIFIER
146 /** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
147 #define U_CAPI U_CFUNC U_EXPORT
148 #define U_STABLE U_CAPI
149 #define U_DRAFT U_CAPI
150 #define U_DEPRECATED U_CAPI
151 #define U_OBSOLETE U_CAPI
152 #define U_INTERNAL U_CAPI
154 /*==========================================================================*/
155 /* limits for int32_t etc., like in POSIX inttypes.h */
156 /*==========================================================================*/
159 /** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */
160 # define INT8_MIN ((int8_t)(-128))
163 /** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */
164 # define INT16_MIN ((int16_t)(-32767-1))
167 /** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */
168 # define INT32_MIN ((int32_t)(-2147483647-1))
172 /** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */
173 # define INT8_MAX ((int8_t)(127))
176 /** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */
177 # define INT16_MAX ((int16_t)(32767))
180 /** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */
181 # define INT32_MAX ((int32_t)(2147483647))
185 /** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */
186 # define UINT8_MAX ((uint8_t)(255U))
189 /** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */
190 # define UINT16_MAX ((uint16_t)(65535U))
193 /** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */
194 # define UINT32_MAX ((uint32_t)(4294967295U))
197 #if defined(U_INT64_T_UNAVAILABLE)
198 # error int64_t is required for decimal format and rule-based number format.
202 * Provides a platform independent way to specify a signed 64-bit integer constant.
203 * note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C
206 # define INT64_C(c) c ## LL
210 * Provides a platform independent way to specify an unsigned 64-bit integer constant.
211 * note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C
214 # define UINT64_C(c) c ## ULL
217 /** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */
218 # define U_INT64_MIN ((int64_t)(INT64_C(-9223372036854775807)-1))
221 /** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */
222 # define U_INT64_MAX ((int64_t)(INT64_C(9223372036854775807)))
224 # ifndef U_UINT64_MAX
225 /** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */
226 # define U_UINT64_MAX ((uint64_t)(UINT64_C(18446744073709551615)))
230 /*==========================================================================*/
231 /* Boolean data type */
232 /*==========================================================================*/
234 /** The ICU boolean type @stable ICU 2.0 */
235 typedef int8_t UBool
;
238 /** The TRUE value of a UBool @stable ICU 2.0 */
242 /** The FALSE value of a UBool @stable ICU 2.0 */
247 /*==========================================================================*/
248 /* Unicode data types */
249 /*==========================================================================*/
251 /* wchar_t-related definitions -------------------------------------------- */
254 * \def U_HAVE_WCHAR_H
255 * Indicates whether <wchar.h> is available (1) or not (0). Set to 1 by default.
259 #ifndef U_HAVE_WCHAR_H
260 # define U_HAVE_WCHAR_H 1
264 * \def U_SIZEOF_WCHAR_T
265 * U_SIZEOF_WCHAR_T==sizeof(wchar_t) (0 means it is not defined or autoconf could not set it)
269 #if U_SIZEOF_WCHAR_T==0
270 # undef U_SIZEOF_WCHAR_T
271 # define U_SIZEOF_WCHAR_T 4
275 * \def U_WCHAR_IS_UTF16
276 * Defined if wchar_t uses UTF-16.
281 * \def U_WCHAR_IS_UTF32
282 * Defined if wchar_t uses UTF-32.
286 #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
287 # ifdef __STDC_ISO_10646__
288 # if (U_SIZEOF_WCHAR_T==2)
289 # define U_WCHAR_IS_UTF16
290 # elif (U_SIZEOF_WCHAR_T==4)
291 # define U_WCHAR_IS_UTF32
293 # elif defined __UCS2__
294 # if (__OS390__ || __OS400__) && (U_SIZEOF_WCHAR_T==2)
295 # define U_WCHAR_IS_UTF16
297 # elif defined __UCS4__
298 # if (U_SIZEOF_WCHAR_T==4)
299 # define U_WCHAR_IS_UTF32
301 # elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
302 # define U_WCHAR_IS_UTF16
306 /* UChar and UChar32 definitions -------------------------------------------- */
308 /** Number of bytes in a UChar. @stable ICU 2.0 */
309 #define U_SIZEOF_UCHAR 2
313 * Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
314 * If wchar_t is not 16 bits wide, then define UChar to be uint16_t.
315 * This makes the definition of UChar platform-dependent
316 * but allows direct string type compatibility with platforms with
317 * 16-bit wchar_t types.
322 /* Define UChar to be compatible with wchar_t if possible. */
323 #if U_SIZEOF_WCHAR_T==2
324 typedef wchar_t UChar
;
326 typedef uint16_t UChar
;
330 * Define UChar32 as a type for single Unicode code points.
331 * UChar32 is a signed 32-bit integer (same as int32_t).
333 * The Unicode code point range is 0..0x10ffff.
334 * All other values (negative or >=0x110000) are illegal as Unicode code points.
335 * They may be used as sentinel values to indicate "done", "error"
336 * or similar non-code point conditions.
338 * Before ICU 2.4 (Jitterbug 2146), UChar32 was defined
339 * to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned)
340 * or else to be uint32_t.
341 * That is, the definition of UChar32 was platform-dependent.
346 typedef int32_t UChar32
;
348 /*==========================================================================*/
349 /* U_INLINE and U_ALIGN_CODE Set default values if these are not already */
350 /* defined. Definitions normally are in */
351 /* platform.h or the corresponding file for */
353 /*==========================================================================*/
357 * This is used to align code fragments to a specific byte boundary.
358 * This is useful for getting consistent performance test results.
362 # define U_ALIGN_CODE(n)