1999-07-04 17:56:03 +02:00
|
|
|
/*
|
|
|
|
* Compilers that uses ILP32, LP64 or P64 type models
|
|
|
|
* for both Win32 and Win64 are supported by this file.
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* Copyright (C) 1999 Patrik Stridvall
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-07-04 17:56:03 +02:00
|
|
|
*/
|
|
|
|
|
2021-10-13 13:10:00 +02:00
|
|
|
#ifndef _BASETSD_H_
|
|
|
|
#define _BASETSD_H_
|
1999-07-04 17:56:03 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* defined(__cplusplus) */
|
|
|
|
|
|
|
|
/*
|
2011-05-11 20:17:18 +02:00
|
|
|
* Win32 was easy to implement under Unix since most 32-bit Unices use the same
|
|
|
|
* type model (ILP32) as Win32, where int, long and pointer are 32-bit.
|
1999-07-04 17:56:03 +02:00
|
|
|
*
|
2011-05-11 20:17:18 +02:00
|
|
|
* Win64, however, can cause some problems. Most 64-bit Unices use the LP64 type
|
|
|
|
* model where int is 32-bit and long and pointer are 64-bit. Win64 on the other
|
|
|
|
* hand uses the LLP64 type model where int and long are 32 bit and pointer is
|
|
|
|
* 64-bit.
|
1999-07-04 17:56:03 +02:00
|
|
|
*/
|
|
|
|
|
2017-05-04 08:16:17 +02:00
|
|
|
#if (defined(__x86_64__) || defined(__powerpc64__) || defined(__aarch64__)) && !defined(_WIN64)
|
2005-09-22 12:58:04 +02:00
|
|
|
#define _WIN64
|
|
|
|
#endif
|
|
|
|
|
2004-08-26 02:31:20 +02:00
|
|
|
/* Type model independent typedefs */
|
2002-11-23 02:03:40 +01:00
|
|
|
/* The __intXX types are native types defined by the MS C compiler.
|
|
|
|
* Apps that make use of them before they get defined here, can
|
|
|
|
* simply add to the command line:
|
|
|
|
* -D__int8=char -D__int16=short -D__int32=int "-D__int64=long long"
|
|
|
|
*/
|
2003-03-17 00:54:18 +01:00
|
|
|
#if !defined(_MSC_VER) && !defined(__WIDL__)
|
2002-11-23 02:03:40 +01:00
|
|
|
# ifndef __int8
|
|
|
|
# define __int8 char
|
|
|
|
# endif
|
|
|
|
# ifndef __int16
|
|
|
|
# define __int16 short
|
|
|
|
# endif
|
|
|
|
# ifndef __int32
|
|
|
|
# define __int32 int
|
|
|
|
# endif
|
|
|
|
# ifndef __int64
|
2008-12-09 17:42:13 +01:00
|
|
|
# if defined(_WIN64) && !defined(__MINGW64__)
|
2005-09-22 12:58:04 +02:00
|
|
|
# define __int64 long
|
|
|
|
# else
|
|
|
|
# define __int64 long long
|
|
|
|
# endif
|
2002-11-23 02:03:40 +01:00
|
|
|
# endif
|
2002-02-05 19:09:29 +01:00
|
|
|
#endif /* !defined(_MSC_VER) */
|
|
|
|
|
2004-05-04 02:43:02 +02:00
|
|
|
/* FIXME: DECLSPEC_ALIGN should be declared only in winnt.h, but we need it here too */
|
|
|
|
#ifndef DECLSPEC_ALIGN
|
|
|
|
# if defined(_MSC_VER) && (_MSC_VER >= 1300) && !defined(MIDL_PASS)
|
|
|
|
# define DECLSPEC_ALIGN(x) __declspec(align(x))
|
|
|
|
# elif defined(__GNUC__)
|
|
|
|
# define DECLSPEC_ALIGN(x) __attribute__((aligned(x)))
|
|
|
|
# else
|
|
|
|
# define DECLSPEC_ALIGN(x)
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2003-03-17 00:54:18 +01:00
|
|
|
typedef signed char INT8, *PINT8;
|
|
|
|
typedef signed short INT16, *PINT16;
|
|
|
|
typedef signed int INT32, *PINT32;
|
|
|
|
typedef unsigned char UINT8, *PUINT8;
|
|
|
|
typedef unsigned short UINT16, *PUINT16;
|
|
|
|
typedef unsigned int UINT32, *PUINT32;
|
|
|
|
typedef signed int LONG32, *PLONG32;
|
|
|
|
typedef unsigned int ULONG32, *PULONG32;
|
|
|
|
typedef unsigned int DWORD32, *PDWORD32;
|
2005-02-18 13:56:35 +01:00
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
typedef signed __int64 INT64, *PINT64;
|
|
|
|
typedef unsigned __int64 UINT64, *PUINT64;
|
|
|
|
typedef signed __int64 LONG64, *PLONG64;
|
|
|
|
typedef unsigned __int64 ULONG64, *PULONG64;
|
|
|
|
typedef unsigned __int64 DWORD64, *PDWORD64;
|
|
|
|
#else
|
|
|
|
typedef signed __int64 DECLSPEC_ALIGN(8) INT64, *PINT64;
|
|
|
|
typedef unsigned __int64 DECLSPEC_ALIGN(8) UINT64, *PUINT64;
|
2004-05-04 02:43:02 +02:00
|
|
|
typedef signed __int64 DECLSPEC_ALIGN(8) LONG64, *PLONG64;
|
|
|
|
typedef unsigned __int64 DECLSPEC_ALIGN(8) ULONG64, *PULONG64;
|
|
|
|
typedef unsigned __int64 DECLSPEC_ALIGN(8) DWORD64, *PDWORD64;
|
2005-02-18 13:56:35 +01:00
|
|
|
#endif
|
1999-07-04 17:56:03 +02:00
|
|
|
|
2009-11-07 15:55:01 +01:00
|
|
|
/* Basic pointer-sized integer types */
|
1999-07-04 17:56:03 +02:00
|
|
|
|
2009-11-07 15:55:01 +01:00
|
|
|
#if defined(__midl) || defined(__WIDL__)
|
|
|
|
|
|
|
|
typedef /* [public] */ signed __int3264 INT_PTR, *PINT_PTR;
|
|
|
|
typedef /* [public] */ signed __int3264 LONG_PTR, *PLONG_PTR;
|
|
|
|
typedef /* [public] */ unsigned __int3264 UINT_PTR, *PUINT_PTR;
|
|
|
|
typedef /* [public] */ unsigned __int3264 ULONG_PTR, *PULONG_PTR;
|
|
|
|
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
|
|
|
|
|
|
|
#elif defined(_WIN64)
|
|
|
|
|
|
|
|
#define __int3264 __int64
|
1999-07-04 17:56:03 +02:00
|
|
|
|
2002-09-12 19:29:12 +02:00
|
|
|
typedef signed __int64 INT_PTR, *PINT_PTR;
|
|
|
|
typedef signed __int64 LONG_PTR, *PLONG_PTR;
|
|
|
|
typedef unsigned __int64 UINT_PTR, *PUINT_PTR;
|
|
|
|
typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
|
2009-11-07 15:55:01 +01:00
|
|
|
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define __int3264 __int32
|
|
|
|
|
|
|
|
typedef long INT_PTR, *PINT_PTR;
|
|
|
|
typedef unsigned long UINT_PTR, *PUINT_PTR;
|
|
|
|
typedef long LONG_PTR, *PLONG_PTR;
|
|
|
|
typedef unsigned long ULONG_PTR, *PULONG_PTR;
|
|
|
|
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Win32 or Win64 dependent typedef/defines. */
|
|
|
|
|
|
|
|
#ifdef _WIN64
|
1999-07-04 17:56:03 +02:00
|
|
|
|
|
|
|
#define MAXINT_PTR 0x7fffffffffffffff
|
|
|
|
#define MININT_PTR 0x8000000000000000
|
|
|
|
#define MAXUINT_PTR 0xffffffffffffffff
|
|
|
|
|
2009-04-01 03:41:55 +02:00
|
|
|
typedef __int64 SHANDLE_PTR;
|
|
|
|
typedef unsigned __int64 HANDLE_PTR;
|
2003-03-17 00:54:18 +01:00
|
|
|
typedef int HALF_PTR, *PHALF_PTR;
|
|
|
|
typedef unsigned int UHALF_PTR, *PUHALF_PTR;
|
1999-07-04 17:56:03 +02:00
|
|
|
|
|
|
|
#define MAXHALF_PTR 0x7fffffff
|
|
|
|
#define MINHALF_PTR 0x80000000
|
|
|
|
#define MAXUHALF_PTR 0xffffffff
|
|
|
|
|
2007-05-21 12:58:58 +02:00
|
|
|
#if !defined(__midl) && !defined(__WIDL__)
|
|
|
|
|
|
|
|
static inline ULONG32 HandleToULong(const void *h)
|
|
|
|
{
|
2012-06-28 12:12:31 +02:00
|
|
|
return (ULONG32)(ULONG_PTR)h;
|
2007-05-21 12:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline LONG32 HandleToLong(const void *h)
|
|
|
|
{
|
2012-06-28 12:12:31 +02:00
|
|
|
return (LONG32)(LONG_PTR)h;
|
2007-05-21 12:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *ULongToHandle(ULONG32 ul)
|
|
|
|
{
|
|
|
|
return (void *)(ULONG_PTR)ul;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *LongToHandle(LONG32 l)
|
|
|
|
{
|
|
|
|
return (void *)(LONG_PTR)l;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline ULONG32 PtrToUlong(const void *p)
|
|
|
|
{
|
2012-06-28 12:12:31 +02:00
|
|
|
return (ULONG32)(ULONG_PTR)p;
|
2007-05-21 12:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline LONG32 PtrToLong(const void *p)
|
|
|
|
{
|
2012-06-28 12:12:31 +02:00
|
|
|
return (LONG32)(LONG_PTR)p;
|
2007-05-21 12:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline UINT32 PtrToUint(const void *p)
|
|
|
|
{
|
2012-06-28 12:12:31 +02:00
|
|
|
return (UINT32)(UINT_PTR)p;
|
2007-05-21 12:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline INT32 PtrToInt(const void *p)
|
|
|
|
{
|
2012-06-28 12:12:31 +02:00
|
|
|
return (INT32)(INT_PTR)p;
|
2007-05-21 12:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline UINT16 PtrToUshort(const void *p)
|
|
|
|
{
|
2012-06-28 12:12:31 +02:00
|
|
|
return (UINT16)(ULONG_PTR)p;
|
2007-05-21 12:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline INT16 PtrToShort(const void *p)
|
|
|
|
{
|
2012-06-28 12:12:31 +02:00
|
|
|
return (INT16)(LONG_PTR)p;
|
2007-05-21 12:58:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *IntToPtr(INT32 i)
|
|
|
|
{
|
|
|
|
return (void *)(INT_PTR)i;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *UIntToPtr(UINT32 ui)
|
|
|
|
{
|
|
|
|
return (void *)(UINT_PTR)ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *LongToPtr(LONG32 l)
|
|
|
|
{
|
|
|
|
return (void *)(LONG_PTR)l;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *ULongToPtr(ULONG32 ul)
|
|
|
|
{
|
|
|
|
return (void *)(ULONG_PTR)ul;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* !__midl && !__WIDL__ */
|
|
|
|
|
1999-07-04 17:56:03 +02:00
|
|
|
#else /* FIXME: defined(_WIN32) */
|
|
|
|
|
|
|
|
#define MAXINT_PTR 0x7fffffff
|
|
|
|
#define MININT_PTR 0x80000000
|
|
|
|
#define MAXUINT_PTR 0xffffffff
|
|
|
|
|
2009-04-01 03:41:55 +02:00
|
|
|
typedef long SHANDLE_PTR;
|
|
|
|
typedef unsigned long HANDLE_PTR;
|
2003-03-17 00:54:18 +01:00
|
|
|
typedef signed short HALF_PTR, *PHALF_PTR;
|
|
|
|
typedef unsigned short UHALF_PTR, *PUHALF_PTR;
|
1999-07-04 17:56:03 +02:00
|
|
|
|
|
|
|
#define MAXUHALF_PTR 0xffff
|
|
|
|
#define MAXHALF_PTR 0x7fff
|
|
|
|
#define MINHALF_PTR 0x8000
|
|
|
|
|
2007-05-21 12:58:58 +02:00
|
|
|
#define HandleToULong(h) ((ULONG)(ULONG_PTR)(h))
|
|
|
|
#define HandleToLong(h) ((LONG)(LONG_PTR)(h))
|
|
|
|
#define ULongToHandle(ul) ((HANDLE)(ULONG_PTR)(ul))
|
2007-05-23 10:32:33 +02:00
|
|
|
#define LongToHandle(l) ((HANDLE)(LONG_PTR)(l))
|
2007-05-21 12:58:58 +02:00
|
|
|
#define PtrToUlong(p) ((ULONG)(ULONG_PTR)(p))
|
|
|
|
#define PtrToLong(p) ((LONG)(LONG_PTR)(p))
|
|
|
|
#define PtrToUint(p) ((UINT)(UINT_PTR)(p))
|
|
|
|
#define PtrToInt(p) ((INT)(INT_PTR)(p))
|
|
|
|
#define PtrToUshort(p) ((USHORT)(ULONG_PTR)(p))
|
|
|
|
#define PtrToShort(p) ((SHORT)(LONG_PTR)(p))
|
|
|
|
#define IntToPtr(i) ((void *)(INT_PTR)((INT)i))
|
|
|
|
#define UIntToPtr(ui) ((void *)(UINT_PTR)((UINT)ui))
|
|
|
|
#define LongToPtr(l) ((void *)(LONG_PTR)((LONG)l))
|
|
|
|
#define ULongToPtr(ul) ((void *)(ULONG_PTR)((ULONG)ul))
|
|
|
|
|
1999-07-04 17:56:03 +02:00
|
|
|
#endif /* defined(_WIN64) || defined(_WIN32) */
|
|
|
|
|
2007-07-13 07:18:29 +02:00
|
|
|
#define HandleToUlong(h) HandleToULong(h)
|
|
|
|
#define UlongToHandle(ul) ULongToHandle(ul)
|
|
|
|
#define UintToPtr(ui) UIntToPtr(ui)
|
|
|
|
#define UlongToPtr(ul) ULongToPtr(ul)
|
|
|
|
|
2002-09-21 03:21:00 +02:00
|
|
|
typedef LONG_PTR SSIZE_T, *PSSIZE_T;
|
|
|
|
typedef ULONG_PTR SIZE_T, *PSIZE_T;
|
1999-07-04 17:56:03 +02:00
|
|
|
|
2005-06-27 11:49:56 +02:00
|
|
|
typedef ULONG_PTR KAFFINITY, *PKAFFINITY;
|
|
|
|
|
2020-10-12 13:17:25 +02:00
|
|
|
#define MINLONGLONG ((LONGLONG)~MAXLONGLONG)
|
|
|
|
|
2002-05-29 04:02:19 +02:00
|
|
|
/* Some Wine-specific definitions */
|
|
|
|
|
|
|
|
/* Architecture dependent settings. */
|
|
|
|
/* These are hardcoded to avoid dependencies on config.h in Winelib apps. */
|
|
|
|
#if defined(__i386__)
|
|
|
|
# undef WORDS_BIGENDIAN
|
2005-07-18 11:11:42 +02:00
|
|
|
#elif defined(__x86_64__)
|
|
|
|
# undef WORDS_BIGENDIAN
|
2021-01-31 18:34:11 +01:00
|
|
|
#elif defined(__powerpc64__) && defined(__BIG_ENDIAN__)
|
|
|
|
# define WORDS_BIGENDIAN
|
|
|
|
#elif defined(__powerpc64__)
|
|
|
|
# undef WORDS_BIGENDIAN
|
2003-07-15 22:46:40 +02:00
|
|
|
#elif defined(__powerpc__)
|
2002-05-29 04:02:19 +02:00
|
|
|
# define WORDS_BIGENDIAN
|
2002-12-10 20:04:45 +01:00
|
|
|
#elif defined(__ALPHA__)
|
2004-10-18 21:37:30 +02:00
|
|
|
# undef WORDS_BIGENDIAN
|
2010-10-29 16:34:31 +02:00
|
|
|
#elif defined(__ARMEB__)
|
|
|
|
# define WORDS_BIGENDIAN
|
2011-05-10 20:49:58 +02:00
|
|
|
#elif defined(__ARMEL__) || defined(__arm__)
|
2009-09-22 16:31:17 +02:00
|
|
|
# undef WORDS_BIGENDIAN
|
2013-01-16 00:41:16 +01:00
|
|
|
#elif defined(__AARCH64EB__)
|
|
|
|
# define WORDS_BIGENDIAN
|
|
|
|
#elif defined(__AARCH64EL__) || defined(__aarch64__)
|
|
|
|
# undef WORDS_BIGENDIAN
|
2010-10-29 16:34:38 +02:00
|
|
|
#elif defined(__MIPSEB__)
|
|
|
|
# define WORDS_BIGENDIAN
|
|
|
|
#elif defined(__MIPSEL__)
|
|
|
|
# undef WORDS_BIGENDIAN
|
2008-06-28 13:25:54 +02:00
|
|
|
#elif !defined(RC_INVOKED) && !defined(__WIDL__) && !defined(__midl)
|
2002-05-29 04:02:19 +02:00
|
|
|
# error Unknown CPU architecture!
|
|
|
|
#endif
|
|
|
|
|
1999-07-04 17:56:03 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif /* defined(__cplusplus) */
|
|
|
|
|
2021-10-13 13:10:00 +02:00
|
|
|
#endif /* !defined(_BASETSD_H_) */
|