Rizin
unix-like reverse engineering framework and cli tools
umachine.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ******************************************************************************
5 *
6 * Copyright (C) 1999-2015, International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 ******************************************************************************
10 * file name: umachine.h
11 * encoding: UTF-8
12 * tab size: 8 (not used)
13 * indentation:4
14 *
15 * created on: 1999sep13
16 * created by: Markus W. Scherer
17 *
18 * This file defines basic types and constants for ICU to be
19 * platform-independent. umachine.h and utf.h are included into
20 * utypes.h to provide all the general definitions for ICU.
21 * All of these definitions used to be in utypes.h before
22 * the UTF-handling macros made this unmaintainable.
23 */
24 
25 #ifndef __UMACHINE_H__
26 #define __UMACHINE_H__
27 
28 
41 /*==========================================================================*/
42 /* Include platform-dependent definitions */
43 /* which are contained in the platform-specific file platform.h */
44 /*==========================================================================*/
45 
46 #include "unicode/ptypes.h" /* platform.h is included in ptypes.h */
47 
48 /*
49  * ANSI C headers:
50  * stddef.h defines wchar_t
51  */
52 #include <stddef.h>
53 
54 /*==========================================================================*/
55 /* For C wrappers, we use the symbol U_STABLE. */
56 /* This works properly if the includer is C or C++. */
57 /* Functions are declared U_STABLE return-type U_EXPORT2 function-name()... */
58 /*==========================================================================*/
59 
78 #ifdef __cplusplus
79 # define U_CFUNC extern "C"
80 # define U_CDECL_BEGIN extern "C" {
81 # define U_CDECL_END }
82 #else
83 # define U_CFUNC extern
84 # define U_CDECL_BEGIN
85 # define U_CDECL_END
86 #endif
87 
88 #ifndef U_ATTRIBUTE_DEPRECATED
94 #if U_GCC_MAJOR_MINOR >= 302
95 # define U_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))
101 #elif defined(_MSC_VER) && (_MSC_VER >= 1400)
102 # define U_ATTRIBUTE_DEPRECATED __declspec(deprecated)
103 #else
104 # define U_ATTRIBUTE_DEPRECATED
105 #endif
106 #endif
107 
109 #define U_CAPI U_CFUNC U_EXPORT
111 #define U_STABLE U_CAPI
113 #define U_DRAFT U_CAPI
115 #define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED
117 #define U_OBSOLETE U_CAPI
119 #define U_INTERNAL U_CAPI
120 
128 #ifndef U_OVERRIDE
129 #define U_OVERRIDE override
130 #endif
131 
139 #if !defined(U_FINAL) || defined(U_IN_DOXYGEN)
140 #define U_FINAL final
141 #endif
142 
143 // Before ICU 65, function-like, multi-statement ICU macros were just defined as
144 // series of statements wrapped in { } blocks and the caller could choose to
145 // either treat them as if they were actual functions and end the invocation
146 // with a trailing ; creating an empty statement after the block or else omit
147 // this trailing ; using the knowledge that the macro would expand to { }.
148 //
149 // But doing so doesn't work well with macros that look like functions and
150 // compiler warnings about empty statements (ICU-20601) and ICU 65 therefore
151 // switches to the standard solution of wrapping such macros in do { } while.
152 //
153 // This will however break existing code that depends on being able to invoke
154 // these macros without a trailing ; so to be able to remain compatible with
155 // such code the wrapper is itself defined as macros so that it's possible to
156 // build ICU 65 and later with the old macro behaviour, like this:
157 //
158 // CPPFLAGS='-DUPRV_BLOCK_MACRO_BEGIN="" -DUPRV_BLOCK_MACRO_END=""'
159 // runConfigureICU ...
160 
166 #ifndef UPRV_BLOCK_MACRO_BEGIN
167 #define UPRV_BLOCK_MACRO_BEGIN do
168 #endif
169 
175 #ifndef UPRV_BLOCK_MACRO_END
176 #define UPRV_BLOCK_MACRO_END while (FALSE)
177 #endif
178 
179 /*==========================================================================*/
180 /* limits for int32_t etc., like in POSIX inttypes.h */
181 /*==========================================================================*/
182 
183 #ifndef INT8_MIN
185 # define INT8_MIN ((int8_t)(-128))
186 #endif
187 #ifndef INT16_MIN
189 # define INT16_MIN ((int16_t)(-32767-1))
190 #endif
191 #ifndef INT32_MIN
193 # define INT32_MIN ((int32_t)(-2147483647-1))
194 #endif
195 
196 #ifndef INT8_MAX
198 # define INT8_MAX ((int8_t)(127))
199 #endif
200 #ifndef INT16_MAX
202 # define INT16_MAX ((int16_t)(32767))
203 #endif
204 #ifndef INT32_MAX
206 # define INT32_MAX ((int32_t)(2147483647))
207 #endif
208 
209 #ifndef UINT8_MAX
211 # define UINT8_MAX ((uint8_t)(255U))
212 #endif
213 #ifndef UINT16_MAX
215 # define UINT16_MAX ((uint16_t)(65535U))
216 #endif
217 #ifndef UINT32_MAX
219 # define UINT32_MAX ((uint32_t)(4294967295U))
220 #endif
221 
222 #if defined(U_INT64_T_UNAVAILABLE)
223 # error int64_t is required for decimal format and rule-based number format.
224 #else
225 # ifndef INT64_C
231 # define INT64_C(c) c ## LL
232 # endif
233 # ifndef UINT64_C
239 # define UINT64_C(c) c ## ULL
240 # endif
241 # ifndef U_INT64_MIN
243 # define U_INT64_MIN ((int64_t)(INT64_C(-9223372036854775807)-1))
244 # endif
245 # ifndef U_INT64_MAX
247 # define U_INT64_MAX ((int64_t)(INT64_C(9223372036854775807)))
248 # endif
249 # ifndef U_UINT64_MAX
251 # define U_UINT64_MAX ((uint64_t)(UINT64_C(18446744073709551615)))
252 # endif
253 #endif
254 
255 /*==========================================================================*/
256 /* Boolean data type */
257 /*==========================================================================*/
258 
260 typedef int8_t UBool;
261 
262 #ifndef TRUE
264 # define TRUE 1
265 #endif
266 #ifndef FALSE
268 # define FALSE 0
269 #endif
270 
271 
272 /*==========================================================================*/
273 /* Unicode data types */
274 /*==========================================================================*/
275 
276 /* wchar_t-related definitions -------------------------------------------- */
277 
278 /*
279  * \def U_WCHAR_IS_UTF16
280  * Defined if wchar_t uses UTF-16.
281  *
282  * @stable ICU 2.0
283  */
284 /*
285  * \def U_WCHAR_IS_UTF32
286  * Defined if wchar_t uses UTF-32.
287  *
288  * @stable ICU 2.0
289  */
290 #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
291 # ifdef __STDC_ISO_10646__
292 # if (U_SIZEOF_WCHAR_T==2)
293 # define U_WCHAR_IS_UTF16
294 # elif (U_SIZEOF_WCHAR_T==4)
295 # define U_WCHAR_IS_UTF32
296 # endif
297 # elif defined __UCS2__
298 # if (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400) && (U_SIZEOF_WCHAR_T==2)
299 # define U_WCHAR_IS_UTF16
300 # endif
301 # elif defined(__UCS4__) || (U_PLATFORM == U_PF_OS400 && defined(__UTF32__))
302 # if (U_SIZEOF_WCHAR_T==4)
303 # define U_WCHAR_IS_UTF32
304 # endif
305 # elif U_PLATFORM_IS_DARWIN_BASED || (U_SIZEOF_WCHAR_T==4 && U_PLATFORM_IS_LINUX_BASED)
306 # define U_WCHAR_IS_UTF32
307 # elif U_PLATFORM_HAS_WIN32_API
308 # define U_WCHAR_IS_UTF16
309 # endif
310 #endif
311 
312 /* UChar and UChar32 definitions -------------------------------------------- */
313 
315 #define U_SIZEOF_UCHAR 2
316 
322 #if (U_PLATFORM == U_PF_AIX) && defined(__cplusplus) &&(U_CPLUSPLUS_VERSION < 11)
323 // for AIX, uchar.h needs to be included
324 # include <uchar.h>
325 # define U_CHAR16_IS_TYPEDEF 1
326 #elif defined(_MSC_VER) && (_MSC_VER < 1900)
327 // Versions of Visual Studio/MSVC below 2015 do not support char16_t as a real type,
328 // and instead use a typedef. https://msdn.microsoft.com/library/bb531344.aspx
329 # define U_CHAR16_IS_TYPEDEF 1
330 #else
331 # define U_CHAR16_IS_TYPEDEF 0
332 #endif
333 
334 
359 #if 1
360  // #if 1 is normal. UChar defaults to char16_t in C++.
361  // For configuration testing of UChar=uint16_t temporarily change this to #if 0.
362  // The intltest Makefile #defines UCHAR_TYPE=char16_t,
363  // so we only #define it to uint16_t if it is undefined so far.
364 #elif !defined(UCHAR_TYPE)
365 # define UCHAR_TYPE uint16_t
366 #endif
367 
368 #if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || \
369  defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION)
370  // Inside the ICU library code, never configurable.
371  typedef char16_t UChar;
372 #elif defined(UCHAR_TYPE)
373  typedef UCHAR_TYPE UChar;
374 #elif defined(__cplusplus)
375  typedef char16_t UChar;
376 #else
377  typedef uint16_t UChar;
378 #endif
379 
399 #if U_SIZEOF_WCHAR_T==2
400  typedef wchar_t OldUChar;
401 #elif defined(__CHAR16_TYPE__)
402  typedef __CHAR16_TYPE__ OldUChar;
403 #else
405 #endif
406 
424 typedef int32_t UChar32;
425 
444 #define U_SENTINEL (-1)
445 
446 #include "unicode/urename.h"
447 
448 #endif
unsigned short uint16_t
Definition: sftypes.h:30
int int32_t
Definition: sftypes.h:33
char int8_t
Definition: sftypes.h:35
int32_t UChar32
Definition: umachine.h:424
int8_t UBool
Definition: umachine.h:260
uint16_t UChar
Definition: umachine.h:377
uint16_t OldUChar
Definition: umachine.h:404