]> git.saurik.com Git - apple/javascriptcore.git/blame - icu/unicode/umachine.h
JavaScriptCore-1097.3.3.tar.gz
[apple/javascriptcore.git] / icu / unicode / umachine.h
CommitLineData
b37bf2e1
A
1/*
2******************************************************************************
3*
4* Copyright (C) 1999-2004, 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(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
45# include "unicode/pwin32.h"
46#else
47# include "unicode/platform.h"
48#endif
49
50/*
51 * ANSI C headers:
52 * stddef.h defines wchar_t
53 */
54#include <stddef.h>
55
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/*==========================================================================*/
60
61#ifdef __cplusplus
62# ifndef XP_CPLUSPLUS
63# define XP_CPLUSPLUS
64# endif
65#else
66# undef XP_CPLUSPLUS
67#endif
68
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/*==========================================================================*/
74
75/**
76 * \def U_CFUNC
77 * This is used in a declaration of a library private ICU C function.
78 * @stable ICU 2.4
79 */
80
81/**
82 * \def U_CDECL_BEGIN
83 * This is used to begin a declaration of a library private ICU C API.
84 * @stable ICU 2.4
85 */
86
87/**
88 * \def U_CDECL_END
89 * This is used to end a declaration of a library private ICU C API
90 * @stable ICU 2.4
91 */
92
93#ifdef XP_CPLUSPLUS
94# define U_CFUNC extern "C"
95# define U_CDECL_BEGIN extern "C" {
96# define U_CDECL_END }
97#else
98# define U_CFUNC extern
99# define U_CDECL_BEGIN
100# define U_CDECL_END
101#endif
102
103/**
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.
107 * @stable ICU 2.4
108 */
109
110/**
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.
114 * @stable ICU 2.4
115 */
116
117/**
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.
122 * @stable ICU 2.4
123 */
124
125/**
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.
130 * @stable ICU 2.4
131 */
132
133/* Define namespace symbols if the compiler supports it. */
134#if U_HAVE_NAMESPACE
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::
139#else
140# define U_NAMESPACE_BEGIN
141# define U_NAMESPACE_END
142# define U_NAMESPACE_USE
143# define U_NAMESPACE_QUALIFIER
144#endif
145
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
153
154/*==========================================================================*/
155/* limits for int32_t etc., like in POSIX inttypes.h */
156/*==========================================================================*/
157
158#ifndef INT8_MIN
159/** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */
160# define INT8_MIN ((int8_t)(-128))
161#endif
162#ifndef INT16_MIN
163/** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */
164# define INT16_MIN ((int16_t)(-32767-1))
165#endif
166#ifndef INT32_MIN
167/** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */
168# define INT32_MIN ((int32_t)(-2147483647-1))
169#endif
170
171#ifndef INT8_MAX
172/** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */
173# define INT8_MAX ((int8_t)(127))
174#endif
175#ifndef INT16_MAX
176/** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */
177# define INT16_MAX ((int16_t)(32767))
178#endif
179#ifndef INT32_MAX
180/** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */
181# define INT32_MAX ((int32_t)(2147483647))
182#endif
183
184#ifndef UINT8_MAX
185/** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */
186# define UINT8_MAX ((uint8_t)(255U))
187#endif
188#ifndef UINT16_MAX
189/** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */
190# define UINT16_MAX ((uint16_t)(65535U))
191#endif
192#ifndef UINT32_MAX
193/** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */
194# define UINT32_MAX ((uint32_t)(4294967295U))
195#endif
196
197#if defined(U_INT64_T_UNAVAILABLE)
198# error int64_t is required for decimal format and rule-based number format.
199#else
200# ifndef INT64_C
201/**
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
204 * @draft ICU 2.8
205 */
206# define INT64_C(c) c ## LL
207# endif
208# ifndef UINT64_C
209/**
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
212 * @draft ICU 2.8
213 */
214# define UINT64_C(c) c ## ULL
215# endif
216# ifndef U_INT64_MIN
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))
219# endif
220# ifndef U_INT64_MAX
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)))
223# endif
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)))
227# endif
228#endif
229
230/*==========================================================================*/
231/* Boolean data type */
232/*==========================================================================*/
233
234/** The ICU boolean type @stable ICU 2.0 */
235typedef int8_t UBool;
236
237#ifndef TRUE
238/** The TRUE value of a UBool @stable ICU 2.0 */
239# define TRUE 1
240#endif
241#ifndef FALSE
242/** The FALSE value of a UBool @stable ICU 2.0 */
243# define FALSE 0
244#endif
245
246
247/*==========================================================================*/
248/* Unicode data types */
249/*==========================================================================*/
250
251/* wchar_t-related definitions -------------------------------------------- */
252
253/**
254 * \def U_HAVE_WCHAR_H
255 * Indicates whether <wchar.h> is available (1) or not (0). Set to 1 by default.
256 *
257 * @stable ICU 2.0
258 */
259#ifndef U_HAVE_WCHAR_H
260# define U_HAVE_WCHAR_H 1
261#endif
262
263/**
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)
266 *
267 * @stable ICU 2.0
268 */
269#if U_SIZEOF_WCHAR_T==0
270# undef U_SIZEOF_WCHAR_T
271# define U_SIZEOF_WCHAR_T 4
272#endif
273
274/*
275 * \def U_WCHAR_IS_UTF16
276 * Defined if wchar_t uses UTF-16.
277 *
278 * @stable ICU 2.0
279 */
280/*
281 * \def U_WCHAR_IS_UTF32
282 * Defined if wchar_t uses UTF-32.
283 *
284 * @stable ICU 2.0
285 */
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
292# endif
293# elif defined __UCS2__
294# if (__OS390__ || __OS400__) && (U_SIZEOF_WCHAR_T==2)
295# define U_WCHAR_IS_UTF16
296# endif
297# elif defined __UCS4__
298# if (U_SIZEOF_WCHAR_T==4)
299# define U_WCHAR_IS_UTF32
300# endif
301# elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
302# define U_WCHAR_IS_UTF16
303# endif
304#endif
305
306/* UChar and UChar32 definitions -------------------------------------------- */
307
308/** Number of bytes in a UChar. @stable ICU 2.0 */
309#define U_SIZEOF_UCHAR 2
310
311/**
312 * \var UChar
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.
318 *
319 * @stable ICU 2.0
320 */
321
322/* Define UChar to be compatible with wchar_t if possible. */
323#if U_SIZEOF_WCHAR_T==2
324 typedef wchar_t UChar;
325#else
326 typedef uint16_t UChar;
327#endif
328
329/**
330 * Define UChar32 as a type for single Unicode code points.
331 * UChar32 is a signed 32-bit integer (same as int32_t).
332 *
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.
337 *
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.
342 *
343 * @see U_SENTINEL
344 * @stable ICU 2.4
345 */
346typedef int32_t UChar32;
347
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 */
352/* the OS in use. */
353/*==========================================================================*/
354
355/**
356 * \def U_ALIGN_CODE
357 * This is used to align code fragments to a specific byte boundary.
358 * This is useful for getting consistent performance test results.
359 * @internal
360 */
361#ifndef U_ALIGN_CODE
362# define U_ALIGN_CODE(n)
363#endif
364
365#ifndef U_INLINE
366# define U_INLINE
367#endif
368
369#include "unicode/urename.h"
370
371#endif