debug.h 6.9 KB

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