|
ICU 73.2
73.2
|
00001 // © 2016 and later: Unicode, Inc. and others. 00002 // License & terms of use: http://www.unicode.org/copyright.html 00003 /* 00004 ****************************************************************************** 00005 * 00006 * Copyright (C) 1999-2015, International Business Machines 00007 * Corporation and others. All Rights Reserved. 00008 * 00009 ****************************************************************************** 00010 * file name: umachine.h 00011 * encoding: UTF-8 00012 * tab size: 8 (not used) 00013 * indentation:4 00014 * 00015 * created on: 1999sep13 00016 * created by: Markus W. Scherer 00017 * 00018 * This file defines basic types and constants for ICU to be 00019 * platform-independent. umachine.h and utf.h are included into 00020 * utypes.h to provide all the general definitions for ICU. 00021 * All of these definitions used to be in utypes.h before 00022 * the UTF-handling macros made this unmaintainable. 00023 */ 00024 00025 #ifndef __UMACHINE_H__ 00026 #define __UMACHINE_H__ 00027 00028 00041 /*==========================================================================*/ 00042 /* Include platform-dependent definitions */ 00043 /* which are contained in the platform-specific file platform.h */ 00044 /*==========================================================================*/ 00045 00046 #include "unicode/ptypes.h" /* platform.h is included in ptypes.h */ 00047 00048 /* 00049 * ANSI C headers: 00050 * stddef.h defines wchar_t 00051 */ 00052 #include <stdbool.h> 00053 #include <stddef.h> 00054 00055 /*==========================================================================*/ 00056 /* For C wrappers, we use the symbol U_CAPI. */ 00057 /* This works properly if the includer is C or C++. */ 00058 /* Functions are declared U_CAPI return-type U_EXPORT2 function-name()... */ 00059 /*==========================================================================*/ 00060 00079 #ifdef __cplusplus 00080 # define U_CFUNC extern "C" 00081 # define U_CDECL_BEGIN extern "C" { 00082 # define U_CDECL_END } 00083 #else 00084 # define U_CFUNC extern 00085 # define U_CDECL_BEGIN 00086 # define U_CDECL_END 00087 #endif 00088 00089 #ifndef U_ATTRIBUTE_DEPRECATED 00090 00095 #if U_GCC_MAJOR_MINOR >= 302 00096 # define U_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated)) 00097 00102 #elif defined(_MSC_VER) && (_MSC_VER >= 1400) 00103 # define U_ATTRIBUTE_DEPRECATED __declspec(deprecated) 00104 #else 00105 # define U_ATTRIBUTE_DEPRECATED 00106 #endif 00107 #endif 00108 00110 #define U_CAPI U_CFUNC U_EXPORT 00111 00112 #define U_STABLE U_CAPI 00113 00114 #define U_DRAFT U_CAPI 00115 00116 #define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED 00117 00118 #define U_OBSOLETE U_CAPI 00119 00120 #define U_INTERNAL U_CAPI 00121 00122 // Before ICU 65, function-like, multi-statement ICU macros were just defined as 00123 // series of statements wrapped in { } blocks and the caller could choose to 00124 // either treat them as if they were actual functions and end the invocation 00125 // with a trailing ; creating an empty statement after the block or else omit 00126 // this trailing ; using the knowledge that the macro would expand to { }. 00127 // 00128 // But doing so doesn't work well with macros that look like functions and 00129 // compiler warnings about empty statements (ICU-20601) and ICU 65 therefore 00130 // switches to the standard solution of wrapping such macros in do { } while. 00131 // 00132 // This will however break existing code that depends on being able to invoke 00133 // these macros without a trailing ; so to be able to remain compatible with 00134 // such code the wrapper is itself defined as macros so that it's possible to 00135 // build ICU 65 and later with the old macro behaviour, like this: 00136 // 00137 // export CPPFLAGS='-DUPRV_BLOCK_MACRO_BEGIN="" -DUPRV_BLOCK_MACRO_END=""' 00138 // runConfigureICU ... 00139 // 00140 00146 #ifndef UPRV_BLOCK_MACRO_BEGIN 00147 #define UPRV_BLOCK_MACRO_BEGIN do 00148 #endif 00149 00155 #ifndef UPRV_BLOCK_MACRO_END 00156 #define UPRV_BLOCK_MACRO_END while (false) 00157 #endif 00158 00159 /*==========================================================================*/ 00160 /* limits for int32_t etc., like in POSIX inttypes.h */ 00161 /*==========================================================================*/ 00162 00163 #ifndef INT8_MIN 00164 00165 # define INT8_MIN ((int8_t)(-128)) 00166 #endif 00167 #ifndef INT16_MIN 00168 00169 # define INT16_MIN ((int16_t)(-32767-1)) 00170 #endif 00171 #ifndef INT32_MIN 00172 00173 # define INT32_MIN ((int32_t)(-2147483647-1)) 00174 #endif 00175 00176 #ifndef INT8_MAX 00177 00178 # define INT8_MAX ((int8_t)(127)) 00179 #endif 00180 #ifndef INT16_MAX 00181 00182 # define INT16_MAX ((int16_t)(32767)) 00183 #endif 00184 #ifndef INT32_MAX 00185 00186 # define INT32_MAX ((int32_t)(2147483647)) 00187 #endif 00188 00189 #ifndef UINT8_MAX 00190 00191 # define UINT8_MAX ((uint8_t)(255U)) 00192 #endif 00193 #ifndef UINT16_MAX 00194 00195 # define UINT16_MAX ((uint16_t)(65535U)) 00196 #endif 00197 #ifndef UINT32_MAX 00198 00199 # define UINT32_MAX ((uint32_t)(4294967295U)) 00200 #endif 00201 00202 #if defined(U_INT64_T_UNAVAILABLE) 00203 # error int64_t is required for decimal format and rule-based number format. 00204 #else 00205 # ifndef INT64_C 00206 00211 # define INT64_C(c) c ## LL 00212 # endif 00213 # ifndef UINT64_C 00214 00219 # define UINT64_C(c) c ## ULL 00220 # endif 00221 # ifndef U_INT64_MIN 00222 00223 # define U_INT64_MIN ((int64_t)(INT64_C(-9223372036854775807)-1)) 00224 # endif 00225 # ifndef U_INT64_MAX 00226 00227 # define U_INT64_MAX ((int64_t)(INT64_C(9223372036854775807))) 00228 # endif 00229 # ifndef U_UINT64_MAX 00230 00231 # define U_UINT64_MAX ((uint64_t)(UINT64_C(18446744073709551615))) 00232 # endif 00233 #endif 00234 00235 /*==========================================================================*/ 00236 /* Boolean data type */ 00237 /*==========================================================================*/ 00238 00247 typedef int8_t UBool; 00248 00261 #ifdef U_DEFINE_FALSE_AND_TRUE 00262 // Use the predefined value. 00263 #else 00264 // Default to avoiding collision with non-macro definitions of FALSE & TRUE. 00265 # define U_DEFINE_FALSE_AND_TRUE 0 00266 #endif 00267 00268 #if U_DEFINE_FALSE_AND_TRUE || defined(U_IN_DOXYGEN) 00269 #ifndef TRUE 00270 00275 # define TRUE 1 00276 #endif 00277 #ifndef FALSE 00278 00283 # define FALSE 0 00284 #endif 00285 #endif // U_DEFINE_FALSE_AND_TRUE 00286 00287 /*==========================================================================*/ 00288 /* Unicode data types */ 00289 /*==========================================================================*/ 00290 00291 /* wchar_t-related definitions -------------------------------------------- */ 00292 00293 /* 00294 * \def U_WCHAR_IS_UTF16 00295 * Defined if wchar_t uses UTF-16. 00296 * 00297 * @stable ICU 2.0 00298 */ 00299 /* 00300 * \def U_WCHAR_IS_UTF32 00301 * Defined if wchar_t uses UTF-32. 00302 * 00303 * @stable ICU 2.0 00304 */ 00305 #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32) 00306 # ifdef __STDC_ISO_10646__ 00307 # if (U_SIZEOF_WCHAR_T==2) 00308 # define U_WCHAR_IS_UTF16 00309 # elif (U_SIZEOF_WCHAR_T==4) 00310 # define U_WCHAR_IS_UTF32 00311 # endif 00312 # elif defined __UCS2__ 00313 # if (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400) && (U_SIZEOF_WCHAR_T==2) 00314 # define U_WCHAR_IS_UTF16 00315 # endif 00316 # elif defined(__UCS4__) || (U_PLATFORM == U_PF_OS400 && defined(__UTF32__)) 00317 # if (U_SIZEOF_WCHAR_T==4) 00318 # define U_WCHAR_IS_UTF32 00319 # endif 00320 # elif U_PLATFORM_IS_DARWIN_BASED || (U_SIZEOF_WCHAR_T==4 && U_PLATFORM_IS_LINUX_BASED) 00321 # define U_WCHAR_IS_UTF32 00322 # elif U_PLATFORM_HAS_WIN32_API 00323 # define U_WCHAR_IS_UTF16 00324 # endif 00325 #endif 00326 00327 /* UChar and UChar32 definitions -------------------------------------------- */ 00328 00330 #define U_SIZEOF_UCHAR 2 00331 00337 #if defined(_MSC_VER) && (_MSC_VER < 1900) 00338 // Versions of Visual Studio/MSVC below 2015 do not support char16_t as a real type, 00339 // and instead use a typedef. https://msdn.microsoft.com/library/bb531344.aspx 00340 # define U_CHAR16_IS_TYPEDEF 1 00341 #else 00342 # define U_CHAR16_IS_TYPEDEF 0 00343 #endif 00344 00345 00370 #if 1 00371 // #if 1 is normal. UChar defaults to char16_t in C++. 00372 // For configuration testing of UChar=uint16_t temporarily change this to #if 0. 00373 // The intltest Makefile #defines UCHAR_TYPE=char16_t, 00374 // so we only #define it to uint16_t if it is undefined so far. 00375 #elif !defined(UCHAR_TYPE) 00376 # define UCHAR_TYPE uint16_t 00377 #endif 00378 00379 #if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || \ 00380 defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) 00381 // Inside the ICU library code, never configurable. 00382 typedef char16_t UChar; 00383 #elif defined(UCHAR_TYPE) 00384 typedef UCHAR_TYPE UChar; 00385 #elif U_CPLUSPLUS_VERSION != 0 00386 typedef char16_t UChar; // C++ 00387 #else 00388 typedef uint16_t UChar; // C 00389 #endif 00390 00410 #if U_SIZEOF_WCHAR_T==2 00411 typedef wchar_t OldUChar; 00412 #elif defined(__CHAR16_TYPE__) 00413 typedef __CHAR16_TYPE__ OldUChar; 00414 #else 00415 typedef uint16_t OldUChar; 00416 #endif 00417 00435 typedef int32_t UChar32; 00436 00455 #define U_SENTINEL (-1) 00456 00457 #include "unicode/urename.h" 00458 00459 #endif
1.7.6.1