]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/unicode/umachine.h
2 ******************************************************************************
4 * Copyright (C) 1999-2006, 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 /*==========================================================================*/
45 # include "unicode/ppalmos.h"
46 #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
47 # include "unicode/pwin32.h"
49 # include "unicode/platform.h"
54 * stddef.h defines wchar_t
58 /*==========================================================================*/
59 /* XP_CPLUSPLUS is a cross-platform symbol which should be defined when */
60 /* using C++. It should not be defined when compiling under C. */
61 /*==========================================================================*/
71 /*==========================================================================*/
72 /* For C wrappers, we use the symbol U_STABLE. */
73 /* This works properly if the includer is C or C++. */
74 /* Functions are declared U_STABLE return-type U_EXPORT2 function-name()... */
75 /*==========================================================================*/
79 * This is used in a declaration of a library private ICU C function.
85 * This is used to begin a declaration of a library private ICU C API.
91 * This is used to end a declaration of a library private ICU C API
96 # define U_CFUNC extern "C"
97 # define U_CDECL_BEGIN extern "C" {
98 # define U_CDECL_END }
100 # define U_CFUNC extern
101 # define U_CDECL_BEGIN
106 * \def U_NAMESPACE_BEGIN
107 * This is used to begin a declaration of a public ICU C++ API.
108 * If the compiler doesn't support namespaces, this does nothing.
113 * \def U_NAMESPACE_END
114 * This is used to end a declaration of a public ICU C++ API
115 * If the compiler doesn't support namespaces, this does nothing.
120 * \def U_NAMESPACE_USE
121 * This is used to specify that the rest of the code uses the
122 * public ICU C++ API namespace.
123 * If the compiler doesn't support namespaces, this does nothing.
128 * \def U_NAMESPACE_QUALIFIER
129 * This is used to qualify that a function or class is part of
130 * the public ICU C++ API namespace.
131 * If the compiler doesn't support namespaces, this does nothing.
135 /* Define namespace symbols if the compiler supports it. */
137 # define U_NAMESPACE_BEGIN namespace U_ICU_NAMESPACE {
138 # define U_NAMESPACE_END }
139 # define U_NAMESPACE_USE using namespace U_ICU_NAMESPACE;
140 # define U_NAMESPACE_QUALIFIER U_ICU_NAMESPACE::
142 # define U_NAMESPACE_BEGIN
143 # define U_NAMESPACE_END
144 # define U_NAMESPACE_USE
145 # define U_NAMESPACE_QUALIFIER
148 /** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
149 #define U_CAPI U_CFUNC U_EXPORT
150 #define U_STABLE U_CAPI
151 #define U_DRAFT U_CAPI
152 #define U_DEPRECATED U_CAPI
153 #define U_OBSOLETE U_CAPI
154 #define U_INTERNAL U_CAPI
156 /*==========================================================================*/
157 /* limits for int32_t etc., like in POSIX inttypes.h */
158 /*==========================================================================*/
161 /** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */
162 # define INT8_MIN ((int8_t)(-128))
165 /** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */
166 # define INT16_MIN ((int16_t)(-32767-1))
169 /** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */
170 # define INT32_MIN ((int32_t)(-2147483647-1))
174 /** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */
175 # define INT8_MAX ((int8_t)(127))
178 /** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */
179 # define INT16_MAX ((int16_t)(32767))
182 /** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */
183 # define INT32_MAX ((int32_t)(2147483647))
187 /** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */
188 # define UINT8_MAX ((uint8_t)(255U))
191 /** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */
192 # define UINT16_MAX ((uint16_t)(65535U))
195 /** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */
196 # define UINT32_MAX ((uint32_t)(4294967295U))
199 #if defined(U_INT64_T_UNAVAILABLE)
200 # error int64_t is required for decimal format and rule-based number format.
204 * Provides a platform independent way to specify a signed 64-bit integer constant.
205 * note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C
208 # define INT64_C(c) c ## LL
212 * Provides a platform independent way to specify an unsigned 64-bit integer constant.
213 * note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C
216 # define UINT64_C(c) c ## ULL
219 /** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */
220 # define U_INT64_MIN ((int64_t)(INT64_C(-9223372036854775807)-1))
223 /** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */
224 # define U_INT64_MAX ((int64_t)(INT64_C(9223372036854775807)))
226 # ifndef U_UINT64_MAX
227 /** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */
228 # define U_UINT64_MAX ((uint64_t)(UINT64_C(18446744073709551615)))
232 /*==========================================================================*/
233 /* Boolean data type */
234 /*==========================================================================*/
236 /** The ICU boolean type @stable ICU 2.0 */
237 typedef int8_t UBool
;
240 /** The TRUE value of a UBool @stable ICU 2.0 */
244 /** The FALSE value of a UBool @stable ICU 2.0 */
249 /*==========================================================================*/
250 /* Unicode data types */
251 /*==========================================================================*/
253 /* wchar_t-related definitions -------------------------------------------- */
256 * \def U_HAVE_WCHAR_H
257 * Indicates whether <wchar.h> is available (1) or not (0). Set to 1 by default.
261 #ifndef U_HAVE_WCHAR_H
262 # define U_HAVE_WCHAR_H 1
266 * \def U_SIZEOF_WCHAR_T
267 * U_SIZEOF_WCHAR_T==sizeof(wchar_t) (0 means it is not defined or autoconf could not set it)
271 #if U_SIZEOF_WCHAR_T==0
272 # undef U_SIZEOF_WCHAR_T
273 # define U_SIZEOF_WCHAR_T 4
277 * \def U_WCHAR_IS_UTF16
278 * Defined if wchar_t uses UTF-16.
283 * \def U_WCHAR_IS_UTF32
284 * Defined if wchar_t uses UTF-32.
288 #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
289 # ifdef __STDC_ISO_10646__
290 # if (U_SIZEOF_WCHAR_T==2)
291 # define U_WCHAR_IS_UTF16
292 # elif (U_SIZEOF_WCHAR_T==4)
293 # define U_WCHAR_IS_UTF32
295 # elif defined __UCS2__
296 # if (__OS390__ || __OS400__) && (U_SIZEOF_WCHAR_T==2)
297 # define U_WCHAR_IS_UTF16
299 # elif defined __UCS4__
300 # if (U_SIZEOF_WCHAR_T==4)
301 # define U_WCHAR_IS_UTF32
303 # elif defined(U_WINDOWS)
304 # define U_WCHAR_IS_UTF16
308 /* UChar and UChar32 definitions -------------------------------------------- */
310 /** Number of bytes in a UChar. @stable ICU 2.0 */
311 #define U_SIZEOF_UCHAR 2
315 * Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
316 * If wchar_t is not 16 bits wide, then define UChar to be uint16_t.
317 * This makes the definition of UChar platform-dependent
318 * but allows direct string type compatibility with platforms with
319 * 16-bit wchar_t types.
324 /* Define UChar to be compatible with wchar_t if possible. */
325 #if U_SIZEOF_WCHAR_T==2
326 typedef wchar_t UChar
;
328 typedef uint16_t UChar
;
332 * Define UChar32 as a type for single Unicode code points.
333 * UChar32 is a signed 32-bit integer (same as int32_t).
335 * The Unicode code point range is 0..0x10ffff.
336 * All other values (negative or >=0x110000) are illegal as Unicode code points.
337 * They may be used as sentinel values to indicate "done", "error"
338 * or similar non-code point conditions.
340 * Before ICU 2.4 (Jitterbug 2146), UChar32 was defined
341 * to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned)
342 * or else to be uint32_t.
343 * That is, the definition of UChar32 was platform-dependent.
348 typedef int32_t UChar32
;
350 /*==========================================================================*/
351 /* U_INLINE and U_ALIGN_CODE Set default values if these are not already */
352 /* defined. Definitions normally are in */
353 /* platform.h or the corresponding file for */
355 /*==========================================================================*/
357 #ifndef U_HIDE_INTERNAL_API
361 * This is used to align code fragments to a specific byte boundary.
362 * This is useful for getting consistent performance test results.
366 # define U_ALIGN_CODE(n)
369 #endif /* U_HIDE_INTERNAL_API */
373 # define U_INLINE inline
379 #include "unicode/urename.h"