2019-12-01 01:02:08 -07:00
|
|
|
#ifndef __WINTYPE_H_INCLUDED
|
|
|
|
#define __WINTYPE_H_INCLUDED
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2019-12-02 23:30:46 -07:00
|
|
|
/* Integral limit values */
|
|
|
|
/*#define INT16_MIN 0x8000 - defined in stdint.h */
|
|
|
|
/*#define INT16_MAX 0x7FFF - defined in stdint.h */
|
|
|
|
#define UINT16_MIN 0
|
|
|
|
/*#define UINT16_MAX 0xFFFF - defined in stdint.h*/
|
|
|
|
/*#define INT32_MIN 0x80000000 - defined in stdint.h*/
|
|
|
|
/*#define INT32_MAX 0x7FFFFFFF - defined in stdint.h*/
|
|
|
|
#define UINT32_MIN 0
|
|
|
|
/*#define UINT32_MAX 0xFFFFFFFF - defined in stdint.h*/
|
|
|
|
/*#define INT64_MIN 0x8000000000000000 - defined in stdint.h*/
|
|
|
|
/*#define INT64_MAX 0x7FFFFFFFFFFFFFFF - defined in stdint.h*/
|
|
|
|
#define UINT64_MIN 0
|
|
|
|
/*#define UINT64_MAX 0xFFFFFFFFFFFFFFFF - defined in stdint.h*/
|
|
|
|
|
|
|
|
#define INT_PTR_MIN INTPTR_MIN
|
|
|
|
#define INT_PTR_MAX INTPTR_MAX
|
|
|
|
#define UINT_PTR_MIN 0
|
|
|
|
#define UINT_PTR_MAX UINTPTR_MAX
|
|
|
|
#define DWORD_MIN UINT32_MIN
|
|
|
|
#define DWORD_MAX UINT32_MAX
|
|
|
|
|
|
|
|
/* Number of bits */
|
|
|
|
#define INT16_BITS 16
|
|
|
|
#define UINT16_BITS 16
|
|
|
|
#define INT32_BITS 32
|
|
|
|
#define UINT32_BITS 32
|
|
|
|
#define INT64_BITS 64
|
|
|
|
#define UINT64_BITS 64
|
|
|
|
|
2019-12-07 13:07:59 -07:00
|
|
|
#define LOG_PTRSIZE 2 /* log2(sizeof(void *)) */
|
2019-12-02 23:30:46 -07:00
|
|
|
|
|
|
|
#define LOG_INTSIZE 2 /* log2(sizeof(int)) */
|
|
|
|
#define LOG_UINTSIZE 2 /* log2(sizeof(UINT32)) */
|
|
|
|
#define LOG_INT64SIZE 3 /* log2(sizeof(long long)) */
|
|
|
|
|
|
|
|
#define PTRSIZE (1U << LOG_PTRSIZE)
|
|
|
|
#define PTR_MASK (PTRSIZE - 1)
|
|
|
|
#define PTR_CEILING(a) (((a) + PTR_MASK) & ~PTR_MASK)
|
|
|
|
|
|
|
|
/* Boolean values */
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
|
|
|
|
|
|
|
/* NULL value */
|
|
|
|
#ifndef NULL
|
|
|
|
#define NULL 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Integral types */
|
|
|
|
typedef int16_t INT16;
|
|
|
|
typedef uint16_t UINT16;
|
|
|
|
typedef int32_t INT32;
|
|
|
|
typedef uint32_t UINT32;
|
|
|
|
typedef int64_t INT64;
|
|
|
|
typedef uint64_t UINT64;
|
|
|
|
|
|
|
|
typedef UINT16 WORD;
|
|
|
|
typedef UINT32 DWORD;
|
|
|
|
typedef UINT64 QWORD;
|
|
|
|
typedef INT32 LONG;
|
|
|
|
typedef UINT32 ULONG;
|
|
|
|
typedef INT64 LONG64;
|
|
|
|
typedef UINT64 ULONG64;
|
|
|
|
|
|
|
|
typedef INT32 INT;
|
|
|
|
typedef UINT32 UINT;
|
|
|
|
|
|
|
|
typedef INT64 LONGLONG;
|
|
|
|
typedef UINT64 ULONGLONG;
|
|
|
|
|
|
|
|
typedef intptr_t INT_PTR;
|
|
|
|
typedef uintptr_t UINT_PTR;
|
|
|
|
|
|
|
|
typedef UINT_PTR SIZE_T;
|
|
|
|
typedef INT_PTR SSIZE_T;
|
|
|
|
|
|
|
|
/* Base pointer types */
|
|
|
|
typedef INT16 *PINT16;
|
|
|
|
typedef UINT16 *PUINT16;
|
|
|
|
typedef INT32 *PINT32;
|
|
|
|
typedef UINT32 *PUINT32;
|
|
|
|
typedef INT64 *PINT64;
|
|
|
|
typedef UINT64 *PUINT64;
|
|
|
|
typedef SIZE_T *PSIZE_T;
|
|
|
|
typedef void *PVOID;
|
|
|
|
typedef const void *PCVOID;
|
|
|
|
typedef WORD *PWORD;
|
|
|
|
typedef DWORD *PDWORD;
|
|
|
|
typedef QWORD *PQWORD;
|
|
|
|
typedef LONGLONG *PLONGLONG;
|
|
|
|
typedef ULONGLONG *PULONGLONG;
|
|
|
|
|
|
|
|
/* Pointer-to-pointer types */
|
|
|
|
typedef PVOID *PPVOID;
|
|
|
|
|
|
|
|
/* Character types */
|
|
|
|
typedef char CHAR;
|
|
|
|
typedef unsigned char UCHAR;
|
|
|
|
typedef unsigned char BYTE;
|
|
|
|
typedef uint16_t WCHAR;
|
|
|
|
|
|
|
|
typedef CHAR *PCHAR;
|
|
|
|
typedef const CHAR *PCCHAR;
|
|
|
|
typedef UCHAR *PUCHAR;
|
|
|
|
typedef BYTE *PBYTE;
|
|
|
|
typedef const BYTE *PCBYTE;
|
|
|
|
typedef WCHAR *PWCHAR;
|
|
|
|
typedef const WCHAR *PCWCHAR;
|
|
|
|
typedef PCCHAR *PPCCHAR;
|
|
|
|
typedef CHAR *PSTR;
|
|
|
|
typedef const CHAR *PCSTR;
|
|
|
|
typedef WCHAR *PWSTR;
|
|
|
|
typedef const WCHAR *PCWSTR;
|
|
|
|
|
2019-12-07 22:05:31 -07:00
|
|
|
typedef PCSTR *PPCSTR;
|
|
|
|
|
2019-12-02 23:30:46 -07:00
|
|
|
/* Boolean type */
|
|
|
|
typedef int BOOL;
|
|
|
|
|
|
|
|
/* Handle type */
|
|
|
|
typedef UINT_PTR HANDLE;
|
|
|
|
typedef HANDLE *PHANDLE;
|
|
|
|
|
|
|
|
/* Status code/result types */
|
|
|
|
typedef UINT32 SCODE;
|
|
|
|
typedef SCODE *PSCODE;
|
|
|
|
typedef SCODE HRESULT;
|
|
|
|
|
|
|
|
typedef UINT64 TIMESTAMP;
|
|
|
|
|
|
|
|
#define MAKEBOOL(val) ((val) ? TRUE : FALSE)
|
|
|
|
#define OFFSETOF(struc, field) ((UINT_PTR)(&(((struc *)0)->field)))
|
2019-12-06 20:29:11 -07:00
|
|
|
#ifndef MIN
|
2019-12-02 23:30:46 -07:00
|
|
|
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
2019-12-06 20:29:11 -07:00
|
|
|
#endif
|
|
|
|
#ifndef MAX
|
2019-12-02 23:30:46 -07:00
|
|
|
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
2019-12-06 20:29:11 -07:00
|
|
|
#endif
|
2019-12-06 23:26:13 -07:00
|
|
|
#define ABS(v) ((v) < 0 ? -(v) : (v))
|
2019-12-02 23:30:46 -07:00
|
|
|
|
|
|
|
#define MAKEWORD(a, b) ((WORD)((((UINT_PTR)(a)) & 0xFF) | ((((UINT_PTR)(b)) & 0xFF) << 8)))
|
|
|
|
#define MAKELONG(a, b) ((LONG)((((UINT_PTR)(a)) & 0xFFFF) | ((((UINT_PTR)(b)) & 0xFFFF) << 16)))
|
|
|
|
#define MAKELONG64(a, b) ((LONG64)((((UINT64)(a)) & 0xFFFFFFFF) | ((((UINT64)(b)) & 0xFFFFFFFF) << 32)))
|
|
|
|
#define LODWORD(l) ((DWORD)(((UINT64)(l)) & 0xFFFFFFFF))
|
|
|
|
#define HIDWORD(l) ((DWORD)((((UINT64)(l)) >> 32) & 0xFFFFFFFF))
|
|
|
|
#define LOWORD(l) ((WORD)(((UINT_PTR)(l)) & 0xFFFF))
|
|
|
|
#define HIWORD(l) ((WORD)((((UINT_PTR)(l)) >> 16) & 0xFFFF))
|
|
|
|
#define LOBYTE(w) ((BYTE)(((UINT_PTR)(w)) & 0xFF))
|
|
|
|
#define HIBYTE(w) ((BYTE)((((UINT_PTR)(w)) >> 8) & 0xFF))
|
2019-12-01 01:02:08 -07:00
|
|
|
|
|
|
|
#endif /* __WINTYPE_H_INCLUDED */
|