qse/ase/types.h

275 lines
6.5 KiB
C
Raw Normal View History

2004-12-18 09:16:31 +00:00
/*
2006-10-22 11:46:18 +00:00
* $Id: types.h,v 1.57 2006-10-22 11:44:46 bacon Exp $
2004-12-18 09:16:31 +00:00
*/
2006-10-22 11:46:18 +00:00
#ifndef _SSE_TYPES_H_
#define _SSE_TYPES_H_
2004-12-18 09:16:31 +00:00
2005-08-07 11:17:23 +00:00
#if defined(_WIN32)
2006-10-22 11:46:18 +00:00
#include <sse/conf_msw.h>
2006-01-08 13:34:41 +00:00
#elif defined(vms) || defined(__vms)
2006-10-22 11:46:18 +00:00
#include <sse/conf_vms.h>
2006-04-30 17:35:37 +00:00
#elif defined(dos) || defined(__dos)
2006-10-22 11:46:18 +00:00
#include <sse/conf_dos.h>
2005-03-29 10:09:27 +00:00
#else
2006-10-22 11:46:18 +00:00
#include <sse/config.h>
2005-03-29 10:09:27 +00:00
#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
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_bool_t
2005-09-17 17:42:21 +00:00
* Boolean type
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_tri_t
2005-09-17 17:42:21 +00:00
* Tri-State type
*
* GROUP: Integral Types
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_byte_t
2005-09-19 14:24:38 +00:00
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_word_t
2005-09-17 17:42:21 +00:00
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_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
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_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
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_long_t
2005-09-19 14:24:38 +00:00
* The largest signed integer available
2005-09-17 17:42:21 +00:00
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_ulong_t
2005-09-19 14:24:38 +00:00
* The largest unsigned integer available
2005-09-17 17:42:21 +00:00
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_size_t
2005-09-19 14:24:38 +00:00
* Unsigned integer which can represent the size of the largest
* in-memory data
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_ssize_t
* Signed version of sse_size_t
2005-09-19 14:24:38 +00:00
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_int8_t
2005-09-17 17:42:21 +00:00
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_uint8_t
2005-09-17 17:42:21 +00:00
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_int16_t
2005-09-17 17:42:21 +00:00
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_uint16_t
2005-09-17 17:42:21 +00:00
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_int32_t
2005-09-17 17:42:21 +00:00
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_uint32_t
2005-09-17 17:42:21 +00:00
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_int64_t
2005-09-17 17:42:21 +00:00
*
2006-10-22 11:46:18 +00:00
* TYPE: sse_uint64_t
2005-09-17 17:42:21 +00:00
*/
2005-05-04 04:33:42 +00:00
/* boolean type */
2006-10-22 11:46:18 +00:00
typedef int sse_bool_t;
#define sse_true (0 == 0)
#define sse_false (0 != 0)
2005-02-14 03:13:32 +00:00
2005-05-04 04:33:42 +00:00
/* tri-state type */
2006-10-22 11:46:18 +00:00
typedef int sse_tri_t;
#define sse_alive 1
#define sse_zombie 0
#define sse_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-22 11:46:18 +00:00
#if SSE_SIZEOF_VOID_P == SSE_SIZEOF_INT
typedef int sse_int_t;
typedef unsigned int sse_uint_t;
#elif SSE_SIZEOF_VOID_P == SSE_SIZEOF_LONG
typedef long sse_int_t;
typedef unsigned long sse_uint_t;
#elif SSE_SIZEOF_VOID_P == SSE_SIZEOF_LONG_LONG
typedef long long sse_int_t;
typedef unsigned long long sse_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-22 11:46:18 +00:00
#if SSE_SIZEOF_LONG_LONG != 0
typedef long long sse_long_t;
typedef unsigned long long sse_ulong_t;
#elif SSE_SIZEOF___INT64 != 0
typedef __int64 sse_long_t;
typedef unsigned __int64 sse_ulong_t;
2005-02-14 03:13:32 +00:00
#else
2006-10-22 11:46:18 +00:00
typedef long sse_long_t;
typedef unsigned long sse_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-22 11:46:18 +00:00
#if SSE_SIZEOF_CHAR == 1
typedef char sse_int8_t;
typedef unsigned char sse_uint8_t;
#elif SSE_SIZEOF___INT8 == 1
typedef __int8 sse_int8_t;
typedef unsigned __int8 sse_uint8_t;
2005-02-13 16:15:31 +00:00
#endif
2006-10-22 11:46:18 +00:00
#if SSE_SIZEOF_SHORT == 2
typedef short sse_int16_t;
typedef unsigned short sse_uint16_t;
#elif SSE_SIZEOF___INT16 == 2
typedef __int16 sse_int16_t;
typedef unsigned __int16 sse_uint16_t;
2005-02-13 16:15:31 +00:00
#endif
2006-10-22 11:46:18 +00:00
#if SSE_SIZEOF_INT == 4
typedef int sse_int32_t;
typedef unsigned int sse_uint32_t;
#elif SSE_SIZEOF_LONG == 4
typedef long sse_int32_t;
typedef unsigned long sse_uint32_t;
#elif SSE_SIZEOF___INT32 == 4
typedef __int32 sse_int32_t;
typedef unsigned __int32 sse_uint32_t;
2005-02-13 16:15:31 +00:00
#endif
2006-10-22 11:46:18 +00:00
#if SSE_SIZEOF_INT == 8
#define SSE_HAVE_INT64_T
#define SSE_HAVE_UINT64_T
typedef int sse_int64_t;
typedef unsigned int sse_uint64_t;
#elif SSE_SIZEOF_LONG == 8
#define SSE_HAVE_INT64_T
#define SSE_HAVE_UINT64_T
typedef long sse_int64_t;
typedef unsigned long sse_uint64_t;
#elif SSE_SIZEOF_LONG_LONG == 8
#define SSE_HAVE_INT64_T
#define SSE_HAVE_UINT64_T
typedef long long sse_int64_t;
typedef unsigned long long sse_uint64_t;
#elif SSE_SIZEOF___INT64 == 8
#define SSE_HAVE_INT64_T
#define SSE_HAVE_UINT64_T
typedef __int64 sse_int64_t;
typedef unsigned __int64 sse_uint64_t;
2005-02-14 03:13:32 +00:00
#endif
2004-12-18 10:56:00 +00:00
2006-10-22 11:46:18 +00:00
#if SSE_SIZEOF_INT == 16
#define SSE_HAVE_INT128_T
#define SSE_HAVE_UINT128_T
typedef int sse_int128_t;
typedef unsigned int sse_uint128_t;
#elif SSE_SIZEOF_LONG == 16
#define SSE_HAVE_INT128_T
#define SSE_HAVE_UINT128_T
typedef long sse_int128_t;
typedef unsigned long sse_uint128_t;
#elif SSE_SIZEOF_LONG_LONG == 16
#define SSE_HAVE_INT128_T
#define SSE_HAVE_UINT128_T
typedef long long sse_int128_t;
typedef unsigned long long sse_uint128_t;
#elif SSE_SIZEOF___INT128 == 16
#define SSE_HAVE_INT128_T
#define SSE_HAVE_UINT128_T
typedef __int128 sse_int128_t;
typedef unsigned __int128 sse_uint128_t;
2005-02-14 03:13:32 +00:00
#endif
/* miscellaneous integral types */
2006-10-22 11:46:18 +00:00
typedef sse_uint8_t sse_byte_t;
typedef sse_uint_t sse_size_t;
typedef sse_int_t sse_ssize_t;
typedef sse_uint_t sse_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-22 11:46:18 +00:00
* if so, use long double for sse_real_t */
#define SSE_SIZEOF_REAL SSE_SIZEOF_DOUBLE
typedef double sse_real_t;
#elif SSE_SIZEOF_LONG_DOUBLE > SSE_SIZEOF_DOUBLE
#define SSE_SIZEOF_REAL SSE_SIZEOF_LONG_DOUBLE
typedef long double sse_real_t;
2005-02-14 03:13:32 +00:00
#else
2006-10-22 11:46:18 +00:00
#define SSE_SIZEOF_REAL SSE_SIZEOF_DOUBLE
typedef double sse_real_t;
2005-02-14 03:13:32 +00:00
#endif
/* character types */
2006-10-22 11:46:18 +00:00
typedef char sse_mchar_t;
typedef int sse_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-22 11:46:18 +00:00
typedef wchar_t sse_wchar_t;
typedef wchar_t sse_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-22 11:46:18 +00:00
#elif (SSE_SIZEOF_WCHAR_T == 2) || (SSE_SIZEOF_WCHAR_T == 0)
typedef unsigned short sse_wchar_t;
typedef unsigned short sse_wcint_t;
#elif (SSE_SIZEOF_WCHAR_T == 4)
2006-07-28 17:20:27 +00:00
#if defined(vms) || defined(__vms)
2006-10-22 11:46:18 +00:00
typedef unsigned int sse_wchar_t;
typedef int sse_wcint_t;
2006-08-26 15:28:08 +00:00
#elif defined(__FreeBSD__)
2006-10-22 11:46:18 +00:00
typedef int sse_wchar_t;
typedef int sse_wcint_t;
2006-09-08 11:27:01 +00:00
#elif (defined(sun) || defined(__sun)) && defined(_LP64)
2006-10-22 11:46:18 +00:00
typedef int sse_wchar_t;
typedef int sse_wcint_t;
#elif SSE_SIZEOF_LONG == 4
typedef long sse_wchar_t;
typedef long sse_wcint_t;
2006-05-06 16:05:12 +00:00
#else
2006-10-22 11:46:18 +00:00
typedef int sse_wchar_t;
typedef int sse_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-22 11:46:18 +00:00
#define SSE_CHAR_IS_WCHAR
typedef sse_wchar_t sse_char_t;
typedef sse_wcint_t sse_cint_t;
2005-04-17 15:28:49 +00:00
#else
2006-10-22 11:46:18 +00:00
#if defined(SSE_CHAR_IS_MCHAR)
typedef sse_mchar_t sse_char_t;
typedef sse_mcint_t sse_cint_t;
#elif defined(SSE_CHAR_IS_WCHAR)
typedef sse_wchar_t sse_char_t;
typedef sse_wcint_t sse_cint_t;
2006-06-09 06:17:24 +00:00
#elif defined(_MBCS)
2006-10-22 11:46:18 +00:00
#define SSE_CHAR_IS_MCHAR
typedef sse_mchar_t sse_char_t;
typedef sse_mcint_t sse_cint_t;
2006-01-17 15:49:22 +00:00
#else
2006-10-22 11:46:18 +00:00
#define SSE_CHAR_IS_WCHAR
typedef sse_wchar_t sse_char_t;
typedef sse_wcint_t sse_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-22 11:46:18 +00:00
#if defined(SSE_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