ReactOS 0.4.16-dev-257-g6aa11ac
typedefs.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Host Headers
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Type definitions and useful macros for host tools
5 * COPYRIGHT: Copyright 2007 Hervé Poussineau (hpoussin@reactos.org)
6 * Copyright 2007 Colin Finck (colin@reactos.org)
7 */
8
9#ifndef _TYPEDEFS_HOST_H
10#define _TYPEDEFS_HOST_H
11
12#include <assert.h>
13#include <stdlib.h>
14#include <limits.h>
15#include <stdint.h>
16
17/* Function attributes for GCC */
18#if !defined(_MSC_VER) && !defined(__fastcall)
19#define __fastcall __attribute__((fastcall))
20#endif
21#if !defined(_MSC_VER) && !defined(__cdecl)
22#define __cdecl __attribute__((cdecl))
23#endif
24#if !defined(_MSC_VER) && !defined(__stdcall)
25#define __stdcall __attribute__((stdcall))
26#endif
27
28/* Basic definitions */
29#define UNIMPLEMENTED { printf("%s unimplemented\n", __FUNCTION__); exit(1); }
30#define UNIMPLEMENTED_ONCE { printf("%s unimplemented\n", __FUNCTION__); exit(1); }
31#define ASSERT(x) assert(x)
32#define ASSERTMSG(m, x) assert(x)
33#define DPRINT if (0) printf
34#define DPRINT1 printf
35
36#define NTAPI
37#define WINAPI
38
39#define IN
40#define OUT
41#define OPTIONAL
42
43#define FALSE 0
44#define TRUE 1
45
46#define ANYSIZE_ARRAY 1
47
48/* Basic types
49 Emulate a LLP64 memory model using a LP64 compiler */
50typedef void VOID, *PVOID, *LPVOID;
51typedef char CHAR, CCHAR, *PCHAR, *PSTR, *LPSTR;
52typedef const char *PCSTR, *LPCSTR;
53typedef unsigned char UCHAR, *PUCHAR, BYTE, *LPBYTE, BOOLEAN, *PBOOLEAN;
54typedef uint8_t UINT8;
57typedef const uint16_t *PCWSTR, *LPCWSTR;
60#if defined(_LP64) || defined(_WIN64)
63#else
66#endif
69typedef float FLOAT;
70typedef double DOUBLE;
71
72/* Derived types */
73typedef PVOID HANDLE;
74#ifndef _HAVE_HKEY
75typedef HANDLE HKEY, *PHKEY;
76#endif
79typedef LONG HRESULT;
81typedef WORD LANGID;
82
83#define MAXUSHORT USHRT_MAX
84
85/* Widely used structures */
86
87#ifndef _HAVE_RTL_BITMAP
88typedef struct _RTL_BITMAP
89{
93
94typedef struct _RTL_BITMAP_RUN
95{
99#endif
100
101#ifndef _HAVE_LARGE_INTEGER
102typedef union _LARGE_INTEGER
103{
104 struct
105 {
108 };
109 struct
110 {
113 } u;
116#endif
117
118#ifndef _HAVE_LIST_ENTRY
119typedef struct _LIST_ENTRY
120{
124#endif
125
126#ifndef _HAVE_ANSI_STRING
127typedef struct _ANSI_STRING
128{
131 PSTR Buffer;
133
134typedef struct _UNICODE_STRING
135{
140#endif
141
142
143#ifndef _HAVE_LIST_ENTRY
144/* List Functions */
145static __inline
146VOID
148 IN PLIST_ENTRY ListHead
149 )
150{
151 ListHead->Flink = ListHead->Blink = ListHead;
152}
153
154static __inline
155VOID
157 IN PLIST_ENTRY ListHead,
159 )
160{
161 PLIST_ENTRY OldFlink;
162 OldFlink = ListHead->Flink;
163 Entry->Flink = OldFlink;
164 Entry->Blink = ListHead;
165 OldFlink->Blink = Entry;
166 ListHead->Flink = Entry;
167}
168
169static __inline
170VOID
172 IN PLIST_ENTRY ListHead,
174 )
175{
176 PLIST_ENTRY OldBlink;
177 OldBlink = ListHead->Blink;
178 Entry->Flink = ListHead;
179 Entry->Blink = OldBlink;
180 OldBlink->Flink = Entry;
181 ListHead->Blink = Entry;
182}
183
184static __inline
187 IN const LIST_ENTRY * ListHead
188 )
189{
190 return (BOOLEAN)(ListHead->Flink == ListHead);
191}
192
193static __inline
197{
198 PLIST_ENTRY OldFlink;
199 PLIST_ENTRY OldBlink;
200
201 OldFlink = Entry->Flink;
202 OldBlink = Entry->Blink;
203 OldFlink->Blink = OldBlink;
204 OldBlink->Flink = OldFlink;
205 return (BOOLEAN)(OldFlink == OldBlink);
206}
207
208static __inline
211 IN PLIST_ENTRY ListHead)
212{
213 PLIST_ENTRY Flink;
215
216 Entry = ListHead->Flink;
217 Flink = Entry->Flink;
218 ListHead->Flink = Flink;
219 Flink->Blink = ListHead;
220 return Entry;
221}
222
223static __inline
226 IN PLIST_ENTRY ListHead)
227{
228 PLIST_ENTRY Blink;
230
231 Entry = ListHead->Blink;
232 Blink = Entry->Blink;
233 ListHead->Blink = Blink;
234 Blink->Flink = ListHead;
235 return Entry;
236}
237#endif
238
239#ifndef _HAVE_ANSI_STRING
241#endif
242
243/* Widely used macros */
244#define LOBYTE(w) ((BYTE)(w))
245#define HIBYTE(w) ((BYTE)(((WORD)(w)>>8)&0xFF))
246#define LOWORD(l) ((WORD)((DWORD_PTR)(l)))
247#define HIWORD(l) ((WORD)(((DWORD_PTR)(l)>>16)&0xFFFF))
248#define MAKEWORD(a,b) ((WORD)(((BYTE)(a))|(((WORD)((BYTE)(b)))<<8)))
249#define MAKELONG(a,b) ((LONG)(((WORD)(a))|(((DWORD)((WORD)(b)))<<16)))
250
251#define MAXULONG 0xFFFFFFFF
252
253#define NT_SUCCESS(x) ((x)>=0)
254#if !defined(__GNUC__)
255#define FIELD_OFFSET(t,f) ((LONG)(LONG_PTR)&(((t*) 0)->f))
256#else
257#define FIELD_OFFSET(t,f) ((LONG)__builtin_offsetof(t,f))
258#endif
259#define RTL_CONSTANT_STRING(s) { sizeof(s)-sizeof((s)[0]), sizeof(s), s }
260#define CONTAINING_RECORD(address, type, field) ((type *)(((ULONG_PTR)address) - (ULONG_PTR)(&(((type *)0)->field))))
261
262#define RtlZeroMemory(Destination, Length) memset(Destination, 0, Length)
263#define RtlCopyMemory(Destination, Source, Length) memcpy(Destination, Source, Length)
264#define RtlMoveMemory(Destination, Source, Length) memmove(Destination, Source, Length)
265
266#define MAKELANGID(p,s) ((((WORD)(s))<<10)|(WORD)(p))
267#define PRIMARYLANGID(l) ((WORD)(l)&0x3ff)
268#define SUBLANGID(l) ((WORD)(l)>>10)
269#define SUBLANG_NEUTRAL 0x00
270
271/* Prevent inclusion of some other headers */
272#define __INTERNAL_DEBUG
273#define RTL_H
274
275#endif
276
unsigned char BOOLEAN
unsigned short int uint16_t
Definition: acefiex.h:54
INT32 int32_t
Definition: types.h:71
UINT32 uint32_t
Definition: types.h:75
INT16 int16_t
Definition: types.h:70
UINT64 uint64_t
Definition: types.h:77
INT64 int64_t
Definition: types.h:72
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveTailList(ListHead)
Definition: env_spec_w32.h:975
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
unsigned short WORD
Definition: ntddk_ex.h:93
BYTE uint8_t
Definition: msvideo1.c:66
long LONG
Definition: ntbasedef.h:350
unsigned long ULONG
Definition: ntbasedef.h:362
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
base of all file and directory entries
Definition: entries.h:83
USHORT MaximumLength
Definition: env_spec_w32.h:377
Definition: typedefs.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
ULONG NumberOfBits
Definition: typedefs.h:97
ULONG StartingIndex
Definition: typedefs.h:96
ULONG SizeOfBitMap
Definition: typedefs.h:90
PULONG Buffer
Definition: typedefs.h:91
USHORT MaximumLength
Definition: env_spec_w32.h:370
HANDLE HINSTANCE
Definition: typedefs.h:77
ULONG_PTR * PSIZE_T
Definition: typedefs.h:80
uint32_t * PUINT
Definition: typedefs.h:59
uint64_t * PDWORD64
Definition: typedefs.h:67
uint32_t UINT_PTR
Definition: typedefs.h:65
uint16_t * PWSTR
Definition: typedefs.h:56
unsigned char BOOLEAN
Definition: typedefs.h:53
uint32_t * PUINT_PTR
Definition: typedefs.h:65
WORD LANGID
Definition: typedefs.h:81
uint32_t * PULONG_PTR
Definition: typedefs.h:65
int32_t LONG
Definition: typedefs.h:58
struct _RTL_BITMAP * PRTL_BITMAP
int32_t INT_PTR
Definition: typedefs.h:64
int64_t INT64
Definition: typedefs.h:68
int32_t * PLONG_PTR
Definition: typedefs.h:64
const char * LPCSTR
Definition: typedefs.h:52
int32_t INT32
Definition: typedefs.h:58
uint32_t UINT
Definition: typedefs.h:59
uint32_t * PDWORD
Definition: typedefs.h:59
HANDLE * PHKEY
Definition: typedefs.h:75
uint32_t * PULONG
Definition: typedefs.h:59
int32_t LONG_PTR
Definition: typedefs.h:64
char * PSTR
Definition: typedefs.h:51
const uint16_t * PCWSTR
Definition: typedefs.h:57
int64_t LONG64
Definition: typedefs.h:68
unsigned char BYTE
Definition: typedefs.h:53
unsigned char UCHAR
Definition: typedefs.h:53
int32_t WINBOOL
Definition: typedefs.h:58
uint32_t DWORD_PTR
Definition: typedefs.h:65
HANDLE HKEY
Definition: typedefs.h:75
int32_t * PINT_PTR
Definition: typedefs.h:64
uint16_t WCHAR
Definition: typedefs.h:56
uint16_t USHORT
Definition: typedefs.h:56
void * LPVOID
Definition: typedefs.h:50
uint16_t * PWORD
Definition: typedefs.h:56
unsigned char * PBOOLEAN
Definition: typedefs.h:53
int16_t SHORT
Definition: typedefs.h:55
uint64_t DWORD64
Definition: typedefs.h:67
struct _ANSI_STRING * PANSI_STRING
const uint16_t * LPCWSTR
Definition: typedefs.h:57
struct _ANSI_STRING ANSI_STRING
struct _LIST_ENTRY * PLIST_ENTRY
unsigned char * LPBYTE
Definition: typedefs.h:53
uint16_t * LPWORD
Definition: typedefs.h:56
float FLOAT
Definition: typedefs.h:69
INT POOL_TYPE
Definition: typedefs.h:78
int32_t * LPLONG
Definition: typedefs.h:58
int64_t LONGLONG
Definition: typedefs.h:68
uint64_t UINT64
Definition: typedefs.h:67
int16_t * PSHORT
Definition: typedefs.h:55
uint16_t * LPWSTR
Definition: typedefs.h:56
int32_t BOOL
Definition: typedefs.h:58
union _LARGE_INTEGER LARGE_INTEGER
struct _UNICODE_STRING * PUNICODE_STRING
void * PVOID
Definition: typedefs.h:50
PVOID HANDLE
Definition: typedefs.h:73
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t * LPDWORD
Definition: typedefs.h:59
struct _RTL_BITMAP_RUN RTL_BITMAP_RUN
int32_t INT
Definition: typedefs.h:58
LONG HRESULT
Definition: typedefs.h:79
struct _RTL_BITMAP_RUN * PRTL_BITMAP_RUN
uint16_t * PUSHORT
Definition: typedefs.h:56
uint16_t WORD
Definition: typedefs.h:56
const char * PCSTR
Definition: typedefs.h:52
char * LPSTR
Definition: typedefs.h:51
uint64_t ULONG64
Definition: typedefs.h:67
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
struct _UNICODE_STRING UNICODE_STRING
int32_t * PLONG
Definition: typedefs.h:58
uint16_t UINT16
Definition: typedefs.h:56
void VOID
Definition: typedefs.h:50
union _LARGE_INTEGER * PLARGE_INTEGER
Definition: file.c:85
uint16_t * PWCHAR
Definition: typedefs.h:56
HANDLE HMODULE
Definition: typedefs.h:77
INT NTSTATUS
Definition: typedefs.h:78
uint32_t UINT32
Definition: typedefs.h:59
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
uint32_t * LPUINT
Definition: typedefs.h:59
double DOUBLE
Definition: typedefs.h:70
char CHAR
Definition: typedefs.h:51
struct _RTL_BITMAP RTL_BITMAP
uint8_t UINT8
Definition: typedefs.h:54
uint32_t DWORD
Definition: typedefs.h:59
char CCHAR
Definition: typedefs.h:51
char * PCHAR
Definition: typedefs.h:51
struct _LIST_ENTRY LIST_ENTRY
const UNICODE_STRING * PCUNICODE_STRING
Definition: typedefs.h:240
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2302 u
ULONG LowPart
Definition: typedefs.h:106