sl@0: /* sl@0: ****************************************************************************** sl@0: * sl@0: * Copyright (C) 1999-2005, International Business Machines sl@0: * Corporation and others. All Rights Reserved. sl@0: * sl@0: ****************************************************************************** sl@0: * file name: umachine.h sl@0: * encoding: US-ASCII sl@0: * tab size: 8 (not used) sl@0: * indentation:4 sl@0: * sl@0: * created on: 1999sep13 sl@0: * created by: Markus W. Scherer sl@0: * sl@0: * This file defines basic types and constants for utf.h to be sl@0: * platform-independent. umachine.h and utf.h are included into sl@0: * utypes.h to provide all the general definitions for ICU. sl@0: * All of these definitions used to be in utypes.h before sl@0: * the UTF-handling macros made this unmaintainable. sl@0: */ sl@0: sl@0: #ifndef __UMACHINE_H__ sl@0: #define __UMACHINE_H__ sl@0: sl@0: sl@0: /** sl@0: * \file sl@0: * \brief Basic types and constants for UTF sl@0: * sl@0: *

Basic types and constants for UTF

sl@0: * This file defines basic types and constants for utf.h to be sl@0: * platform-independent. umachine.h and utf.h are included into sl@0: * utypes.h to provide all the general definitions for ICU. sl@0: * All of these definitions used to be in utypes.h before sl@0: * the UTF-handling macros made this unmaintainable. sl@0: * sl@0: */ sl@0: /*==========================================================================*/ sl@0: /* Include platform-dependent definitions */ sl@0: /* which are contained in the platform-specific file platform.h */ sl@0: /*==========================================================================*/ sl@0: sl@0: #if defined(__SYMBIAN32__) sl@0: #include "SymbianPlatform.h" sl@0: #elif defined(U_PALMOS) sl@0: # include "unicode/ppalmos.h" sl@0: #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) sl@0: # include "unicode/pwin32.h" sl@0: #else sl@0: # include "unicode/platform.h" sl@0: #endif sl@0: sl@0: /* sl@0: * ANSI C headers: sl@0: * stddef.h defines wchar_t sl@0: */ sl@0: #include sl@0: sl@0: /*==========================================================================*/ sl@0: /* XP_CPLUSPLUS is a cross-platform symbol which should be defined when */ sl@0: /* using C++. It should not be defined when compiling under C. */ sl@0: /*==========================================================================*/ sl@0: sl@0: #ifdef __cplusplus sl@0: # ifndef XP_CPLUSPLUS sl@0: # define XP_CPLUSPLUS sl@0: # endif sl@0: #else sl@0: # undef XP_CPLUSPLUS sl@0: #endif sl@0: sl@0: /*==========================================================================*/ sl@0: /* For C wrappers, we use the symbol U_STABLE. */ sl@0: /* This works properly if the includer is C or C++. */ sl@0: /* Functions are declared U_STABLE return-type U_EXPORT2 function-name()... */ sl@0: /*==========================================================================*/ sl@0: sl@0: /** sl@0: * \def U_CFUNC sl@0: * This is used in a declaration of a library private ICU C function. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: sl@0: /** sl@0: * \def U_CDECL_BEGIN sl@0: * This is used to begin a declaration of a library private ICU C API. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: sl@0: /** sl@0: * \def U_CDECL_END sl@0: * This is used to end a declaration of a library private ICU C API sl@0: * @stable ICU 2.4 sl@0: */ sl@0: sl@0: #ifdef XP_CPLUSPLUS sl@0: # define U_CFUNC extern "C" sl@0: # define U_CDECL_BEGIN extern "C" { sl@0: # define U_CDECL_END } sl@0: #else sl@0: # define U_CFUNC extern sl@0: # define U_CDECL_BEGIN sl@0: # define U_CDECL_END sl@0: #endif sl@0: sl@0: /** sl@0: * \def U_NAMESPACE_BEGIN sl@0: * This is used to begin a declaration of a public ICU C++ API. sl@0: * If the compiler doesn't support namespaces, this does nothing. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: sl@0: /** sl@0: * \def U_NAMESPACE_END sl@0: * This is used to end a declaration of a public ICU C++ API sl@0: * If the compiler doesn't support namespaces, this does nothing. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: sl@0: /** sl@0: * \def U_NAMESPACE_USE sl@0: * This is used to specify that the rest of the code uses the sl@0: * public ICU C++ API namespace. sl@0: * If the compiler doesn't support namespaces, this does nothing. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: sl@0: /** sl@0: * \def U_NAMESPACE_QUALIFIER sl@0: * This is used to qualify that a function or class is part of sl@0: * the public ICU C++ API namespace. sl@0: * If the compiler doesn't support namespaces, this does nothing. sl@0: * @stable ICU 2.4 sl@0: */ sl@0: sl@0: /* Define namespace symbols if the compiler supports it. */ sl@0: #if U_HAVE_NAMESPACE sl@0: # define U_NAMESPACE_BEGIN namespace U_ICU_NAMESPACE { sl@0: # define U_NAMESPACE_END } sl@0: # define U_NAMESPACE_USE using namespace U_ICU_NAMESPACE; sl@0: # define U_NAMESPACE_QUALIFIER U_ICU_NAMESPACE:: sl@0: #else sl@0: # define U_NAMESPACE_BEGIN sl@0: # define U_NAMESPACE_END sl@0: # define U_NAMESPACE_USE sl@0: # define U_NAMESPACE_QUALIFIER sl@0: #endif sl@0: sl@0: /** This is used to declare a function as a public ICU C API @stable ICU 2.0*/ sl@0: #define U_CAPI U_CFUNC U_EXPORT sl@0: #define U_STABLE U_CAPI sl@0: #define U_DRAFT U_CAPI sl@0: #define U_DEPRECATED U_CAPI sl@0: #define U_OBSOLETE U_CAPI sl@0: #define U_INTERNAL U_CAPI sl@0: sl@0: /*==========================================================================*/ sl@0: /* limits for int32_t etc., like in POSIX inttypes.h */ sl@0: /*==========================================================================*/ sl@0: sl@0: #ifndef INT8_MIN sl@0: /** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */ sl@0: # define INT8_MIN ((int8_t)(-128)) sl@0: #endif sl@0: #ifndef INT16_MIN sl@0: /** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */ sl@0: # define INT16_MIN ((int16_t)(-32767-1)) sl@0: #endif sl@0: #ifndef INT32_MIN sl@0: /** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */ sl@0: # define INT32_MIN ((int32_t)(-2147483647-1)) sl@0: #endif sl@0: sl@0: #ifndef INT8_MAX sl@0: /** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */ sl@0: # define INT8_MAX ((int8_t)(127)) sl@0: #endif sl@0: #ifndef INT16_MAX sl@0: /** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */ sl@0: # define INT16_MAX ((int16_t)(32767)) sl@0: #endif sl@0: #ifndef INT32_MAX sl@0: /** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */ sl@0: # define INT32_MAX ((int32_t)(2147483647)) sl@0: #endif sl@0: sl@0: #ifndef UINT8_MAX sl@0: /** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */ sl@0: # define UINT8_MAX ((uint8_t)(255U)) sl@0: #endif sl@0: #ifndef UINT16_MAX sl@0: /** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */ sl@0: # define UINT16_MAX ((uint16_t)(65535U)) sl@0: #endif sl@0: #ifndef UINT32_MAX sl@0: /** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */ sl@0: # define UINT32_MAX ((uint32_t)(4294967295U)) sl@0: #endif sl@0: sl@0: #if defined(U_INT64_T_UNAVAILABLE) sl@0: # error int64_t is required for decimal format and rule-based number format. sl@0: #else sl@0: # ifndef INT64_C sl@0: /** sl@0: * Provides a platform independent way to specify a signed 64-bit integer constant. sl@0: * note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C sl@0: * @stable ICU 2.8 sl@0: */ sl@0: # define INT64_C(c) c ## LL sl@0: # endif sl@0: # ifndef UINT64_C sl@0: /** sl@0: * Provides a platform independent way to specify an unsigned 64-bit integer constant. sl@0: * note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C sl@0: * @stable ICU 2.8 sl@0: */ sl@0: # define UINT64_C(c) c ## ULL sl@0: # endif sl@0: # ifndef U_INT64_MIN sl@0: /** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */ sl@0: # define U_INT64_MIN ((int64_t)(INT64_C(-9223372036854775807)-1)) sl@0: # endif sl@0: # ifndef U_INT64_MAX sl@0: /** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */ sl@0: # define U_INT64_MAX ((int64_t)(INT64_C(9223372036854775807))) sl@0: # endif sl@0: # ifndef U_UINT64_MAX sl@0: /** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */ sl@0: # define U_UINT64_MAX ((uint64_t)(UINT64_C(18446744073709551615))) sl@0: # endif sl@0: #endif sl@0: sl@0: /*==========================================================================*/ sl@0: /* Boolean data type */ sl@0: /*==========================================================================*/ sl@0: sl@0: /** The ICU boolean type @stable ICU 2.0 */ sl@0: typedef int8_t UBool; sl@0: sl@0: #ifndef TRUE sl@0: /** The TRUE value of a UBool @stable ICU 2.0 */ sl@0: # define TRUE 1 sl@0: #endif sl@0: #ifndef FALSE sl@0: /** The FALSE value of a UBool @stable ICU 2.0 */ sl@0: # define FALSE 0 sl@0: #endif sl@0: sl@0: sl@0: /*==========================================================================*/ sl@0: /* Unicode data types */ sl@0: /*==========================================================================*/ sl@0: sl@0: /* wchar_t-related definitions -------------------------------------------- */ sl@0: sl@0: /** sl@0: * \def U_HAVE_WCHAR_H sl@0: * Indicates whether is available (1) or not (0). Set to 1 by default. sl@0: * sl@0: * @stable ICU 2.0 sl@0: */ sl@0: #ifndef U_HAVE_WCHAR_H sl@0: # define U_HAVE_WCHAR_H 1 sl@0: #endif sl@0: sl@0: /** sl@0: * \def U_SIZEOF_WCHAR_T sl@0: * U_SIZEOF_WCHAR_T==sizeof(wchar_t) (0 means it is not defined or autoconf could not set it) sl@0: * sl@0: * @stable ICU 2.0 sl@0: */ sl@0: #if U_SIZEOF_WCHAR_T==0 sl@0: # undef U_SIZEOF_WCHAR_T sl@0: # define U_SIZEOF_WCHAR_T 4 sl@0: #endif sl@0: sl@0: /* sl@0: * \def U_WCHAR_IS_UTF16 sl@0: * Defined if wchar_t uses UTF-16. sl@0: * sl@0: * @stable ICU 2.0 sl@0: */ sl@0: /* sl@0: * \def U_WCHAR_IS_UTF32 sl@0: * Defined if wchar_t uses UTF-32. sl@0: * sl@0: * @stable ICU 2.0 sl@0: */ sl@0: #if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32) sl@0: # ifdef __STDC_ISO_10646__ sl@0: # if (U_SIZEOF_WCHAR_T==2) sl@0: # define U_WCHAR_IS_UTF16 sl@0: # elif (U_SIZEOF_WCHAR_T==4) sl@0: # define U_WCHAR_IS_UTF32 sl@0: # endif sl@0: # elif defined __UCS2__ sl@0: # if (__OS390__ || __OS400__) && (U_SIZEOF_WCHAR_T==2) sl@0: # define U_WCHAR_IS_UTF16 sl@0: # endif sl@0: # elif defined __UCS4__ sl@0: # if (U_SIZEOF_WCHAR_T==4) sl@0: # define U_WCHAR_IS_UTF32 sl@0: # endif sl@0: # elif defined(U_WINDOWS) sl@0: # define U_WCHAR_IS_UTF16 sl@0: # endif sl@0: #endif sl@0: sl@0: /* UChar and UChar32 definitions -------------------------------------------- */ sl@0: sl@0: /** Number of bytes in a UChar. @stable ICU 2.0 */ sl@0: #define U_SIZEOF_UCHAR 2 sl@0: sl@0: /** sl@0: * \var UChar sl@0: * Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned. sl@0: * If wchar_t is not 16 bits wide, then define UChar to be uint16_t. sl@0: * This makes the definition of UChar platform-dependent sl@0: * but allows direct string type compatibility with platforms with sl@0: * 16-bit wchar_t types. sl@0: * sl@0: * @stable ICU 2.0 sl@0: */ sl@0: sl@0: /* Define UChar to be compatible with wchar_t if possible. */ sl@0: #if U_SIZEOF_WCHAR_T==2 sl@0: typedef wchar_t UChar; sl@0: #else sl@0: typedef uint16_t UChar; sl@0: #endif sl@0: sl@0: /** sl@0: * Define UChar32 as a type for single Unicode code points. sl@0: * UChar32 is a signed 32-bit integer (same as int32_t). sl@0: * sl@0: * The Unicode code point range is 0..0x10ffff. sl@0: * All other values (negative or >=0x110000) are illegal as Unicode code points. sl@0: * They may be used as sentinel values to indicate "done", "error" sl@0: * or similar non-code point conditions. sl@0: * sl@0: * Before ICU 2.4 (Jitterbug 2146), UChar32 was defined sl@0: * to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned) sl@0: * or else to be uint32_t. sl@0: * That is, the definition of UChar32 was platform-dependent. sl@0: * sl@0: * @see U_SENTINEL sl@0: * @stable ICU 2.4 sl@0: */ sl@0: typedef int32_t UChar32; sl@0: sl@0: /*==========================================================================*/ sl@0: /* U_INLINE and U_ALIGN_CODE Set default values if these are not already */ sl@0: /* defined. Definitions normally are in */ sl@0: /* platform.h or the corresponding file for */ sl@0: /* the OS in use. */ sl@0: /*==========================================================================*/ sl@0: sl@0: /** sl@0: * \def U_ALIGN_CODE sl@0: * This is used to align code fragments to a specific byte boundary. sl@0: * This is useful for getting consistent performance test results. sl@0: * @internal sl@0: */ sl@0: #ifndef U_ALIGN_CODE sl@0: # define U_ALIGN_CODE(n) sl@0: #endif sl@0: sl@0: #ifndef U_INLINE sl@0: # ifdef XP_CPLUSPLUS sl@0: # define U_INLINE inline sl@0: # else sl@0: # define U_INLINE sl@0: # endif sl@0: #endif sl@0: sl@0: #include "unicode/urename.h" sl@0: sl@0: #endif