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.

194 lines
5.9 KiB

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