You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

197 lines
5.9 KiB

28 years ago
28 years ago
28 years ago
  1. /****************************************************************************
  2. *
  3. * Copyright (C) 1991 Kendall Bennett.
  4. * All rights reserved.
  5. *
  6. * Filename: $RCSfile$
  7. * Version: $Revision$
  8. *
  9. * Language: ANSI C
  10. * Environment: any
  11. *
  12. * Description: General header file for portable code.
  13. *
  14. * $Id$
  15. *
  16. * Revision History:
  17. * -----------------
  18. *
  19. * $Log$
  20. * Revision 1.1 1999/04/21 23:37:47 ssb
  21. * moved db
  22. *
  23. * Revision 1.1.1.1 1999/04/07 21:03:29 zeev
  24. * PHP 4.0
  25. *
  26. * Revision 1.1.1.1 1999/03/17 04:29:10 andi
  27. * PHP4
  28. *
  29. * Revision 1.1.1.1 1998/12/21 07:56:22 andi
  30. * Trying to start the zend CVS tree
  31. *
  32. * Revision 1.1 1998/08/12 09:29:16 steinm
  33. * First version of Hyperwave module.
  34. *
  35. * Revision 1.6 92/03/15 12:51:48 kjb
  36. * Added MK_FP macro and ushort typedef.
  37. *
  38. * Revision 1.5 91/10/28 03:17:33 kjb
  39. * Ported to the Iris.
  40. *
  41. * Revision 1.4 91/09/26 15:29:02 kjb
  42. * Added stuff for the SGI Iris 4D.
  43. *
  44. * Revision 1.3 91/09/26 10:07:04 kjb
  45. * Added general typedef stuff.
  46. *
  47. * Revision 1.2 91/09/03 18:19:14 ROOT_DOS
  48. * Added a few defines that are supplied by <dir.h> for UNIX compatibility.
  49. *
  50. * Revision 1.1 91/08/16 13:19:06 ROOT_DOS
  51. * Initial revision
  52. *
  53. ****************************************************************************/
  54. #ifndef DEBUG_H
  55. #define DEBUG_H
  56. #ifdef DEBUG
  57. # define D(x) x
  58. #else
  59. # define D(x)
  60. #endif
  61. #define PRIVATE static
  62. #define PUBLIC
  63. #ifdef __MSDOS__ /* Compiling for MSDOS */
  64. # define MS(x) x
  65. # define UX(x)
  66. # define IR(x)
  67. # define _8086 /* We know we have an 8086 type processor */
  68. #if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
  69. # define LDATA
  70. # define NULL 0L
  71. #else
  72. # define NULL 0
  73. #endif
  74. #else __MSDOS__
  75. #ifdef __IRIS4D__ /* Compiling for the SGI Iris 4D */
  76. # define MS(x)
  77. # define UX(x) x /* The Iris is a UNIX machine */
  78. # define IR(x) x
  79. # define O_BINARY 0 /* no binary input mode in UNIX open() */
  80. # define MAXFILE 255 /* These are defined in <dir.h>, but */
  81. # define MAXDIR 255 /* on UNIX machines, we just define */
  82. # define MAXPATH 255 /* them all to be the same size */
  83. # define far /* Near and far do not exist under */
  84. # define near /* UNIX or the Iris. */
  85. # define NULL ((void *)0)
  86. #else __IRIS4D__ /* Assume UNIX compilation */
  87. # define MS(x)
  88. # define UX(x) x
  89. # define IR(x)
  90. # define O_BINARY 0 /* no binary input mode in UNIX open() */
  91. # define MAXFILE 255 /* These are defined in <dir.h>, but */
  92. # define MAXDIR 255 /* on UNIX machines, we just define */
  93. # define MAXPATH 255 /* them all to be the same size */
  94. # define far /* Near and far do not exist under */
  95. # define near /* UNIX or the Iris. */
  96. # ifndef NULL
  97. # define NULL ((void *)0)
  98. # endif
  99. #endif __IRIS4D__
  100. #endif __MSDOS__
  101. /****************************************************************************
  102. *
  103. * SEG(p) Evaluates to the segment portion of an 8086 address.
  104. * OFF(p) Evaluates to the offset portion of an 8086 address.
  105. * FP(s,o) Creates a far pointer given a segment offset pair.
  106. * PHYS(p) Evaluates to a long holding a physical address
  107. *
  108. ****************************************************************************/
  109. #ifdef _8086
  110. # define SEG(p) ( ((unsigned *)&(void far *)(p))[1] )
  111. # define OFF(p) ( (unsigned)(p) )
  112. # define FP(s,o) ( (void far *)( ((unsigned long)s << 16) + \
  113. (unsigned long)o ))
  114. # define PHYS(p) ( (unsigned long)OFF(p) + \
  115. ((unsigned long)SEG(p) << 4))
  116. #else
  117. # define PHYS(p) (p)
  118. #endif _8086
  119. /****************************************************************************
  120. *
  121. * NUMELE(array) Evaluates to the array size in elements
  122. * LASTELE(array) Evaluates to a pointer to the last element
  123. * INBOUNDS(array,p) Evaluates to true if p points into the array
  124. * RANGE(a,b,c) Evaluates to true if a <= b <= c
  125. * max(a,b) Evaluates to a or b, whichever is larger
  126. * min(a,b) Evaluates to a or b, whichever is smaller
  127. * ABS(a) Evaluates to the absolute value of a
  128. * NBITS(type) Returns the number of bits in a variable of the
  129. * indicated type
  130. * MAXINT Evaluates to the value of the largest signed integer
  131. *
  132. ****************************************************************************/
  133. #define NUMELE(a) (sizeof(a)/sizeof(*(a)))
  134. #define LASTELE(a) ((a) + (NUMELE(a)-1))
  135. #ifdef LDATA
  136. #define TOOHIGH(a,p) ((long)PHYS(p) - (long)PHYS(a) > (long)(NUMELE(a)-1))
  137. #define TOOLOW(a,p) ((long)PHYS(p) - (long)PHYS(a) < 0)
  138. #else
  139. #define TOOHIGH(a,p) ((long)(p) - (long)(a) > (long)(NUMELE(a)-1))
  140. #define TOOLOW(a,p) ((long)(p) - (long)(a) < 0)
  141. #endif
  142. #define INBOUNDS(a,p) ( ! (TOOHIGH(a,p) || TOOLOW(a,p)) )
  143. #define _IS(t,x) (((t)1 << (x)) != 0) /* Evaluates true if the width of */
  144. /* variable of type t is < x. */
  145. /* The != 0 assures that the */
  146. /* answer is 1 or 0 */
  147. #define NBITS(t) (4 * (1 + _IS(t,4) + _IS(t,8) + _IS(t,12) + _IS(t,16) \
  148. + _IS(t,20) + _IS(t,24) + _IS(t,28) + _IS(t,32)))
  149. #define MAXINT (((unsigned)~0) >> 1)
  150. #ifndef MAX
  151. # define MAX(a,b) ( ((a) > (b)) ? (a) : (b))
  152. #endif
  153. #ifndef MIN
  154. # define MIN(a,b) ( ((a) < (b)) ? (a) : (b))
  155. #endif
  156. #ifndef ABS
  157. # define ABS(a) ((a) >= 0 ? (a) : -(a))
  158. #endif
  159. #define RANGE(a,b,c) ( (a) <= (b) && (b) <= (c) )
  160. /* General typedefs */
  161. #ifndef __GENDEFS
  162. #define __GENDEFS
  163. typedef void *ptr;
  164. typedef void near *nearptr;
  165. typedef void far *farptr;
  166. /*typedef unsigned char uchar;
  167. typedef unsigned short ushort;
  168. typedef unsigned int uint;
  169. typedef unsigned long ulong;*/
  170. typedef int bool;
  171. #endif __GENDEFS
  172. /* Boolean truth values */
  173. #define false 0
  174. #define true 1
  175. #define FALSE 0
  176. #define TRUE 1
  177. #define NO 0
  178. #define YES 1
  179. #endif /* DEBUG_H */