upiwin/src/wintype.h

176 lines
5.0 KiB
C

/*
* UPIWIN - Micro Pi Windowing Framework Kernel
* Copyright (C) 2019 Amy Bowersox/Erbosoft Metaverse Design Solutions
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*-------------------------------------------------------------------------
*/
#ifndef __WINTYPE_H_INCLUDED
#define __WINTYPE_H_INCLUDED
#include <stdint.h>
/* 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
#define LOG_PTRSIZE 2 /* log2(sizeof(void *)) */
#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;
typedef PCSTR *PPCSTR;
/* 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)))
#ifndef MIN
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
#endif
#ifndef MAX
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#endif
#define ABS(v) ((v) < 0 ? -(v) : (v))
#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))
#endif /* __WINTYPE_H_INCLUDED */