qse/ase/types.h

223 lines
5.7 KiB
C
Raw Normal View History

2004-12-18 09:16:31 +00:00
/*
2007-01-29 06:40:29 +00:00
* $Id: types.h,v 1.65 2007-01-29 06:40:29 bacon Exp $
2004-12-18 09:16:31 +00:00
*/
2006-10-24 04:31:07 +00:00
#ifndef _ASE_TYPES_H_
#define _ASE_TYPES_H_
2004-12-18 09:16:31 +00:00
2005-08-07 11:17:23 +00:00
#if defined(_WIN32)
2006-10-24 04:31:07 +00:00
#include <ase/conf_msw.h>
2006-01-08 13:34:41 +00:00
#elif defined(vms) || defined(__vms)
2006-10-24 04:31:07 +00:00
#include <ase/conf_vms.h>
2007-01-29 06:40:29 +00:00
#elif defined(__unix__) || defined(__unix) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || (defined(__APPLE__) && defined(__MACH__))
2006-12-17 10:33:41 +00:00
#if !defined(__unix__)
#define __unix__
#endif
#if !defined(__unix)
#define __unix
#endif
2006-11-19 08:01:45 +00:00
#include <ase/conf_unx.h>
2006-11-28 11:47:43 +00:00
#else
2006-11-19 08:01:45 +00:00
#error unsupport operating system
2005-03-29 10:09:27 +00:00
#endif
2005-02-13 16:15:31 +00:00
2005-05-04 04:33:42 +00:00
/* boolean type */
2006-10-24 04:31:07 +00:00
typedef int ase_bool_t;
#define ase_true (0 == 0)
#define ase_false (0 != 0)
2005-02-14 03:13:32 +00:00
2005-05-04 04:33:42 +00:00
/* tri-state type */
2006-10-24 04:31:07 +00:00
typedef int ase_tri_t;
#define ase_alive 1
#define ase_zombie 0
#define ase_dead -1
2005-05-04 04:33:42 +00:00
2005-02-14 03:13:32 +00:00
/* integer that can hold a pointer */
2006-10-24 04:31:07 +00:00
#if ASE_SIZEOF_VOID_P == ASE_SIZEOF_INT
typedef int ase_int_t;
typedef unsigned int ase_uint_t;
#elif ASE_SIZEOF_VOID_P == ASE_SIZEOF_LONG
typedef long ase_int_t;
typedef unsigned long ase_uint_t;
#elif ASE_SIZEOF_VOID_P == ASE_SIZEOF_LONG_LONG
typedef long long ase_int_t;
typedef unsigned long long ase_uint_t;
2005-02-13 16:15:31 +00:00
#else
2006-09-27 14:14:47 +00:00
#error Unsupported pointer size
2005-02-13 16:15:31 +00:00
#endif
2006-09-27 14:14:47 +00:00
2005-02-14 03:13:32 +00:00
/* the largest integer supported by the system */
2006-10-24 04:31:07 +00:00
#if ASE_SIZEOF_LONG_LONG != 0
typedef long long ase_long_t;
typedef unsigned long long ase_ulong_t;
#elif ASE_SIZEOF___INT64 != 0
typedef __int64 ase_long_t;
typedef unsigned __int64 ase_ulong_t;
2005-02-14 03:13:32 +00:00
#else
2006-10-24 04:31:07 +00:00
typedef long ase_long_t;
typedef unsigned long ase_ulong_t;
2005-02-13 16:15:31 +00:00
#endif
2005-02-14 03:13:32 +00:00
/* integers of specific size */
2006-10-24 04:31:07 +00:00
#if ASE_SIZEOF_CHAR == 1
typedef char ase_int8_t;
typedef unsigned char ase_uint8_t;
#elif ASE_SIZEOF___INT8 == 1
typedef __int8 ase_int8_t;
typedef unsigned __int8 ase_uint8_t;
2005-02-13 16:15:31 +00:00
#endif
2006-10-24 04:31:07 +00:00
#if ASE_SIZEOF_SHORT == 2
typedef short ase_int16_t;
typedef unsigned short ase_uint16_t;
#elif ASE_SIZEOF___INT16 == 2
typedef __int16 ase_int16_t;
typedef unsigned __int16 ase_uint16_t;
2005-02-13 16:15:31 +00:00
#endif
2006-10-24 04:31:07 +00:00
#if ASE_SIZEOF_INT == 4
typedef int ase_int32_t;
typedef unsigned int ase_uint32_t;
#elif ASE_SIZEOF_LONG == 4
typedef long ase_int32_t;
typedef unsigned long ase_uint32_t;
#elif ASE_SIZEOF___INT32 == 4
typedef __int32 ase_int32_t;
typedef unsigned __int32 ase_uint32_t;
2005-02-13 16:15:31 +00:00
#endif
2006-10-24 04:31:07 +00:00
#if ASE_SIZEOF_INT == 8
#define ASE_HAVE_INT64_T
#define ASE_HAVE_UINT64_T
typedef int ase_int64_t;
typedef unsigned int ase_uint64_t;
#elif ASE_SIZEOF_LONG == 8
#define ASE_HAVE_INT64_T
#define ASE_HAVE_UINT64_T
typedef long ase_int64_t;
typedef unsigned long ase_uint64_t;
#elif ASE_SIZEOF_LONG_LONG == 8
#define ASE_HAVE_INT64_T
#define ASE_HAVE_UINT64_T
typedef long long ase_int64_t;
typedef unsigned long long ase_uint64_t;
#elif ASE_SIZEOF___INT64 == 8
#define ASE_HAVE_INT64_T
#define ASE_HAVE_UINT64_T
typedef __int64 ase_int64_t;
typedef unsigned __int64 ase_uint64_t;
2005-02-14 03:13:32 +00:00
#endif
2004-12-18 10:56:00 +00:00
2006-10-24 04:31:07 +00:00
#if ASE_SIZEOF_INT == 16
#define ASE_HAVE_INT128_T
#define ASE_HAVE_UINT128_T
typedef int ase_int128_t;
typedef unsigned int ase_uint128_t;
#elif ASE_SIZEOF_LONG == 16
#define ASE_HAVE_INT128_T
#define ASE_HAVE_UINT128_T
typedef long ase_int128_t;
typedef unsigned long ase_uint128_t;
#elif ASE_SIZEOF_LONG_LONG == 16
#define ASE_HAVE_INT128_T
#define ASE_HAVE_UINT128_T
typedef long long ase_int128_t;
typedef unsigned long long ase_uint128_t;
#elif ASE_SIZEOF___INT128 == 16
#define ASE_HAVE_INT128_T
#define ASE_HAVE_UINT128_T
typedef __int128 ase_int128_t;
typedef unsigned __int128 ase_uint128_t;
2005-02-14 03:13:32 +00:00
#endif
/* miscellaneous integral types */
2006-10-24 04:31:07 +00:00
typedef ase_uint8_t ase_byte_t;
typedef ase_uint_t ase_size_t;
typedef ase_int_t ase_ssize_t;
typedef ase_uint_t ase_word_t;
2005-02-14 03:13:32 +00:00
/* floating-point number */
2006-08-26 16:30:53 +00:00
#if defined(__FreeBSD__)
/* TODO: check if the support for long double is complete.
2006-10-24 04:31:07 +00:00
* if so, use long double for ase_real_t */
#define ASE_SIZEOF_REAL ASE_SIZEOF_DOUBLE
typedef double ase_real_t;
#elif ASE_SIZEOF_LONG_DOUBLE > ASE_SIZEOF_DOUBLE
#define ASE_SIZEOF_REAL ASE_SIZEOF_LONG_DOUBLE
typedef long double ase_real_t;
2005-02-14 03:13:32 +00:00
#else
2006-10-24 04:31:07 +00:00
#define ASE_SIZEOF_REAL ASE_SIZEOF_DOUBLE
typedef double ase_real_t;
2005-02-14 03:13:32 +00:00
#endif
/* character types */
2006-10-24 04:31:07 +00:00
typedef char ase_mchar_t;
typedef int ase_mcint_t;
2005-02-14 03:13:32 +00:00
2006-05-06 16:05:12 +00:00
#if defined(__cplusplus)
2006-05-06 12:52:36 +00:00
/* C++ */
2006-10-24 04:31:07 +00:00
typedef wchar_t ase_wchar_t;
typedef wchar_t ase_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-10-24 04:31:07 +00:00
#elif (ASE_SIZEOF_WCHAR_T == 2) || (ASE_SIZEOF_WCHAR_T == 0)
typedef unsigned short ase_wchar_t;
typedef unsigned short ase_wcint_t;
#elif (ASE_SIZEOF_WCHAR_T == 4)
2006-07-28 17:20:27 +00:00
#if defined(vms) || defined(__vms)
2006-10-24 04:31:07 +00:00
typedef unsigned int ase_wchar_t;
typedef int ase_wcint_t;
2007-01-29 06:40:29 +00:00
#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
2006-10-24 04:31:07 +00:00
typedef int ase_wchar_t;
typedef int ase_wcint_t;
2006-09-08 11:27:01 +00:00
#elif (defined(sun) || defined(__sun)) && defined(_LP64)
2006-10-24 04:31:07 +00:00
typedef int ase_wchar_t;
typedef int ase_wcint_t;
2007-01-29 06:40:29 +00:00
#elif defined(__APPLE__) && defined(__MACH__)
typedef int ase_wchar_t;
typedef int ase_wcint_t;
2006-10-24 04:31:07 +00:00
#elif ASE_SIZEOF_LONG == 4
typedef long ase_wchar_t;
typedef long ase_wcint_t;
2006-05-06 16:05:12 +00:00
#else
2006-10-24 04:31:07 +00:00
typedef int ase_wchar_t;
typedef int ase_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))
2006-10-24 04:31:07 +00:00
#define ASE_CHAR_IS_WCHAR
typedef ase_wchar_t ase_char_t;
typedef ase_wcint_t ase_cint_t;
2005-04-17 15:28:49 +00:00
#else
2006-10-24 04:31:07 +00:00
#if defined(ASE_CHAR_IS_MCHAR)
typedef ase_mchar_t ase_char_t;
typedef ase_mcint_t ase_cint_t;
#elif defined(ASE_CHAR_IS_WCHAR)
typedef ase_wchar_t ase_char_t;
typedef ase_wcint_t ase_cint_t;
2006-06-09 06:17:24 +00:00
#elif defined(_MBCS)
2006-10-24 04:31:07 +00:00
#define ASE_CHAR_IS_MCHAR
typedef ase_mchar_t ase_char_t;
typedef ase_mcint_t ase_cint_t;
2006-01-17 15:49:22 +00:00
#else
2006-10-24 04:31:07 +00:00
#define ASE_CHAR_IS_WCHAR
typedef ase_wchar_t ase_char_t;
typedef ase_wcint_t ase_cint_t;
2006-01-17 15:49:22 +00:00
#endif
2005-04-17 15:28:49 +00:00
#endif
2005-04-10 06:41:37 +00:00
2006-10-24 04:31:07 +00:00
#if defined(ASE_CHAR_IS_WCHAR) && defined(_WIN32)
2006-01-17 15:49:22 +00:00
#ifndef UNICODE
2006-07-17 04:17:40 +00:00
#define UNICODE
2006-01-17 15:49:22 +00:00
#endif
#ifndef _UNICODE
2006-07-17 04:17:40 +00:00
#define _UNICODE
2006-01-17 15:49:22 +00:00
#endif
2005-04-10 06:41:37 +00:00
#endif
2004-12-18 09:16:31 +00:00
#endif