summaryrefslogtreecommitdiff
path: root/ext/hyperwave/debug.h
blob: 5b72dbb194d3b507ec487b17fd9c5e13f6fb6a97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/****************************************************************************
*
*          Copyright (C) 1991 Kendall Bennett.
*              All rights reserved.
*
* Filename:    $RCSfile$
* Version:    $Revision$
*
* Language:    ANSI C
* Environment:  any
*
* Description:  General header file for portable code.
*
* $Id$
*
* Revision History:
* -----------------
*
* $Log$
* Revision 1.2  2000/07/02 23:46:41  sas
* Change header protection macros to conform to standard.
*
* Draft 3 of IEEE 1003.1 200x, "2.2 The Compilation Environment"
*
*   All identifiers that begin with an underscore and either an uppercase
*   letter or another underscore are always reserved for any use by the
*   implementation.
*
* Revision 1.1  1999/04/21 23:37:47  ssb
* moved db
*
* Revision 1.1.1.1  1999/04/07 21:03:29  zeev
* PHP 4.0
*
* Revision 1.1.1.1  1999/03/17 04:29:10  andi
* PHP4
*
* Revision 1.1.1.1  1998/12/21 07:56:22  andi
* Trying to start the zend CVS tree
*
* Revision 1.1  1998/08/12 09:29:16  steinm
* First version of Hyperwave module.
*
* Revision 1.6  92/03/15  12:51:48  kjb
* Added MK_FP macro and ushort typedef.
* 
* Revision 1.5  91/10/28  03:17:33  kjb
* Ported to the Iris.
* 
* Revision 1.4  91/09/26  15:29:02  kjb
* Added stuff for the SGI Iris 4D.
* 
* Revision 1.3  91/09/26  10:07:04  kjb
* Added general typedef stuff.
* 
* Revision 1.2  91/09/03  18:19:14  ROOT_DOS
* Added a few defines that are supplied by <dir.h> for UNIX compatibility.
*
* Revision 1.1  91/08/16  13:19:06  ROOT_DOS
* Initial revision
*
****************************************************************************/

#ifndef  DEBUG_H
#define  DEBUG_H

#ifdef  DEBUG
#    define D(x) x
#else
#    define D(x)
#endif

#define  PRIVATE  static
#define  PUBLIC

#ifdef   __MSDOS__        /* Compiling for MSDOS          */
#    define MS(x) x
#    define UX(x)
#    define IR(x)
#    define _8086    /* We know we have an 8086 type processor  */
#if defined(__COMPACT__) || defined(__LARGE__) || defined(__HUGE__)
#    define LDATA
#    define NULL  0L
#else
#    define NULL  0
#endif
#else  __MSDOS__
#ifdef  __IRIS4D__        /* Compiling for the SGI Iris 4D    */
#    define MS(x)
#    define UX(x) x      /* The Iris is a UNIX machine      */
#    define IR(x) x
#    define O_BINARY 0    /* no binary input mode in UNIX open()  */
#    define MAXFILE  255    /* These are defined in <dir.h>, but  */
#    define MAXDIR  255    /* on UNIX machines, we just define    */
#    define MAXPATH  255    /* them all to be the same size      */
#    define far        /* Near and far do not exist under    */
#    define near        /* UNIX or the Iris.          */
#    define NULL ((void *)0)
#else  __IRIS4D__        /* Assume UNIX compilation        */
#    define MS(x)
#    define UX(x) x
#    define IR(x)
#    define O_BINARY 0    /* no binary input mode in UNIX open()  */
#    define MAXFILE  255    /* These are defined in <dir.h>, but  */
#    define MAXDIR  255    /* on UNIX machines, we just define    */
#    define MAXPATH  255    /* them all to be the same size      */
#    define far        /* Near and far do not exist under    */
#    define near        /* UNIX or the Iris.          */
#    ifndef NULL
#      define NULL ((void *)0)
#    endif
#endif  __IRIS4D__
#endif  __MSDOS__

/****************************************************************************
*
*  SEG(p)    Evaluates to the segment portion of an 8086 address.
*  OFF(p)    Evaluates to the offset portion of an 8086 address.
*  FP(s,o)    Creates a far pointer given a segment offset pair.
*  PHYS(p)    Evaluates to a long holding a physical address
*
****************************************************************************/

#ifdef  _8086
#    define SEG(p)  ( ((unsigned *)&(void far *)(p))[1] )
#    define OFF(p)  ( (unsigned)(p) )
#    define FP(s,o)  ( (void far *)( ((unsigned long)s << 16) +  \
              (unsigned long)o ))
#    define PHYS(p)  ( (unsigned long)OFF(p) +            \
              ((unsigned long)SEG(p) << 4))
#else
#    define PHYS(p)   (p)
#endif  _8086

/****************************************************************************
*
*  NUMELE(array)    Evaluates to the array size in elements
*  LASTELE(array)    Evaluates to a pointer to the last element
*  INBOUNDS(array,p)  Evaluates to true if p points into the array
*  RANGE(a,b,c)    Evaluates to true if a <= b <= c
*  max(a,b)      Evaluates to a or b, whichever is larger
*  min(a,b)      Evaluates to a or b, whichever is smaller
*  ABS(a)        Evaluates to the absolute value of a
*  NBITS(type)      Returns the number of bits in a variable of the
*            indicated type
*  MAXINT        Evaluates to the value of the largest signed integer
*
****************************************************************************/

#define  NUMELE(a)    (sizeof(a)/sizeof(*(a)))
#define  LASTELE(a)    ((a) + (NUMELE(a)-1))
#ifdef  LDATA
#define  TOOHIGH(a, p)  ((long)PHYS(p) - (long)PHYS(a) > (long)(NUMELE(a)-1))
#define  TOOLOW(a, p)    ((long)PHYS(p) - (long)PHYS(a) < 0)
#else
#define  TOOHIGH(a, p)  ((long)(p) - (long)(a) > (long)(NUMELE(a)-1))
#define  TOOLOW(a, p)    ((long)(p) - (long)(a) < 0)
#endif
#define  INBOUNDS(a, p)  ( ! (TOOHIGH(a, p) || TOOLOW(a, p)) )

#define  _IS(t, x) (((t)1 << (x)) != 0)  /* Evaluates true if the width of */
                    /* variable of type t is < x.    */
                    /* The != 0 assures that the      */
                    /* answer is 1 or 0          */

#define  NBITS(t) (4 * (1 + _IS(t, 4) + _IS(t, 8) + _IS(t, 12) + _IS(t, 16) \
             + _IS(t, 20) + _IS(t, 24) + _IS(t, 28) + _IS(t, 32)))

#define  MAXINT      (((unsigned)~0) >> 1)

#ifndef  MAX
#    define MAX(a, b)  ( ((a) > (b)) ? (a) : (b))
#endif
#ifndef  MIN
#    define MIN(a, b) ( ((a) < (b)) ? (a) : (b))
#endif
#ifndef  ABS
#    define ABS(a)  ((a) >= 0 ? (a) : -(a))
#endif

#define  RANGE(a, b, c)  ( (a) <= (b) && (b) <= (c) )

/* General typedefs  */

#ifndef  __GENDEFS
#define  __GENDEFS
typedef  void      *ptr;
typedef void near    *nearptr;
typedef  void far    *farptr;
/*typedef  unsigned char  uchar;
typedef  unsigned short  ushort;
typedef  unsigned int  uint;
typedef  unsigned long  ulong;*/
typedef  int        bool;
#endif  __GENDEFS

/* Boolean truth values */

#define  false    0
#define  true    1
#define  FALSE    0
#define  TRUE    1
#define  NO      0
#define  YES      1

#endif  /* DEBUG_H */