home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / zen / ztimer / debug.h next >
Encoding:
C/C++ Source or Header  |  1992-01-09  |  5.1 KB  |  179 lines

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