rewrite of wtypes.h

This commit is contained in:
Norbert Federa 2016-12-13 22:41:46 +01:00
parent 2b9165466d
commit 73ac495870

View File

@ -20,11 +20,14 @@
#ifndef WINPR_WTYPES_H
#define WINPR_WTYPES_H
/* Set by CMake during configuration. */
#cmakedefine01 WINPR_HAVE_STDINT_H
/* Set by CMake during configuration */
#cmakedefine WINPR_HAVE_STDINT_H
#cmakedefine WINPR_HAVE_STDBOOL_H
/* Set by CMake during configuration. */
#cmakedefine01 WINPR_HAVE_STDBOOL_H
#if !defined(_MSC_VER) || _MSC_VER >= 1900
/* Microsoft's inttypes.h is broken before MSVC 2015 */
#cmakedefine WINPR_HAVE_INTTYPES_H
#endif
/* MSDN: Windows Data Types - http://msdn.microsoft.com/en-us/library/aa383751/ */
/* [MS-DTYP]: Windows Data Types - http://msdn.microsoft.com/en-us/library/cc230273/ */
@ -34,14 +37,20 @@
#include <winpr/spec.h>
#if WINPR_HAVE_STDBOOL_H
#ifdef WINPR_HAVE_STDBOOL_H
#include <stdbool.h>
#endif
#if WINPR_HAVE_STDINT_H
#ifdef WINPR_HAVE_STDINT_H
#include <stdint.h>
#endif
#ifdef WINPR_HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#include <limits.h>
#ifdef _WIN32
#include <wtypes.h>
#endif
@ -50,8 +59,18 @@
#include <objc/objc.h>
#endif
#ifndef CONST
#define CONST const
#endif
#ifndef VOID
#define VOID void
#endif
#ifndef _WIN32
#define CALLBACK
#define WINAPI
#define CDECL
@ -63,27 +82,51 @@
#define NEAR
#endif
#if WINPR_HAVE_STDINT_H
#define __int8 int8_t
#define __uint8 uint8_t
#define __int16 int16_t
#define __uint16 uint16_t
#define __int32 int32_t
#define __uint32 uint32_t
#define __int64 int64_t
#define __uint64 uint64_t
#ifdef WINPR_HAVE_STDINT_H
typedef int8_t __int8;
typedef uint8_t __uint8;
typedef int16_t __int16;
typedef uint16_t __uint16;
typedef int32_t __int32;
typedef uint32_t __uint32;
typedef int64_t __int64;
typedef uint64_t __uint64;
#else
#define __int8 char
#define __uint8 unsigned char
#define __int16 short
#define __uint16 unsigned short
#define __int32 int
#define __uint32 unsigned int
#define __int64 long long
#define __uint64 unsigned long long
#if UCHAR_MAX == 0xFF
typedef signed char __int8;
typedef unsigned char __uint8;
#else
#error "8-bit type not configured"
#endif
#if USHRT_MAX == 0xFFFF
typedef short __int16;
typedef unsigned short __uint16;
#elif UINT_MAX == 0xFFFF
typedef int __int16;
typedef unsigned int __uint16;
#error "16-bit type not configured"
#endif
#if UINT_MAX == 0xFFFFFFFF
typedef int __int32;
typedef unsigned int __uint32;
#elif ULONG_MAX == 0xFFFFFFFF
typedef long __int32;
typedef unsigned long __uint32;
#else
#error "32-bit type not configured"
#endif
#if ULONG_MAX == 0xFFFFFFFFFFFFFFFF
typedef long __int64;
typedef unsigned long __uint64;
#elif ULLONG_MAX == 0xFFFFFFFFFFFFFFFF
typedef long long __int64;
typedef unsigned long long __uint64;
#else
#error "64-bit type not configured"
#endif
#endif /* WINPR_HAVE_STDINT_H */
#if WINPR_HAVE_STDINT_H
#ifdef WINPR_HAVE_STDINT_H
#if __ILP64__ || __LP64__
#define __int3264 int64_t
#define __uint3264 uint64_t
@ -99,88 +142,105 @@
#define __int3264 __int32
#define __uint3264 __uint32
#endif
#endif
#endif /* WINPR_HAVE_STDINT_H */
typedef void *PVOID, *LPVOID, *PVOID64, *LPVOID64;
#ifndef XMD_H /* X11/Xmd.h typedef collision with BOOL */
#if WINPR_HAVE_STDBOOL_H && !defined(__OBJC__)
#ifndef __OBJC__ /* objc.h typedef collision with BOOL */
#ifndef __APPLE__
typedef __int32 BOOL;
#else /* __APPLE__ */
/* ensure compatibility with objc libraries */
#if (TARGET_OS_IPHONE && __LP64__) || TARGET_OS_WATCH
typedef bool BOOL;
#else
#ifndef __OBJC__
#if defined(__APPLE__)
typedef signed char BOOL;
#else
typedef int BOOL;
#endif
#endif
#endif
#endif
#endif /* __APPLE__ */
#endif /* __OBJC__ */
#endif /* XMD_H */
typedef BOOL *PBOOL, *LPBOOL;
#if WINPR_HAVE_STDINT_H
typedef int32_t LONG;
typedef uint32_t DWORD;
typedef uint32_t ULONG;
#elif defined(__LP64__) || defined(__APPLE__)
typedef int LONG;
typedef unsigned int DWORD;
typedef unsigned int ULONG;
#else
typedef long LONG;
typedef unsigned long DWORD;
typedef unsigned long ULONG;
#endif
#ifndef XMD_H /* X11/Xmd.h typedef collision with BYTE */
#if WINPR_HAVE_STDINT_H
typedef uint8_t BYTE;
#else
typedef unsigned char BYTE;
#endif
#endif
typedef BYTE *PBYTE, *LPBYTE;
typedef BYTE BOOLEAN, *PBOOLEAN;
#if defined(wchar_t)
typedef wchar_t WCHAR, *PWCHAR;
#else
typedef unsigned short WCHAR, *PWCHAR;
#endif
typedef WCHAR* BSTR;
typedef char CHAR, *PCHAR;
typedef DWORD *PDWORD, *LPDWORD;
#if WINPR_HAVE_STDINT_H
typedef uint32_t DWORD32;
typedef uint64_t DWORD64;
typedef uint64_t ULONGLONG;
#else
typedef unsigned int DWORD32;
typedef unsigned __int64 DWORD64;
typedef unsigned __int64 ULONGLONG;
#endif
typedef ULONGLONG DWORDLONG, *PDWORDLONG;
typedef float FLOAT;
typedef unsigned char UCHAR, *PUCHAR;
typedef short SHORT;
#ifndef FALSE
#if WINPR_HAVE_STDBOOL_H && !defined(__OBJC__)
#define FALSE false
#else
#define FALSE 0
#endif
#define FALSE 0
#endif
#ifndef TRUE
#if WINPR_HAVE_STDBOOL_H && !defined(__OBJC__)
#define TRUE true
#else
#define TRUE 1
#endif
#define TRUE 1
#endif
#define CONST const
#define CALLBACK
#ifndef XMD_H /* X11/Xmd.h typedef collision with BYTE */
typedef __uint8 BYTE;
#endif /* XMD_H */
typedef BYTE byte, *PBYTE, *LPBYTE;
typedef BYTE BOOLEAN, PBOOLEAN;
#if CHAR_BIT == 8
typedef char CHAR;
typedef unsigned char UCHAR;
#else
typedef __int8 CHAR;
typedef __uint8 UCHAR;
#endif
typedef CHAR CCHAR, *PCHAR, *LPCH, *PCH, *PSTR, *LPSTR;
typedef const CHAR *LPCCH, *PCCH, *LPCSTR, *PCSTR;
typedef UCHAR *PUCHAR;
typedef __uint16 WCHAR;
typedef WCHAR UNICODE, *PWCHAR, *LPWCH, *PWCH, *BSTR, *LMSTR, *LPWSTR, *PWSTR;
typedef const WCHAR *LPCWCH, *PCWCH, *LMCSTR, *LPCWSTR, *PCWSTR;
typedef __int16 SHORT, *PSHORT;
typedef __int32 INT, *PINT, *LPINT;
typedef __int32 LONG, *PLONG, *LPLONG;
typedef __int64 LONGLONG, *PLONGLONG;
typedef __uint32 UINT, *PUINT, *LPUINT;
typedef __uint16 USHORT, *PUSHORT;
typedef __uint32 ULONG, *PULONG;
typedef __uint64 ULONGLONG, *PULONGLONG;
#ifndef XMD_H /* X11/Xmd.h typedef collisions */
typedef __int8 INT8;
typedef __int16 INT16;
typedef __int32 INT32;
typedef __int64 INT64;
#endif
typedef INT8 *PINT8;
typedef INT16 *PINT16;
typedef INT32 *PINT32;
typedef INT64 *PINT64;
typedef __int32 LONG32, *PLONG32;
#ifndef LONG64 /* X11/Xmd.h uses/defines LONG64 */
typedef __int64 LONG64, *PLONG64;
#endif
typedef __uint8 UINT8, *PUINT8;
typedef __uint16 UINT16, *PUINT16;
typedef __uint32 UINT32, *PUINT32;
typedef __uint64 UINT64, *PUINT64;
typedef __uint64 ULONG64, *PULONG64;
typedef __uint16 WORD, *PWORD, *LPWORD;
typedef __uint32 DWORD, DWORD32, *PDWORD, *LPDWORD, *PDWORD32;
typedef __uint64 DWORD64, DWORDLONG, QWORD, *PDWORD64, *PDWORDLONG, *PQWORD;
typedef __int3264 INT_PTR, *PINT_PTR;
typedef __uint3264 UINT_PTR, *PUINT_PTR;
typedef __int3264 LONG_PTR, *PLONG_PTR;
typedef __uint3264 ULONG_PTR, *PULONG_PTR;
typedef __uint3264 DWORD_PTR, *PDWORD_PTR;
typedef ULONG_PTR SIZE_T, *PSIZE_T;
typedef LONG_PTR SSIZE_T, *PSSIZE_T;
typedef float FLOAT;
typedef double DOUBLE;
typedef void* HANDLE, *PHANDLE, *LPHANDLE;
typedef HANDLE HINSTANCE;
@ -193,106 +253,12 @@ typedef HANDLE HBRUSH;
typedef HANDLE HMENU;
typedef DWORD HCALL;
typedef int INT, *LPINT;
#ifndef XMD_H /* X11/Xmd.h typedef collision with INT8, INT16, INT32 and INT64 */
#if WINPR_HAVE_STDINT_H
typedef int8_t INT8;
typedef int16_t INT16;
typedef int32_t INT32;
typedef int64_t INT64;
#else
typedef signed char INT8;
typedef signed short INT16;
typedef signed int INT32;
typedef signed __int64 INT64;
#endif
#endif
typedef const WCHAR* LMCSTR;
typedef WCHAR* LMSTR;
typedef LONG *PLONG, *LPLONG;
#if WINPR_HAVE_STDINT_H
typedef int64_t LONGLONG;
#else
typedef signed __int64 LONGLONG;
#endif
typedef __int3264 LONG_PTR, *PLONG_PTR;
typedef __uint3264 ULONG_PTR, *PULONG_PTR;
#if WINPR_HAVE_STDINT_H
typedef int32_t LONG32;
#else
typedef signed int LONG32;
#endif
#ifndef XMD_H /* X11/Xmd.h defines LONG64 */
#if WINPR_HAVE_STDINT_H
typedef int64_t LONG64;
#else
typedef signed __int64 LONG64;
#endif
#endif
typedef CHAR *PSTR, *LPSTR, *LPCH;
typedef const CHAR *LPCSTR,*PCSTR;
typedef WCHAR *LPWSTR, *PWSTR, *LPWCH;
typedef const WCHAR *LPCWSTR,*PCWSTR;
typedef unsigned int UINT;
#if WINPR_HAVE_STDINT_H
typedef uint64_t QWORD;
typedef uint8_t UINT8;
typedef uint16_t UINT16;
typedef uint32_t UINT32;
typedef uint64_t UINT64;
#else
typedef unsigned __int64 QWORD;
typedef unsigned char UINT8;
typedef unsigned short UINT16;
typedef unsigned int UINT32;
typedef unsigned __int64 UINT64;
#endif
typedef ULONG *PULONG;
typedef ULONG error_status_t;
typedef LONG HRESULT;
typedef LONG SCODE;
typedef SCODE *PSCODE;
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;
typedef ULONG_PTR SIZE_T;
#if WINPR_HAVE_STDINT_H
typedef uint32_t ULONG32;
typedef uint64_t ULONG64;
typedef uint16_t USHORT;
typedef uint16_t WORD, *PWORD, *LPWORD;
#else
typedef unsigned int ULONG32;
typedef unsigned __int64 ULONG64;
typedef unsigned short USHORT;
typedef unsigned short WORD, *PWORD, *LPWORD;
#endif
typedef wchar_t UNICODE;
#define VOID void
typedef void *PVOID, *LPVOID;
typedef void *PVOID64, *LPVOID64;
#if WINPR_HAVE_STDINT_H
typedef intptr_t INT_PTR;
typedef uintptr_t UINT_PTR;
#elif __ILP64__ || __LP64__ || __LLP64__
typedef __int64 INT_PTR;
typedef unsigned __int64 UINT_PTR;
#else
typedef int INT_PTR;
typedef unsigned int UINT_PTR;
#endif
typedef struct _GUID
{
UINT32 Data1;
@ -437,33 +403,6 @@ typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
typedef void* FARPROC;
#endif
typedef BYTE byte;
typedef double DOUBLE;
typedef void* PCONTEXT_HANDLE;
typedef PCONTEXT_HANDLE* PPCONTEXT_HANDLE;
typedef ULONG error_status_t;
#ifndef _NTDEF_
typedef LONG NTSTATUS;
typedef NTSTATUS *PNTSTATUS;
#endif
#ifndef _LPCBYTE_DEFINED
#define _LPCBYTE_DEFINED
typedef const BYTE *LPCBYTE;
#endif
#ifndef _LPCVOID_DEFINED
#define _LPCVOID_DEFINED
typedef const VOID *LPCVOID;
#endif
#ifndef _WIN32
typedef struct tagDEC
{
USHORT wReserved;
@ -489,13 +428,101 @@ typedef DECIMAL *LPDECIMAL;
#define DECIMAL_NEG ((BYTE) 0x80)
#define DECIMAL_SETZERO(dec) { (dec).Lo64 = 0; (dec).Hi32 = 0; (dec).signscale = 0; }
typedef char CCHAR;
typedef DWORD LCID;
typedef PDWORD PLCID;
typedef WORD LANGID;
#endif /* _WIN32 not defined */
typedef void* PCONTEXT_HANDLE;
typedef PCONTEXT_HANDLE* PPCONTEXT_HANDLE;
#ifndef _NTDEF
typedef LONG NTSTATUS;
typedef NTSTATUS *PNTSTATUS;
#endif
#ifndef _LPCVOID_DEFINED
#define _LPCVOID_DEFINED
typedef const VOID *LPCVOID;
#endif
#ifndef _LPCBYTE_DEFINED
#define _LPCBYTE_DEFINED
typedef const BYTE *LPCBYTE;
#endif
/* integer format specifiers */
#ifndef WINPR_HAVE_INTTYPES_H
#define PRId8 "hhd"
#define PRIi8 "hhi"
#define PRIu8 "hhu"
#define PRIo8 "hho"
#define PRIx8 "hhx"
#define PRIX8 "hhX"
#define PRId16 "hd"
#define PRIi16 "hi"
#define PRIu16 "hu"
#define PRIo16 "ho"
#define PRIx16 "hx"
#define PRIX16 "hX"
#if defined(_MSC_VER)
#define PRId32 "I32d"
#define PRIi32 "I32i"
#define PRIu32 "I32u"
#define PRIo32 "I32o"
#define PRIx32 "I32x"
#define PRIX32 "I32X"
#define PRId64 "I64d"
#define PRIi64 "I64i"
#define PRIu64 "I64u"
#define PRIo64 "I64o"
#define PRIx64 "I64x"
#define PRIX64 "I64X"
#else
#define PRId32 "d"
#define PRIi32 "i"
#define PRIu32 "u"
#define PRIo32 "o"
#define PRIx32 "x"
#define PRIX32 "X"
#if ULONG_MAX == 0xFFFFFFFFFFFFFFFF
#define PRId64 "ld"
#define PRIi64 "li"
#define PRIu64 "lu"
#define PRIo64 "lo"
#define PRIx64 "lx"
#define PRIX64 "lX"
#else
#define PRId64 "lld"
#define PRIi64 "lli"
#define PRIu64 "llu"
#define PRIo64 "llo"
#define PRIx64 "llx"
#define PRIX64 "llX"
#endif
#endif /* _MSC_VER */
#endif /* WINPR_HAVE_INTTYPES_H not defined*/
#if defined(_MSC_VER) && _MSC_VER < 1900
/* %z not supported before MSVC 2015 */
#define PRIdz "Id"
#define PRIiz "Ii"
#define PRIuz "Iu"
#define PRIoz "Io"
#define PRIxz "Ix"
#define PRIXz "IX"
#else
#define PRIdz "zd"
#define PRIiz "zi"
#define PRIuz "zu"
#define PRIoz "zo"
#define PRIxz "zx"
#define PRIXz "zX"
#endif
#include <winpr/user.h>
#endif /* WINPR_WTYPES_H */