2000-02-03 19:54:49 +00:00
|
|
|
/*
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
2000-02-03 19:54:49 +00:00
|
|
|
*
|
2012-02-20 04:28:17 +00:00
|
|
|
* Copyright (C) 1999-2012, International Business Machines
|
2000-02-03 19:54:49 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
2000-02-03 19:54:49 +00:00
|
|
|
* file name: umachine.h
|
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:4
|
|
|
|
*
|
|
|
|
* created on: 1999sep13
|
|
|
|
* created by: Markus W. Scherer
|
|
|
|
*
|
|
|
|
* This file defines basic types and constants for utf.h to be
|
|
|
|
* platform-independent. umachine.h and utf.h are included into
|
|
|
|
* utypes.h to provide all the general definitions for ICU.
|
|
|
|
* All of these definitions used to be in utypes.h before
|
|
|
|
* the UTF-handling macros made this unmaintainable.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UMACHINE_H__
|
|
|
|
#define __UMACHINE_H__
|
|
|
|
|
2001-09-18 21:37:01 +00:00
|
|
|
|
2000-12-08 18:43:57 +00:00
|
|
|
/**
|
|
|
|
* \file
|
2008-08-14 19:51:09 +00:00
|
|
|
* \brief Basic types and constants for UTF
|
|
|
|
*
|
2000-12-08 18:43:57 +00:00
|
|
|
* <h2> Basic types and constants for UTF </h2>
|
|
|
|
* This file defines basic types and constants for utf.h to be
|
|
|
|
* platform-independent. umachine.h and utf.h are included into
|
|
|
|
* utypes.h to provide all the general definitions for ICU.
|
|
|
|
* All of these definitions used to be in utypes.h before
|
|
|
|
* the UTF-handling macros made this unmaintainable.
|
2008-08-14 19:51:09 +00:00
|
|
|
*
|
2000-12-08 18:43:57 +00:00
|
|
|
*/
|
2001-03-21 20:44:20 +00:00
|
|
|
/*==========================================================================*/
|
|
|
|
/* Include platform-dependent definitions */
|
|
|
|
/* which are contained in the platform-specific file platform.h */
|
|
|
|
/*==========================================================================*/
|
2000-02-03 19:54:49 +00:00
|
|
|
|
2011-07-23 00:10:30 +00:00
|
|
|
#include "unicode/ptypes.h" /* platform.h is included in ptypes.h */
|
2000-02-03 19:54:49 +00:00
|
|
|
|
2004-06-03 21:37:47 +00:00
|
|
|
/*
|
|
|
|
* ANSI C headers:
|
|
|
|
* stddef.h defines wchar_t
|
|
|
|
*/
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2002-12-12 01:25:55 +00:00
|
|
|
/*==========================================================================*/
|
2004-03-26 19:42:04 +00:00
|
|
|
/* For C wrappers, we use the symbol U_STABLE. */
|
2002-12-12 01:25:55 +00:00
|
|
|
/* This works properly if the includer is C or C++. */
|
2004-03-26 19:42:04 +00:00
|
|
|
/* Functions are declared U_STABLE return-type U_EXPORT2 function-name()... */
|
2002-12-12 01:25:55 +00:00
|
|
|
/*==========================================================================*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \def U_CFUNC
|
|
|
|
* This is used in a declaration of a library private ICU C function.
|
|
|
|
* @stable ICU 2.4
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \def U_CDECL_BEGIN
|
|
|
|
* This is used to begin a declaration of a library private ICU C API.
|
|
|
|
* @stable ICU 2.4
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \def U_CDECL_END
|
2008-08-14 19:51:09 +00:00
|
|
|
* This is used to end a declaration of a library private ICU C API
|
2002-12-12 01:25:55 +00:00
|
|
|
* @stable ICU 2.4
|
|
|
|
*/
|
2000-02-03 19:54:49 +00:00
|
|
|
|
2011-07-23 00:10:30 +00:00
|
|
|
#ifdef __cplusplus
|
2000-02-03 19:54:49 +00:00
|
|
|
# define U_CFUNC extern "C"
|
|
|
|
# define U_CDECL_BEGIN extern "C" {
|
|
|
|
# define U_CDECL_END }
|
|
|
|
#else
|
2000-07-12 06:34:43 +00:00
|
|
|
# define U_CFUNC extern
|
2000-02-03 19:54:49 +00:00
|
|
|
# define U_CDECL_BEGIN
|
|
|
|
# define U_CDECL_END
|
|
|
|
#endif
|
|
|
|
|
2011-06-10 18:56:08 +00:00
|
|
|
#ifndef U_ATTRIBUTE_DEPRECATED
|
2010-02-04 20:32:21 +00:00
|
|
|
/**
|
|
|
|
* \def U_ATTRIBUTE_DEPRECATED
|
|
|
|
* This is used for GCC specific attributes
|
|
|
|
* @internal
|
|
|
|
*/
|
2012-08-27 23:15:08 +00:00
|
|
|
#if U_GCC_MAJOR_MINOR >= 302
|
2008-08-15 21:53:53 +00:00
|
|
|
# define U_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))
|
2010-02-04 20:32:21 +00:00
|
|
|
/**
|
|
|
|
* \def U_ATTRIBUTE_DEPRECATED
|
|
|
|
* This is used for Visual C++ specific attributes
|
|
|
|
* @internal
|
|
|
|
*/
|
2011-07-23 00:10:30 +00:00
|
|
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
2008-08-15 21:53:53 +00:00
|
|
|
# define U_ATTRIBUTE_DEPRECATED __declspec(deprecated)
|
2008-08-14 19:51:09 +00:00
|
|
|
#else
|
2008-08-15 21:53:53 +00:00
|
|
|
# define U_ATTRIBUTE_DEPRECATED
|
2008-08-14 19:51:09 +00:00
|
|
|
#endif
|
2011-06-10 18:56:08 +00:00
|
|
|
#endif
|
|
|
|
|
2002-12-12 01:25:55 +00:00
|
|
|
/** This is used to declare a function as a public ICU C API @stable ICU 2.0*/
|
2001-10-08 23:26:58 +00:00
|
|
|
#define U_CAPI U_CFUNC U_EXPORT
|
2008-09-27 01:12:32 +00:00
|
|
|
/** This is used to declare a function as a stable public ICU C API*/
|
2004-03-26 19:42:04 +00:00
|
|
|
#define U_STABLE U_CAPI
|
2008-09-27 01:12:32 +00:00
|
|
|
/** This is used to declare a function as a draft public ICU C API */
|
2004-03-26 19:42:04 +00:00
|
|
|
#define U_DRAFT U_CAPI
|
2008-09-27 01:12:32 +00:00
|
|
|
/** This is used to declare a function as a deprecated public ICU C API */
|
2008-08-15 21:53:53 +00:00
|
|
|
#define U_DEPRECATED U_CAPI U_ATTRIBUTE_DEPRECATED
|
2008-09-27 01:12:32 +00:00
|
|
|
/** This is used to declare a function as an obsolete public ICU C API */
|
2004-03-26 19:42:04 +00:00
|
|
|
#define U_OBSOLETE U_CAPI
|
2008-09-27 01:12:32 +00:00
|
|
|
/** This is used to declare a function as an internal ICU C API */
|
2004-06-12 00:56:53 +00:00
|
|
|
#define U_INTERNAL U_CAPI
|
2002-12-12 01:25:55 +00:00
|
|
|
|
|
|
|
/*==========================================================================*/
|
|
|
|
/* limits for int32_t etc., like in POSIX inttypes.h */
|
|
|
|
/*==========================================================================*/
|
2000-03-30 01:12:01 +00:00
|
|
|
|
|
|
|
#ifndef INT8_MIN
|
2002-12-12 01:25:55 +00:00
|
|
|
/** The smallest value an 8 bit signed integer can hold @stable ICU 2.0 */
|
2000-08-30 23:25:59 +00:00
|
|
|
# define INT8_MIN ((int8_t)(-128))
|
2000-03-30 01:12:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef INT16_MIN
|
2002-12-12 01:25:55 +00:00
|
|
|
/** The smallest value a 16 bit signed integer can hold @stable ICU 2.0 */
|
2000-08-30 23:25:59 +00:00
|
|
|
# define INT16_MIN ((int16_t)(-32767-1))
|
2000-03-30 01:12:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef INT32_MIN
|
2002-12-12 01:25:55 +00:00
|
|
|
/** The smallest value a 32 bit signed integer can hold @stable ICU 2.0 */
|
2000-08-30 23:25:59 +00:00
|
|
|
# define INT32_MIN ((int32_t)(-2147483647-1))
|
2000-03-30 01:12:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef INT8_MAX
|
2002-12-12 01:25:55 +00:00
|
|
|
/** The largest value an 8 bit signed integer can hold @stable ICU 2.0 */
|
2000-08-30 23:25:59 +00:00
|
|
|
# define INT8_MAX ((int8_t)(127))
|
2000-03-30 01:12:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef INT16_MAX
|
2002-12-12 01:25:55 +00:00
|
|
|
/** The largest value a 16 bit signed integer can hold @stable ICU 2.0 */
|
2000-08-30 23:25:59 +00:00
|
|
|
# define INT16_MAX ((int16_t)(32767))
|
2000-03-30 01:12:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef INT32_MAX
|
2002-12-12 01:25:55 +00:00
|
|
|
/** The largest value a 32 bit signed integer can hold @stable ICU 2.0 */
|
2000-08-30 23:25:59 +00:00
|
|
|
# define INT32_MAX ((int32_t)(2147483647))
|
2000-03-30 01:12:01 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef UINT8_MAX
|
2002-12-12 01:25:55 +00:00
|
|
|
/** The largest value an 8 bit unsigned integer can hold @stable ICU 2.0 */
|
2000-08-30 23:25:59 +00:00
|
|
|
# define UINT8_MAX ((uint8_t)(255U))
|
2000-03-30 01:12:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef UINT16_MAX
|
2002-12-12 01:25:55 +00:00
|
|
|
/** The largest value a 16 bit unsigned integer can hold @stable ICU 2.0 */
|
2000-08-30 23:25:59 +00:00
|
|
|
# define UINT16_MAX ((uint16_t)(65535U))
|
2000-03-30 01:12:01 +00:00
|
|
|
#endif
|
|
|
|
#ifndef UINT32_MAX
|
2002-12-12 01:25:55 +00:00
|
|
|
/** The largest value a 32 bit unsigned integer can hold @stable ICU 2.0 */
|
2000-08-30 23:25:59 +00:00
|
|
|
# define UINT32_MAX ((uint32_t)(4294967295U))
|
2000-03-30 01:12:01 +00:00
|
|
|
#endif
|
|
|
|
|
2002-12-12 01:25:55 +00:00
|
|
|
#if defined(U_INT64_T_UNAVAILABLE)
|
2003-11-05 01:49:45 +00:00
|
|
|
# error int64_t is required for decimal format and rule-based number format.
|
2002-12-12 01:25:55 +00:00
|
|
|
#else
|
2003-11-05 01:49:45 +00:00
|
|
|
# ifndef INT64_C
|
2003-11-24 19:59:15 +00:00
|
|
|
/**
|
|
|
|
* Provides a platform independent way to specify a signed 64-bit integer constant.
|
|
|
|
* note: may be wrong for some 64 bit platforms - ensure your compiler provides INT64_C
|
2005-06-22 23:38:06 +00:00
|
|
|
* @stable ICU 2.8
|
2003-11-24 19:59:15 +00:00
|
|
|
*/
|
2003-11-05 01:49:45 +00:00
|
|
|
# define INT64_C(c) c ## LL
|
|
|
|
# endif
|
|
|
|
# ifndef UINT64_C
|
2003-11-24 19:59:15 +00:00
|
|
|
/**
|
|
|
|
* Provides a platform independent way to specify an unsigned 64-bit integer constant.
|
|
|
|
* note: may be wrong for some 64 bit platforms - ensure your compiler provides UINT64_C
|
2005-06-22 23:38:06 +00:00
|
|
|
* @stable ICU 2.8
|
2003-11-24 19:59:15 +00:00
|
|
|
*/
|
2003-11-05 01:49:45 +00:00
|
|
|
# define UINT64_C(c) c ## ULL
|
|
|
|
# endif
|
|
|
|
# ifndef U_INT64_MIN
|
2003-11-24 19:59:15 +00:00
|
|
|
/** The smallest value a 64 bit signed integer can hold @stable ICU 2.8 */
|
2003-11-05 01:49:45 +00:00
|
|
|
# define U_INT64_MIN ((int64_t)(INT64_C(-9223372036854775807)-1))
|
|
|
|
# endif
|
|
|
|
# ifndef U_INT64_MAX
|
2003-11-24 19:59:15 +00:00
|
|
|
/** The largest value a 64 bit signed integer can hold @stable ICU 2.8 */
|
2003-11-05 01:49:45 +00:00
|
|
|
# define U_INT64_MAX ((int64_t)(INT64_C(9223372036854775807)))
|
|
|
|
# endif
|
|
|
|
# ifndef U_UINT64_MAX
|
2003-11-24 19:59:15 +00:00
|
|
|
/** The largest value a 64 bit unsigned integer can hold @stable ICU 2.8 */
|
2003-11-05 01:49:45 +00:00
|
|
|
# define U_UINT64_MAX ((uint64_t)(UINT64_C(18446744073709551615)))
|
|
|
|
# endif
|
2000-03-30 21:30:21 +00:00
|
|
|
#endif
|
|
|
|
|
2002-12-12 01:25:55 +00:00
|
|
|
/*==========================================================================*/
|
|
|
|
/* Boolean data type */
|
|
|
|
/*==========================================================================*/
|
2000-02-03 19:54:49 +00:00
|
|
|
|
2002-12-12 01:25:55 +00:00
|
|
|
/** The ICU boolean type @stable ICU 2.0 */
|
2000-05-18 22:08:39 +00:00
|
|
|
typedef int8_t UBool;
|
|
|
|
|
2000-02-03 19:54:49 +00:00
|
|
|
#ifndef TRUE
|
2002-12-12 01:25:55 +00:00
|
|
|
/** The TRUE value of a UBool @stable ICU 2.0 */
|
2000-02-03 19:54:49 +00:00
|
|
|
# define TRUE 1
|
|
|
|
#endif
|
|
|
|
#ifndef FALSE
|
2002-12-12 01:25:55 +00:00
|
|
|
/** The FALSE value of a UBool @stable ICU 2.0 */
|
2000-02-03 19:54:49 +00:00
|
|
|
# define FALSE 0
|
|
|
|
#endif
|
|
|
|
|
2001-05-08 17:02:18 +00:00
|
|
|
|
2004-06-03 21:37:47 +00:00
|
|
|
/*==========================================================================*/
|
|
|
|
/* Unicode data types */
|
|
|
|
/*==========================================================================*/
|
|
|
|
|
|
|
|
/* wchar_t-related definitions -------------------------------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* \def U_WCHAR_IS_UTF16
|
|
|
|
* Defined if wchar_t uses UTF-16.
|
|
|
|
*
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* \def U_WCHAR_IS_UTF32
|
|
|
|
* Defined if wchar_t uses UTF-32.
|
|
|
|
*
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
|
|
|
#if !defined(U_WCHAR_IS_UTF16) && !defined(U_WCHAR_IS_UTF32)
|
2008-08-14 19:51:09 +00:00
|
|
|
# ifdef __STDC_ISO_10646__
|
2004-06-03 21:37:47 +00:00
|
|
|
# if (U_SIZEOF_WCHAR_T==2)
|
|
|
|
# define U_WCHAR_IS_UTF16
|
|
|
|
# elif (U_SIZEOF_WCHAR_T==4)
|
|
|
|
# define U_WCHAR_IS_UTF32
|
|
|
|
# endif
|
|
|
|
# elif defined __UCS2__
|
2011-07-23 00:10:30 +00:00
|
|
|
# if (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400) && (U_SIZEOF_WCHAR_T==2)
|
2004-06-03 21:37:47 +00:00
|
|
|
# define U_WCHAR_IS_UTF16
|
|
|
|
# endif
|
2011-07-23 00:10:30 +00:00
|
|
|
# elif defined(__UCS4__) || (U_PLATFORM == U_PF_OS400 && defined(__UTF32__))
|
2004-06-03 21:37:47 +00:00
|
|
|
# if (U_SIZEOF_WCHAR_T==4)
|
|
|
|
# define U_WCHAR_IS_UTF32
|
|
|
|
# endif
|
2011-07-23 00:10:30 +00:00
|
|
|
# elif U_PLATFORM_IS_DARWIN_BASED || (U_SIZEOF_WCHAR_T==4 && U_PLATFORM_IS_LINUX_BASED)
|
|
|
|
# define U_WCHAR_IS_UTF32
|
|
|
|
# elif U_PLATFORM_HAS_WIN32_API
|
2008-08-14 19:51:09 +00:00
|
|
|
# define U_WCHAR_IS_UTF16
|
2004-06-03 21:37:47 +00:00
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* UChar and UChar32 definitions -------------------------------------------- */
|
|
|
|
|
|
|
|
/** Number of bytes in a UChar. @stable ICU 2.0 */
|
|
|
|
#define U_SIZEOF_UCHAR 2
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \var UChar
|
2012-11-09 17:57:46 +00:00
|
|
|
* Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t),
|
2011-07-23 00:10:30 +00:00
|
|
|
* or wchar_t if that is 16 bits wide; always assumed to be unsigned.
|
|
|
|
* If neither is available, then define UChar to be uint16_t.
|
|
|
|
*
|
2004-06-03 21:37:47 +00:00
|
|
|
* This makes the definition of UChar platform-dependent
|
|
|
|
* but allows direct string type compatibility with platforms with
|
|
|
|
* 16-bit wchar_t types.
|
|
|
|
*
|
2012-02-20 04:28:17 +00:00
|
|
|
* @stable ICU 4.4
|
2004-06-03 21:37:47 +00:00
|
|
|
*/
|
2012-11-09 17:57:46 +00:00
|
|
|
#if defined(UCHAR_TYPE)
|
|
|
|
typedef UCHAR_TYPE UChar;
|
|
|
|
/* Not #elif U_HAVE_CHAR16_T -- because that is type-incompatible with pre-C++11 callers
|
|
|
|
typedef char16_t UChar; */
|
2011-07-23 00:10:30 +00:00
|
|
|
#elif U_SIZEOF_WCHAR_T==2
|
|
|
|
typedef wchar_t UChar;
|
|
|
|
#elif defined(__CHAR16_TYPE__)
|
|
|
|
typedef __CHAR16_TYPE__ UChar;
|
2004-06-03 21:37:47 +00:00
|
|
|
#else
|
|
|
|
typedef uint16_t UChar;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define UChar32 as a type for single Unicode code points.
|
|
|
|
* UChar32 is a signed 32-bit integer (same as int32_t).
|
|
|
|
*
|
|
|
|
* The Unicode code point range is 0..0x10ffff.
|
|
|
|
* All other values (negative or >=0x110000) are illegal as Unicode code points.
|
|
|
|
* They may be used as sentinel values to indicate "done", "error"
|
|
|
|
* or similar non-code point conditions.
|
|
|
|
*
|
|
|
|
* Before ICU 2.4 (Jitterbug 2146), UChar32 was defined
|
|
|
|
* to be wchar_t if that is 32 bits wide (wchar_t may be signed or unsigned)
|
|
|
|
* or else to be uint32_t.
|
|
|
|
* That is, the definition of UChar32 was platform-dependent.
|
|
|
|
*
|
|
|
|
* @see U_SENTINEL
|
|
|
|
* @stable ICU 2.4
|
|
|
|
*/
|
|
|
|
typedef int32_t UChar32;
|
|
|
|
|
2011-07-28 18:48:08 +00:00
|
|
|
/**
|
|
|
|
* This value is intended for sentinel values for APIs that
|
|
|
|
* (take or) return single code points (UChar32).
|
|
|
|
* It is outside of the Unicode code point range 0..0x10ffff.
|
|
|
|
*
|
|
|
|
* For example, a "done" or "error" value in a new API
|
|
|
|
* could be indicated with U_SENTINEL.
|
|
|
|
*
|
|
|
|
* ICU APIs designed before ICU 2.4 usually define service-specific "done"
|
|
|
|
* values, mostly 0xffff.
|
|
|
|
* Those may need to be distinguished from
|
|
|
|
* actual U+ffff text contents by calling functions like
|
|
|
|
* CharacterIterator::hasNext() or UnicodeString::length().
|
|
|
|
*
|
|
|
|
* @return -1
|
|
|
|
* @see UChar32
|
|
|
|
* @stable ICU 2.4
|
|
|
|
*/
|
|
|
|
#define U_SENTINEL (-1)
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
#include "unicode/urename.h"
|
2001-05-08 17:02:18 +00:00
|
|
|
|
2000-02-03 19:54:49 +00:00
|
|
|
#endif
|