-
Notifications
You must be signed in to change notification settings - Fork 1
/
debug.h
290 lines (264 loc) · 6.92 KB
/
debug.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/****************************************************************************
*
* Copyright (C) 1996 SciTech Software
* All rights reserved.
*
* Filename: $Workfile: debug.h $
* Version: $Revision: 1.2 $
*
* Language: ANSI C
* Environment: any
*
* Description: General header file for operating system portable code.
*
* $Date: 2005-07-05 20:01:03 $ $Author: disconn3ct $
*
****************************************************************************/
#ifndef __DEBUG_H
#define __DEBUG_H
/* We have the following defines to identify the compilation environment:
*
* __16BIT__ Compiling for 16 bit code (any environment)
* __32BIT__ Compiling for 32 bit code (any environment)
* __MSDOS__ Compiling for MS-DOS (includes __WINDOWS16__, __WIN386__)
* __REALDOS__ Compiling for MS-DOS (excludes __WINDOWS16__)
* __MSDOS16__ Compiling for 16 bit MS-DOS
* __MSDOS32__ Compiling for 32 bit MS-DOS
* __WINDOWS__ Compiling for Windows
* __WINDOWS16__ Compiling for 16 bit Windows (__MSDOS__ also defined)
* __WINDOWS32__ Compiling for 32 bit Windows
* __WIN386__ Compiling for Watcom C++ Win386 extended Windows
* __OS2__ Compiling for OS/2
* __OS2_16__ Compiling for 16 bit OS/2
* __OS2_32__ Compiling for 32 bit OS/2
* __UNIX__ Compiling for Unix
*
*/
#ifdef __SC__
#if __INTSIZE == 4
#define __SC386__
#endif
#endif
#ifdef __GNUC__
#define __cdecl /* GCC doesn't know about __cdecl modifiers */
#define __FLAT__ /* GCC is always 32 bit flat model */
#define __HAS_BOOL__ /* Latest GNU C++ has bool type */
#endif
#ifdef __BORLANDC__
#if (__BORLANDC__ >= 0x500) || defined(CLASSLIB_DEFS_H)
#define __HAS_BOOL__ /* Borland C++ 5.0 and later define bool type */
#endif
#endif
/* For the Metaware High C/C++ compiler, there is no _cdecl calling
* convention. The conventions can be changed, but it is a complicated
* process involving #pragmas, and all externally referenced functions
* will use stack based calling conventions. We also need to change the
* global aliasing conventions to use underscores for external function
* and variables names, so that our assembler routines will link
* correctly (except of course the main function - man what a PAIN!).
*/
#ifdef __HIGHC__
#define __cdecl
#define __FLAT__ /* High C is always 32 bit flat model */
#pragma Global_aliasing_convention("_%r")
extern main();
#pragma Alias(main,"main")
#endif
#if defined(__MSDOS__) || defined(__DOS__) || defined(__DPMI32__) || (defined(M_I86) && !defined(__SC386__))
#ifndef __MSDOS__
#define __MSDOS__
#endif
#if defined(__386__) || defined(__FLAT__) || defined(__NT__) || defined(__SC386__)
#ifndef __MSDOS32__
#define __MSDOS32__
#endif
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __REALDOS__
#define __REALDOS__
#endif
#elif (defined(_Windows) || defined(_WINDOWS)) && !defined(__DPMI16__)
#ifndef __16BIT__
#define __16BIT__
#endif
#ifndef __WINDOWS16__
#define __WINDOWS16__
#endif
#ifndef __WINDOWS__
#define __WINDOWS__
#endif
#ifndef __MSDOS__
#define __MSDOS__
#endif
#else
#ifndef __16BIT__
#define __16BIT__
#endif
#ifndef __MSDOS16__
#define __MSDOS16__
#endif
#ifndef __REALDOS__
#define __REALDOS__
#endif
#endif
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __WINDOWS32__
#define __WINDOWS32__
#endif
#ifndef _WIN32
#define _WIN32 /* Microsoft Win32 SDK headers use _WIN32 */
#endif
#ifndef WIN32
#define WIN32 /* OpenGL headers use WIN32 */
#endif
#ifndef __WINDOWS__
#define __WINDOWS__
#endif
#elif defined(__WINDOWS_386__)
#ifndef __32BIT__
#define __32BIT__
#endif
#ifndef __WIN386__
#define __WIN386__
#endif
#ifndef __WINDOWS__
#define __WINDOWS__
#endif
#ifndef __MSDOS__
#define __MSDOS__
#endif
#elif defined(__OS2__)
#ifndef __OS2__ /* TODO: to be completed */
#define __OS2__
#define __OS2_32__ /* Default to 32 bit OS/2 */
#endif
#else
#define __UNIX__ /* TODO: to be completed */
#endif
/* We have the following defines to define the calling conventions for
* publicly accesible functions:
*
* _PUBAPI - Compiler default calling conventions for all public 'C' functions
* _ASMAPI - Calling conventions for all public assembler functions
* _DLLAPI - Calling conventions for all DLL exported functions
* _DLLVAR - Modifier to export/import globals in 32 bit DLL's
* _EXPORT - Expands to _export when compiling a DLL
* _VARAPI - Modifiers for variables; Watcom C++ mangles C++ globals
*/
#define _PUBAPI
#define _ASMAPI __cdecl
#if defined(_MSC_VER) && defined(_WIN32) && !defined(__SC__)
#define __PASCAL __stdcall
#define __export
#define __import
#else
#define __PASCAL __pascal
#endif
#if defined(__WATCOMC__)
#define _VARAPI __cdecl
#else
#define _VARAPI
#endif
#if defined(__WINDOWS__)
#ifdef BUILD_DLL
#define _DLLASM __export __cdecl
#define _EXPORT __export
#ifdef __WINDOWS32__
#define _DLLAPI __export __PASCAL
#define _DLLVAR __export
#else
#define _DLLAPI __export __far __pascal
#define _DLLVAR
#endif
#else
#define _DLLASM __cdecl
#define _EXPORT
#ifdef __WINDOWS32__
#define _DLLAPI __PASCAL
#define _DLLVAR __import
#else
#define _DLLAPI __far __pascal
#define _DLLVAR
#endif
#endif
#else
#define _EXPORT
#define _DLLAPI
#define _DLLVAR
#endif
/* Useful macros */
#define PRIVATE static
#define PUBLIC
#ifdef DEBUG
# define DBG(x) x
#else
# define DBG(x)
#endif
#ifndef NULL
# define NULL 0L
#endif
#ifndef MAX
# define MAX(a,b) ( ((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
# define MIN(a,b) ( ((a) < (b)) ? (a) : (b))
#endif
#ifndef ABS
# define ABS(a) ((a) >= 0 ? (a) : -(a))
#endif
#ifndef SIGN
# define SIGN(a) ((a) > 0 ? 1 : -1)
#endif
/* General typedefs */
#ifndef __GENDEFS
#define __GENDEFS
typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef int ibool; /* Integer boolean type */
#ifndef __cplusplus
#define bool ibool /* Standard C */
#else
#ifndef __HAS_BOOL__
#define bool ibool /* Older C++ compilers */
#endif
#endif /* __cplusplus */
#endif /* __GENDEFS */
/* Includes Windows headers, as they define TRUE and FALSE */
#ifdef __WINDOWS__
#ifndef _WINDOWS_ /* Dont include if already included */
#ifndef __WIN386__
#define STRICT
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#endif
#endif
/* Boolean truth values */
#undef false
#undef true
#undef NO
#undef YES
#undef FALSE
#undef TRUE
#ifdef __cplusplus /* Cast to bool's for C++ code */
#define false ((bool)0)
#define true ((bool)1)
#define NO ((bool)0)
#define YES ((bool)1)
#define FALSE ((bool)0)
#define TRUE ((bool)1)
#else /* Define to 0 and 1 for C code */
#define false 0
#define true 1
#define NO 0
#define YES 1
#define FALSE 0
#define TRUE 1
#endif
#endif /* __DEBUG_H */