home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / mgl11 / include / debug.h next >
Encoding:
C/C++ Source or Header  |  1994-03-07  |  6.6 KB  |  189 lines

  1. /****************************************************************************
  2. *
  3. *                   Copyright (C) 1993 SciTech Software
  4. *                           All rights reserved.
  5. *
  6. * Filename:     $RCSfile: debug.h $
  7. * Version:      $Revision: 1.6 $
  8. *
  9. * Language:     ANSI C
  10. * Environment:  any
  11. *
  12. * Description:  General header file for portable code.
  13. *
  14. * $Id: debug.h 1.6 92/03/15 12:51:48 kjb Exp $
  15. *
  16. ****************************************************************************/
  17.  
  18. #ifndef __DEBUG_H
  19. #define __DEBUG_H
  20.  
  21. #ifdef  DEBUG
  22. #       define D(x) x
  23. #else
  24. #       define D(x)
  25. #endif
  26.  
  27. #if     defined(__MSDOS__) || defined(__DOS__)  /* Compiling for MSDOS  */
  28. #       define MS(x) x
  29. #       define OS(x)
  30. #       define UX(x)
  31. #       define IR(x)
  32. #       define _8086        /* We know we have an 8086 type processor   */
  33. #if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
  34. #       define LDATA
  35. #ifndef NULL
  36. #       define NULL 0L
  37. #endif
  38. #else
  39. #ifndef NULL
  40. #       define NULL 0
  41. #endif
  42. #endif
  43. #elif   defined(__OS2__)        /* Compiling for 32 bit OS/2            */
  44. #       define MS(x)
  45. #       define OS(x) x
  46. #       define UX(x)
  47. #       define IR(x)
  48. #       define _80386       /* We know we have an 80386 type processor  */
  49. #       define MAXFILE  255     /* These are defined in <dir.h>, but    */
  50. #       define MAXDIR   255     /* on OS/2 machines, we just define     */
  51. #       define MAXPATH  255     /* them all to be the same size         */
  52. #       define near             /* Near and far do not exist under      */
  53. #       define far              /* 32 bit OS/2                          */
  54. #ifndef NULL
  55. #       define NULL 0L
  56. #endif
  57. #else                           /* Assume UNIX compilation              */
  58. #       define MS(x)
  59. #       define OS(x)
  60. #       define UX(x) x
  61. #if     defined(__IRIS4D__)     /* Compiling for the SGI Iris 4D        */
  62. #       define IR(x) x
  63. #else
  64. #       define IR(x)
  65. #endif
  66. #       define O_BINARY 0       /* no binary input mode in UNIX open()  */
  67. #       define MAXFILE  255     /* These are defined in <dir.h>, but    */
  68. #       define MAXDIR   255     /* on UNIX machines, we just define     */
  69. #       define MAXPATH  255     /* them all to be the same size         */
  70. #       define far              /* Near and far do not exist under      */
  71. #       define near             /* UNIX or the Iris.                    */
  72. #ifndef NULL
  73. #       define NULL ((void *)0)
  74. #endif
  75. #define    PUBAPI                    /* UNIX has no _cdecl keywords            */
  76. #endif
  77.  
  78. #define PRIVATE static
  79. #define PUBLIC
  80.  
  81. /* PUBAPI is used to declare calling conventions used for publicly
  82.  * accessible functions. You can override this from the command line to
  83.  * compile with another calling convetion (note that if you change this
  84.  * declaration you will need to re-compile all libraries with the same
  85.  * calling conventions). By default we use the default calling conventions
  86.  * for the compiler being used (Watcom uses register based conventions
  87.  * by default).
  88.  */
  89.  
  90. #ifndef    PUBAPI
  91. #define PUBAPI                  /* Use default calling conventions      */
  92. #endif
  93.  
  94. /****************************************************************************
  95. *
  96. *   SEG(p)      Evaluates to the segment portion of an 8086 address.
  97. *   OFF(p)      Evaluates to the offset portion of an 8086 address.
  98. *   FP(s,o)     Creates a far pointer given a segment offset pair.
  99. *   PHYS(p)     Evaluates to a long holding a physical address
  100. *
  101. ****************************************************************************/
  102.  
  103. #ifdef  _8086
  104. #       define SEG(p)   ( (unsigned)(((unsigned long)((void far *)(p))) >> 16))
  105. #       define OFF(p)   ( (unsigned)(p) )
  106. #       define FP(s,o)  ( (void far *)( ((unsigned long)(s) << 16) +  \
  107.                           (unsigned long)(o) ))
  108. #       define PHYS(p)  ( (unsigned long)OFF(p) +                       \
  109.                           ((unsigned long)SEG(p) << 4))
  110. #else
  111. #       define PHYS(p)  (p)
  112. #endif  /* _8086 */
  113.  
  114. /****************************************************************************
  115. *
  116. *   NUMELE(array)       Evaluates to the array size in elements
  117. *   LASTELE(array)      Evaluates to a pointer to the last element
  118. *   INBOUNDS(array,p)   Evaluates to true if p points into the array
  119. *   RANGE(a,b,c)        Evaluates to true if a <= b <= c
  120. *   MAX(a,b)            Evaluates to a or b, whichever is larger
  121. *   MIN(a,b)            Evaluates to a or b, whichever is smaller
  122. *   ABS(a)              Evaluates to the absolute value of a
  123. *   NBITS(type)         Returns the number of bits in a variable of the
  124. *                       indicated type
  125. *   MAXINT              Evaluates to the value of the largest signed integer
  126. *
  127. ****************************************************************************/
  128.  
  129. #define NUMELE(a)       (sizeof(a)/sizeof(*(a)))
  130. #define LASTELE(a)      ((a) + (NUMELE(a)-1))
  131. #ifdef  LDATA
  132. #define TOOHIGH(a,p)    ((long)PHYS(p) - (long)PHYS(a) > (long)(NUMELE(a)-1))
  133. #define TOOLOW(a,p)     ((long)PHYS(p) - (long)PHYS(a) < 0)
  134. #else
  135. #define TOOHIGH(a,p)    ((long)(p) - (long)(a) > (long)(NUMELE(a)-1))
  136. #define TOOLOW(a,p)     ((long)(p) - (long)(a) < 0)
  137. #endif
  138. #define INBOUNDS(a,p)   ( ! (TOOHIGH(a,p) || TOOLOW(a,p)) )
  139.  
  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.  
  145. #define NBITS(t) (4 * (1 + _IS(t,4) + _IS(t,8) + _IS(t,12) + _IS(t,16) \
  146.                          + _IS(t,20) + _IS(t,24) + _IS(t,28) + _IS(t,32)))
  147.  
  148. #define MAXINT          (((unsigned)~0) >> 1)
  149.  
  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. #ifndef    SIGN
  160. #        define SIGN(a)    ((a) > 0 ? 1 : -1)
  161. #endif
  162.  
  163. #define RANGE(a,b,c)    ( (a) <= (b) && (b) <= (c) )
  164.  
  165. /* General typedefs */
  166.  
  167. #ifndef __GENDEFS
  168. #define __GENDEFS
  169. typedef void            *ptr;
  170. typedef void near       *nearptr;
  171. typedef void far        *farptr;
  172. typedef unsigned char   uchar;
  173. typedef unsigned short  ushort;
  174. typedef unsigned int    uint;
  175. typedef unsigned long   ulong;
  176. typedef short           bool;
  177. #endif  /* __GENDEFS */
  178.  
  179. /* Boolean truth values */
  180.  
  181. #define false       ((bool)0)
  182. #define true        ((bool)1)
  183. #define FALSE       ((bool)0)
  184. #define TRUE        ((bool)1)
  185. #define NO          ((bool)0)
  186. #define YES         ((bool)1)
  187.  
  188. #endif  /* __DEBUG_H */
  189.