2004-12-18 09:16:31 +00:00
|
|
|
/*
|
2006-06-09 06:17:24 +00:00
|
|
|
* $Id: types.h,v 1.49 2006-06-09 06:17:24 bacon Exp $
|
2004-12-18 09:16:31 +00:00
|
|
|
*/
|
|
|
|
|
2004-12-18 09:58:49 +00:00
|
|
|
#ifndef _XP_TYPES_H_
|
|
|
|
#define _XP_TYPES_H_
|
2004-12-18 09:16:31 +00:00
|
|
|
|
2005-08-07 11:17:23 +00:00
|
|
|
#if defined(_WIN32)
|
2006-04-14 15:08:37 +00:00
|
|
|
#include <xp/conf_msw.h>
|
2006-01-08 13:34:41 +00:00
|
|
|
#elif defined(vms) || defined(__vms)
|
2005-05-20 04:01:12 +00:00
|
|
|
#include <xp/conf_vms.h>
|
2006-04-30 17:35:37 +00:00
|
|
|
#elif defined(dos) || defined(__dos)
|
|
|
|
#include <xp/conf_dos.h>
|
2005-03-29 10:09:27 +00:00
|
|
|
#else
|
|
|
|
#include <xp/config.h>
|
|
|
|
#endif
|
2005-02-13 16:15:31 +00:00
|
|
|
|
2005-09-17 17:42:21 +00:00
|
|
|
/*
|
2005-09-20 04:07:40 +00:00
|
|
|
* NOTE: Data Types
|
2005-09-19 14:57:09 +00:00
|
|
|
* Various basic data types are predefined for convenience sake and used
|
|
|
|
* constantly thoughout the entire toolkit. The developers are strongly
|
2005-09-19 14:24:38 +00:00
|
|
|
* encouraged to use these data types rather than built-in data types
|
2005-09-19 14:57:09 +00:00
|
|
|
* supported by compilers.
|
2005-09-19 14:24:38 +00:00
|
|
|
*
|
2005-09-19 14:57:09 +00:00
|
|
|
* NOTE: Availabilty
|
2005-09-19 14:24:38 +00:00
|
|
|
* Some of the data types may or may not be available depending on
|
2005-09-19 14:57:09 +00:00
|
|
|
* the capability of the compiler.
|
2005-09-17 17:42:21 +00:00
|
|
|
*
|
|
|
|
* GROUP: State Types
|
|
|
|
*
|
|
|
|
* TYPE: xp_bool_t
|
|
|
|
* Boolean type
|
|
|
|
*
|
|
|
|
* TYPE: xp_tri_t
|
|
|
|
* Tri-State type
|
|
|
|
*
|
|
|
|
* GROUP: Integral Types
|
|
|
|
*
|
|
|
|
* TYPE: xp_byte_t
|
2005-09-19 14:24:38 +00:00
|
|
|
*
|
|
|
|
* TYPE: xp_word_t
|
2005-09-17 17:42:21 +00:00
|
|
|
*
|
|
|
|
* TYPE: xp_int_t
|
2005-09-19 14:24:38 +00:00
|
|
|
* Signed integer whose size equals the size of a pointer
|
2005-09-17 17:42:21 +00:00
|
|
|
*
|
|
|
|
* TYPE: xp_uint_t
|
2005-09-19 14:24:38 +00:00
|
|
|
* Unsigned integer whose size equals the size of a pointer
|
2005-09-17 17:42:21 +00:00
|
|
|
*
|
|
|
|
* TYPE: xp_long_t
|
2005-09-19 14:24:38 +00:00
|
|
|
* The largest signed integer available
|
2005-09-17 17:42:21 +00:00
|
|
|
*
|
|
|
|
* TYPE: xp_ulong_t
|
2005-09-19 14:24:38 +00:00
|
|
|
* The largest unsigned integer available
|
2005-09-17 17:42:21 +00:00
|
|
|
*
|
2005-09-19 14:24:38 +00:00
|
|
|
* TYPE: xp_size_t
|
|
|
|
* Unsigned integer which can represent the size of the largest
|
|
|
|
* in-memory data
|
|
|
|
*
|
|
|
|
* TYPE: xp_ssize_t
|
|
|
|
* Signed version of xp_size_t
|
|
|
|
*
|
2005-09-17 17:42:21 +00:00
|
|
|
* TYPE: xp_int8_t
|
|
|
|
*
|
|
|
|
* TYPE: xp_uint8_t
|
|
|
|
*
|
|
|
|
* TYPE: xp_int16_t
|
|
|
|
*
|
|
|
|
* TYPE: xp_uint16_t
|
|
|
|
*
|
|
|
|
* TYPE: xp_int32_t
|
|
|
|
*
|
|
|
|
* TYPE: xp_uint32_t
|
|
|
|
*
|
|
|
|
* TYPE: xp_int64_t
|
|
|
|
*
|
|
|
|
* TYPE: xp_uint64_t
|
|
|
|
*/
|
|
|
|
|
2005-05-04 04:33:42 +00:00
|
|
|
/* boolean type */
|
2005-08-02 11:09:04 +00:00
|
|
|
/*
|
2005-03-21 08:24:07 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
typedef bool xp_bool_t;
|
|
|
|
#define xp_true true
|
|
|
|
#define xp_false false
|
|
|
|
#else
|
2005-08-02 11:09:04 +00:00
|
|
|
*/
|
2005-03-21 08:24:07 +00:00
|
|
|
typedef int xp_bool_t;
|
|
|
|
#define xp_true (0 == 0)
|
|
|
|
#define xp_false (0 != 0)
|
2005-08-02 11:09:04 +00:00
|
|
|
/*#endif*/
|
2005-02-14 03:13:32 +00:00
|
|
|
|
2005-05-04 04:33:42 +00:00
|
|
|
/* tri-state type */
|
|
|
|
typedef int xp_tri_t;
|
|
|
|
#define xp_alive 1
|
|
|
|
#define xp_zombie 0
|
|
|
|
#define xp_dead -1
|
|
|
|
|
2005-02-14 03:13:32 +00:00
|
|
|
/* integer that can hold a pointer */
|
2006-04-14 14:17:09 +00:00
|
|
|
#if XP_SIZEOF_VOID_P == XP_SIZEOF_LONG_LONG
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef long long xp_int_t;
|
|
|
|
typedef unsigned long long xp_uint_t;
|
2006-04-14 14:17:09 +00:00
|
|
|
#elif XP_SIZEOF_VOID_P == XP_SIZEOF_LONG
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef long xp_int_t;
|
|
|
|
typedef unsigned long xp_uint_t;
|
2005-02-13 16:15:31 +00:00
|
|
|
#else
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef int xp_int_t;
|
|
|
|
typedef unsigned int xp_uint_t;
|
2005-02-13 16:15:31 +00:00
|
|
|
#endif
|
|
|
|
|
2005-02-14 03:13:32 +00:00
|
|
|
/* the largest integer supported by the system */
|
2006-04-14 14:17:09 +00:00
|
|
|
#if XP_SIZEOF_LONG_LONG != 0
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef long long xp_long_t;
|
|
|
|
typedef unsigned long long xp_ulong_t;
|
2006-04-14 14:17:09 +00:00
|
|
|
#elif XP_SIZEOF___INT64 != 0
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef __int64 xp_long_t;
|
|
|
|
typedef unsigned __int64 xp_ulong_t;
|
|
|
|
#else
|
|
|
|
typedef long xp_long_t;
|
|
|
|
typedef unsigned long xp_ulong_t;
|
2005-02-13 16:15:31 +00:00
|
|
|
#endif
|
|
|
|
|
2005-02-14 03:13:32 +00:00
|
|
|
/* integers of specific size */
|
2006-04-14 14:17:09 +00:00
|
|
|
#if XP_SIZEOF_CHAR == 1
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef char xp_int8_t;
|
|
|
|
typedef unsigned char xp_uint8_t;
|
2006-04-14 14:17:09 +00:00
|
|
|
#elif XP_SIZEOF___INT8 == 1
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef __int8 xp_int8_t;
|
|
|
|
typedef unsigned __int8 xp_uint8_t;
|
2005-02-13 16:15:31 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-14 14:17:09 +00:00
|
|
|
#if XP_SIZEOF_SHORT == 2
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef short xp_int16_t;
|
|
|
|
typedef unsigned short xp_uint16_t;
|
2006-04-14 14:17:09 +00:00
|
|
|
#elif XP_SIZEOF___INT16 == 2
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef __int16 xp_int16_t;
|
|
|
|
typedef unsigned __int16 xp_uint16_t;
|
2005-02-13 16:15:31 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-14 14:17:09 +00:00
|
|
|
#if XP_SIZEOF_INT == 4
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef int xp_int32_t;
|
|
|
|
typedef unsigned int xp_uint32_t;
|
2006-04-14 14:17:09 +00:00
|
|
|
#elif XP_SIZEOF_LONG == 4
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef long xp_int32_t;
|
|
|
|
typedef unsigned long xp_uint32_t;
|
2006-04-14 14:17:09 +00:00
|
|
|
#elif XP_SIZEOF___INT32 == 4
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef __int32 xp_int32_t;
|
|
|
|
typedef unsigned __int32 xp_uint32_t;
|
2005-02-13 16:15:31 +00:00
|
|
|
#endif
|
|
|
|
|
2006-04-14 14:17:09 +00:00
|
|
|
#if XP_SIZEOF_INT == 8
|
2005-08-15 04:14:54 +00:00
|
|
|
#define XP_HAVE_INT64_T
|
|
|
|
#define XP_HAVE_UINT64_T
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef int xp_int64_t;
|
|
|
|
typedef unsigned int xp_uint64_t;
|
2006-04-14 14:17:09 +00:00
|
|
|
#elif XP_SIZEOF_LONG == 8
|
2005-08-15 04:14:54 +00:00
|
|
|
#define XP_HAVE_INT64_T
|
|
|
|
#define XP_HAVE_UINT64_T
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef long xp_int64_t;
|
|
|
|
typedef unsigned long xp_uint64_t;
|
2006-04-14 14:17:09 +00:00
|
|
|
#elif XP_SIZEOF_LONG_LONG == 8
|
2005-08-15 04:14:54 +00:00
|
|
|
#define XP_HAVE_INT64_T
|
|
|
|
#define XP_HAVE_UINT64_T
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef long long xp_int64_t;
|
|
|
|
typedef unsigned long long xp_uint64_t;
|
2006-04-14 14:17:09 +00:00
|
|
|
#elif XP_SIZEOF___INT64 == 8
|
2005-08-15 04:14:54 +00:00
|
|
|
#define XP_HAVE_INT64_T
|
|
|
|
#define XP_HAVE_UINT64_T
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef __int64 xp_int64_t;
|
|
|
|
typedef unsigned __int64 xp_uint64_t;
|
|
|
|
#endif
|
2004-12-18 10:56:00 +00:00
|
|
|
|
2006-04-14 14:17:09 +00:00
|
|
|
#if XP_SIZEOF_INT == 16
|
2005-08-15 04:14:54 +00:00
|
|
|
#define XP_HAVE_INT128_T
|
|
|
|
#define XP_HAVE_UINT128_T
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef int xp_int128_t;
|
|
|
|
typedef unsigned int xp_uint128_t;
|
2006-04-14 14:17:09 +00:00
|
|
|
#elif XP_SIZEOF_LONG == 16
|
2005-08-15 04:14:54 +00:00
|
|
|
#define XP_HAVE_INT128_T
|
|
|
|
#define XP_HAVE_UINT128_T
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef long xp_int128_t;
|
|
|
|
typedef unsigned long xp_uint128_t;
|
2006-04-14 14:17:09 +00:00
|
|
|
#elif XP_SIZEOF_LONG_LONG == 16
|
2005-08-15 04:14:54 +00:00
|
|
|
#define XP_HAVE_INT128_T
|
|
|
|
#define XP_HAVE_UINT128_T
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef long long xp_int128_t;
|
|
|
|
typedef unsigned long long xp_uint128_t;
|
2006-04-14 14:17:09 +00:00
|
|
|
#elif XP_SIZEOF___INT128 == 16
|
2005-08-15 04:14:54 +00:00
|
|
|
#define XP_HAVE_INT128_T
|
|
|
|
#define XP_HAVE_UINT128_T
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef __int128 xp_int128_t;
|
|
|
|
typedef unsigned __int128 xp_uint128_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* miscellaneous integral types */
|
|
|
|
typedef xp_uint8_t xp_byte_t;
|
|
|
|
typedef xp_uint_t xp_size_t;
|
|
|
|
typedef xp_int_t xp_ssize_t;
|
2005-06-08 15:49:35 +00:00
|
|
|
typedef xp_uint_t xp_word_t;
|
2005-02-14 03:13:32 +00:00
|
|
|
|
|
|
|
/* floating-point number */
|
2006-04-14 14:17:09 +00:00
|
|
|
#if XP_SIZEOF_LONG_DOUBLE > XP_SIZEOF_DOUBLE
|
2005-02-14 03:13:32 +00:00
|
|
|
typedef long double xp_real_t;
|
|
|
|
#else
|
|
|
|
typedef double xp_real_t;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* character types */
|
|
|
|
typedef char xp_mchar_t;
|
|
|
|
typedef int xp_mcint_t;
|
|
|
|
|
2006-05-06 16:05:12 +00:00
|
|
|
#if defined(__cplusplus)
|
2006-05-06 12:52:36 +00:00
|
|
|
/* C++ */
|
|
|
|
typedef wchar_t xp_wchar_t;
|
|
|
|
typedef wchar_t xp_wcint_t;
|
2006-05-06 16:05:12 +00:00
|
|
|
|
2006-05-06 16:16:28 +00:00
|
|
|
/* all the way down from here for C */
|
2006-05-06 16:05:12 +00:00
|
|
|
#elif (XP_SIZEOF_WCHAR_T == 2) || (XP_SIZEOF_WCHAR_T == 0)
|
2006-03-31 17:48:17 +00:00
|
|
|
typedef unsigned short xp_wchar_t;
|
|
|
|
typedef unsigned short xp_wcint_t;
|
2006-05-06 16:05:12 +00:00
|
|
|
#elif (XP_SIZEOF_WCHAR_T == 4)
|
2006-05-06 16:16:28 +00:00
|
|
|
#if XP_SIZEOF_LONG == 4
|
2006-01-17 15:49:22 +00:00
|
|
|
typedef long xp_wchar_t;
|
|
|
|
typedef long xp_wcint_t;
|
2006-05-06 16:05:12 +00:00
|
|
|
#else
|
2006-01-17 15:49:22 +00:00
|
|
|
typedef int xp_wchar_t;
|
|
|
|
typedef int xp_wcint_t;
|
2006-05-06 16:05:12 +00:00
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#error unsupported size of wchar_t
|
2006-05-06 12:52:36 +00:00
|
|
|
#endif
|
|
|
|
|
2006-01-17 15:49:22 +00:00
|
|
|
#if defined(_WIN32) && (defined(UNICODE)||defined(_UNICODE))
|
|
|
|
#define XP_CHAR_IS_WCHAR
|
|
|
|
typedef xp_wchar_t xp_char_t;
|
|
|
|
typedef xp_wcint_t xp_cint_t;
|
2005-04-17 15:28:49 +00:00
|
|
|
#else
|
2006-01-17 15:49:22 +00:00
|
|
|
#if defined(XP_CHAR_IS_MCHAR)
|
|
|
|
typedef xp_mchar_t xp_char_t;
|
|
|
|
typedef xp_mcint_t xp_cint_t;
|
|
|
|
#elif defined(XP_CHAR_IS_WCHAR)
|
|
|
|
typedef xp_wchar_t xp_char_t;
|
|
|
|
typedef xp_wcint_t xp_cint_t;
|
2006-06-09 06:17:24 +00:00
|
|
|
#elif defined(_MBCS)
|
|
|
|
#define XP_CHAR_IS_MCHAR
|
|
|
|
typedef xp_mchar_t xp_char_t;
|
|
|
|
typedef xp_mcint_t xp_cint_t;
|
2006-01-17 15:49:22 +00:00
|
|
|
#else
|
2005-04-17 15:28:49 +00:00
|
|
|
#define XP_CHAR_IS_WCHAR
|
2006-01-17 15:49:22 +00:00
|
|
|
typedef xp_wchar_t xp_char_t;
|
|
|
|
typedef xp_wcint_t xp_cint_t;
|
|
|
|
#endif
|
2005-04-17 15:28:49 +00:00
|
|
|
#endif
|
2005-04-10 06:41:37 +00:00
|
|
|
|
2006-01-17 15:49:22 +00:00
|
|
|
#if defined(XP_CHAR_IS_WCHAR) && defined(_WIN32)
|
|
|
|
#ifndef UNICODE
|
2005-04-10 06:41:37 +00:00
|
|
|
#define UNICODE
|
2006-01-17 15:49:22 +00:00
|
|
|
#endif
|
|
|
|
#ifndef _UNICODE
|
|
|
|
#define _UNICODE
|
|
|
|
#endif
|
2005-04-10 06:41:37 +00:00
|
|
|
#endif
|
|
|
|
|
2004-12-18 09:16:31 +00:00
|
|
|
#endif
|