Debian Codegraph @

terps/tads/tads2/lib.h

raw symbols SCIP
1 /*
2 $Header: d:/cvsroot/tads/TADS2/LIB.H,v 1.2 1999/05/17 02:52:12 MJRoberts Exp $
3 */
4
5 /*
6 * Copyright (c) 1991, 2002 Michael J. Roberts. All Rights Reserved.
7 *
8 * Please see the accompanying license file, LICENSE.TXT, for information
9 * on using and copying this software.
10 */
11 /*
12 Name
13 lib.h - standard definitions
14 Function
15 Various standard definitions
16 Notes
17 None
18 Modified
19 01/02/93 SMcAdams - add bit operations
20 12/30/92 MJRoberts - converted to lib.h (from TADS std.h)
21 08/03/91 MJRoberts - creation
22 */
23
24 #ifndef LIB_INCLUDED
25 #define LIB_INCLUDED
26
27 #include <stddef.h>
28 #include <string.h>
29 #include <stdlib.h>
30
31 #ifndef OS_INCLUDED
32 # include "os.h"
33 #endif
34
35 /* short-hand for various types */
36 #ifndef OS_UCHAR_DEFINED
37 typedef unsigned char uchar;
38 #endif
39
40 #ifndef OS_USHORT_DEFINED
41 typedef unsigned short ushort;
42 #endif
43
44 #ifndef OS_UINT_DEFINED
45 typedef unsigned int uint;
46 #endif
47
48 #ifndef OS_ULONG_DEFINED
49 typedef unsigned long ulong;
50 #endif
51
52 /* some alternative types */
53 typedef unsigned char ub1;
54 typedef signed char sb1;
55 typedef char b1;
56 typedef unsigned int ub2;
57 typedef signed int sb2;
58 typedef int b2;
59 typedef unsigned long ub4;
60 typedef signed long sb4;
61 typedef long b4;
62 typedef int eword;
63
64 /* maximum/minimum portable values for various types */
65 #define UB4MAXVAL 0xffffffffUL
66 #define UB2MAXVAL 0xffffU
67 #define UB1MAXVAL 0xffU
68 #define SB4MAXVAL 0x7fffffffL
69 #define SB2MAXVAL 0x7fff
70 #define SB1MAXVAL 0x7f
71 #define SB4MINVAL (-(0x7fffffff)-1)
72 #define SB2MINVAL (-(0x7fff)-1)
73 #define SB1MINVAL (-(0x7f)-1)
74
75 /* clear a struture */
76 #define CLRSTRUCT(x) memset(&(x), 0, (size_t)sizeof(x))
77 #define CPSTRUCT(dst,src) memcpy(&(dst), &(src), (size_t)sizeof(dst))
78
79 /* TRUE and FALSE */
80 #ifndef TRUE
81 # define TRUE 1
82 #endif /* TRUE */
83 #ifndef FALSE
84 # define FALSE 0
85 #endif /* FALSE */
86
87 /* bitwise operations */
88 #define bit(va, bt) ((va) & (bt))
89 #define bis(va, bt) ((va) |= (bt))
90 #define bic(va, bt) ((va) &= ~(bt))
91
92 /*
93 * noreg/NOREG - use for variables changed in error-protected code that
94 * are used in error handling code. Use 'noreg' on the declaration like
95 * a storage class qualifier. Use 'NOREG' as an argument call, passing
96 * the addresses of all variables declared noreg. For non-ANSI
97 * compilers, a routine osnoreg(/o_ void *arg0, ... _o/) must be
98 * defined.
99 */
100 #ifdef OSANSI
101 # define noreg volatile
102 # define NOREG(arglist)
103 #else /* OSANSI */
104 # define noreg
105 # define NOREG(arglist) osnoreg arglist ;
106 #endif /* OSANSI */
107
108 /*
109 * Linting directives. You can define these before including this file
110 * if you have a fussy compiler.
111 */
112 #ifdef LINT
113 # ifndef NOTREACHED
114 # define NOTREACHED return
115 # endif
116 # ifndef NOTREACHEDV
117 # define NOTREACHEDV(t) return((t)0)
118 # endif
119 # ifndef VARUSED
120 # define VARUSED(v) varused(v)
121 # endif
122 void varused();
123 #else /* LINT */
124 # ifndef NOTREACHED
125 # define NOTREACHED
126 # endif
127 # ifndef NOTREACHEDV
128 # define NOTREACHEDV(t)
129 # endif
130 # ifndef VARUSED
131 # define VARUSED(v)
132 # endif
133 #endif /* LINT */
134
135 /* conditionally compile code if debugging is enabled */
136 #ifdef DEBUG
137 # define IF_DEBUG(x) x
138 #else /* DEBUG */
139 # define IF_DEBUG(x)
140 #endif /* DEBUG */
141
142 #ifndef offsetof
143 # define offsetof(s_name, m_name) (size_t)&(((s_name *)0)->m_name)
144 #endif /* offsetof */
145
146 /*
147 * Define our own version of isspace(), so that we don't try to interpret
148 * anything outside of the normal ASCII set as spaces.
149 */
150 #define t_isspace(c) \
151 (((unsigned char)(c)) <= 127 && isspace((unsigned char)(c)))
152
153 #endif /* LIB_INCLUDED */