]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/unicode/umachine.h
2 ******************************************************************************
4 * Copyright (C) 1999-2012, 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 #include "unicode/ptypes.h" /* platform.h is included in ptypes.h */
48 * stddef.h defines wchar_t
52 /*==========================================================================*/
53 /* For C wrappers, we use the symbol U_STABLE. */
54 /* This works properly if the includer is C or C++. */
55 /* Functions are declared U_STABLE return-type U_EXPORT2 function-name()... */
56 /*==========================================================================*/
60 * This is used in a declaration of a library private ICU C function.
66 * This is used to begin a declaration of a library private ICU C API.
72 * This is used to end a declaration of a library private ICU C API
77 # define U_CFUNC extern "C"
78 # define U_CDECL_BEGIN extern "C" {
79 # define U_CDECL_END }
81 # define U_CFUNC extern
82 # define U_CDECL_BEGIN
86 #ifndef U_ATTRIBUTE_DEPRECATED
88 * \def U_ATTRIBUTE_DEPRECATED
89 * This is used for GCC specific attributes
92 #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 2))
93 # define U_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))
95 * \def U_ATTRIBUTE_DEPRECATED
96 * This is used for Visual C++ specific attributes
99 #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
100 # define U_ATTRIBUTE_DEPRECATED __declspec(deprecated)
102 # define U_ATTRIBUTE_DEPRECATED
106 /** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
107 #define U_CAPI U_CFUNC U_EXPORT
108 /** This is used to declare a function as a stable public ICU C API*/
109 #define U_STABLE U_CAPI
110 /** This is used to declare a function as a draft public ICU C API */
111 #define U_DRAFT U_CAPI
112 /** This is used to declare a function as a deprecated public ICU C API */
113 #define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED
114 /** This is used to declare a function as an obsolete public ICU C API */
115 #define U_OBSOLETE U_CAPI
116 /** This is used to declare a function as an internal ICU C API */
117 #define U_INTERNAL U_CAPI
119 /*==========================================================================*/
120 /* limits for int32_t etc., like in POSIX inttypes.h */
121 /*==========================================================================*/
124 /** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */
125 # define INT8_MIN ((int8_t)(-128))
128 /** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */
129 # define INT16_MIN ((int16_t)(-32767-1))
132 /** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */
133 # define INT32_MIN ((int32_t)(-2147483647-1))
137 /** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */
138 # define INT8_MAX ((int8_t)(127))
141 /** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */
142 # define INT16_MAX ((int16_t)(32767))
145 /** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */
146 # define INT32_MAX ((int32_t)(2147483647))
150 /** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */
151 # define UINT8_MAX ((uint8_t)(255U))
154 /** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */
155 # define UINT16_MAX ((uint16_t)(65535U))
158 /** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */
159 # define UINT32_MAX ((uint32_t)(4294967295U))
162 #if defined(U_INT64_T_UNAVAILABLE)
163 # error int64_t is required for decimal format and rule-based number format.
167 * Provides a platform independent way to specify a signed 64-bit integer constant.
168 * note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C
171 # define INT64_C(c) c ## LL
175 * Provides a platform independent way to specify an unsigned 64-bit integer constant.
176 * note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C
179 # define UINT64_C(c) c ## ULL
182 /** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */
183 # define U_INT64_MIN ((int64_t)(INT64_C(-9223372036854775807)-1))
186 /** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */
187 # define U_INT64_MAX ((int64_t)(INT64_C(9223372036854775807)))
189 # ifndef U_UINT64_MAX
190 /** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */
191 # define U_UINT64_MAX ((uint64_t)(UINT64_C(18446744073709551615)))
195 /*==========================================================================*/
196 /* Boolean data type */
197 /*==========================================================================*/
199 /** The ICU boolean type @stable ICU 2.0 */
200 typedef int8_t UBool
;
203 /** The TRUE value of a UBool @stable ICU 2.0 */
207 /** The FALSE value of a UBool @stable ICU 2.0 */
212 /*==========================================================================*/
213 /* Unicode data types */
214 /*==========================================================================*/
216 /* wchar_t-related definitions -------------------------------------------- */
219 * \def U_WCHAR_IS_UTF16
220 * Defined if wchar_t uses UTF-16.
225 * \def U_WCHAR_IS_UTF32
226 * Defined if wchar_t uses UTF-32.
230 #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
231 # ifdef __STDC_ISO_10646__
232 # if (U_SIZEOF_WCHAR_T==2)
233 # define U_WCHAR_IS_UTF16
234 # elif (U_SIZEOF_WCHAR_T==4)
235 # define U_WCHAR_IS_UTF32
237 # elif defined __UCS2__
238 # if (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400) && (U_SIZEOF_WCHAR_T==2)
239 # define U_WCHAR_IS_UTF16
241 # elif defined(__UCS4__) || (U_PLATFORM == U_PF_OS400 && defined(__UTF32__))
242 # if (U_SIZEOF_WCHAR_T==4)
243 # define U_WCHAR_IS_UTF32
245 # elif U_PLATFORM_IS_DARWIN_BASED || (U_SIZEOF_WCHAR_T==4 && U_PLATFORM_IS_LINUX_BASED)
246 # define U_WCHAR_IS_UTF32
247 # elif U_PLATFORM_HAS_WIN32_API
248 # define U_WCHAR_IS_UTF16
252 /* UChar and UChar32 definitions -------------------------------------------- */
254 /** Number of bytes in a UChar. @stable ICU 2.0 */
255 #define U_SIZEOF_UCHAR 2
259 * Define UChar to be char16_t, if available,
260 * or wchar_t if that is 16 bits wide; always assumed to be unsigned.
261 * If neither is available, then define UChar to be uint16_t.
263 * This makes the definition of UChar platform-dependent
264 * but allows direct string type compatibility with platforms with
265 * 16-bit wchar_t types.
270 /* Define UChar to be compatible with char16_t or wchar_t if possible. */
272 typedef char16_t UChar
;
273 #elif U_SIZEOF_WCHAR_T==2
274 typedef wchar_t UChar
;
275 #elif defined(__CHAR16_TYPE__)
276 typedef __CHAR16_TYPE__ UChar
;
278 typedef uint16_t UChar
;
282 * Define UChar32 as a type for single Unicode code points.
283 * UChar32 is a signed 32-bit integer (same as int32_t).
285 * The Unicode code point range is 0..0x10ffff.
286 * All other values (negative or >=0x110000) are illegal as Unicode code points.
287 * They may be used as sentinel values to indicate "done", "error"
288 * or similar non-code point conditions.
290 * Before ICU 2.4 (Jitterbug 2146), UChar32 was defined
291 * to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned)
292 * or else to be uint32_t.
293 * That is, the definition of UChar32 was platform-dependent.
298 typedef int32_t UChar32
;
301 * This value is intended for sentinel values for APIs that
302 * (take or) return single code points (UChar32).
303 * It is outside of the Unicode code point range 0..0x10ffff.
305 * For example, a "done" or "error" value in a new API
306 * could be indicated with U_SENTINEL.
308 * ICU APIs designed before ICU 2.4 usually define service-specific "done"
309 * values, mostly 0xffff.
310 * Those may need to be distinguished from
311 * actual U+ffff text contents by calling functions like
312 * CharacterIterator::hasNext() or UnicodeString::length().
318 #define U_SENTINEL (-1)
320 #include "unicode/urename.h"