Changed comments style for better future documentation generation.
[vlp.git] / src / int / int.h
1 #include "comm.h"
2
3 /** maximum special value of mark */
4 #define MAXMARKER       MAXINTEGER
5
6 /** maximum appetite (easily extensible ?) */
7 #define MAXAPPT         MAXINTEGER
8
9 /** maximum number of trace messages in line */
10 #define MAXTRACNT       13
11
12 /** maximum length of formal procedure header */
13 #define MAXHDLEN        40
14
15 /** maximum number of a system signal */
16 #define MAXSYSSN        62
17
18 /** maximum number of params to standard proc */
19 #define MAXPARAM        10
20
21 /** size of I/O transfer block in bytes */
22 #define IOBLOCK         0x4000
23
24 /* Object structure : */
25
26 /* Offsets from the beginning : */
27 /** prototype number */
28 #define PROTNUM         1
29 /** link to same size list (killed only) */
30 #define SHORTLINK       1
31 /** link to other size list (killed only) */
32 #define LONGLINK        2
33
34 /* Files : */
35 /*      appetite        0       */
36 /*      prot number     1       always FILEOBJECT */
37 /* file status */
38 #define FSTAT           2
39 /* flag to tell if file is temporary */
40 #define FTEMP           3
41 /* file type */
42 #define FTYPE           4
43 /* file name pointer */
44 #define FNAME           5
45 /** file handle */
46 #define FFILE           (FNAME + sizeof(char *) / sizeof(word))
47 /** appetite of file object */
48 #define APFILE          (FFILE + sizeof(FILE *) / sizeof(word))
49
50 /**
51  * \defgroup ObjectOffests Offsets from the first address after object
52  * @{
53  */
54 /* static link */
55 #define SL              -2
56
57 /** dynamic link */
58 #define DL              -4
59
60 /** local control */
61 #define LSC             -5
62
63 /** number of times the object occurs in SL */
64 #define STATSL          -6
65
66 /** signal number (handlers only) */
67 #define SIGNR           -7
68
69 /** remote dynamic link (procedures only) */
70 #define RPCDL           -8
71
72 /** coroutine link (coroutine only) */
73 #define CL              -8
74
75 /** coroutine head (process only) */
76 #define CHD             -10
77
78 /** virtual scratch  (process only) */
79 #define VIRTSC          -12
80 /** @} */
81
82 /**
83  * Virtual address (also formal type)
84  */
85 typedef struct {
86         /**
87          * address of dictionary item
88          * node and process index for processes
89          * or for formal types - number of arrayof
90          */
91         word addr;
92         /**
93          * address mark
94          * negative for processes or for formal types - actual type
95          */
96         word mark;
97 } virtaddr;
98
99 #define loadvirt(v, a)  { word ta;              \
100                           ta = (a);             \
101                           (v).addr = M[ ta++ ]; \
102                           (v).mark = M[ ta ]; }
103 #define storevirt(v, a) { word ta;              \
104                           ta = (a);             \
105                           M[ ta++ ] = (v).addr; \
106                           M[ ta ] = (v).mark; }
107                         
108 #define MF(a)           (*( (FILE **) (M+(a)) ))
109 #define MN(a)           (*( (char **) (M+(a)) ))
110 #define MR(a)            *( (real *) (M+(a)) )
111
112
113 #ifdef max
114 #undef max
115 #endif
116
117 #ifdef min
118 #undef min
119 #endif
120
121 #define min(x, y)       ((x) < (y) ? (x) : (y))
122 #define max(x, y)       ((x) > (y) ? (x) : (y))
123 #define absolute(x)     ((x) >= 0 ? (x) : -(x))
124
125 /**
126  * \defgroup LoglanBooleans LOGLAN's booleans
127  * @{
128  */
129 #define LFALSE          ((word)0)
130 #define LTRUE           (~LFALSE)
131 #define lbool(b)        ( (b) ? LTRUE : LFALSE )
132 /** @} */
133
134 /**
135  * \defgroup FileTypes Type of files
136  * @{
137  */
138 /** text file */
139 #define TEXTF 1
140
141 /** file of char */
142 #define CHARF 2
143
144 /** file of integer */
145 #define INTF 3
146
147 /** file of real */
148 #define REALF 4
149
150 /** direct access file */
151 #define DIRECT 5
152 /** @} */
153
154 /**
155  * \defgroup FileStatus File status
156  * @{
157  */
158 /** sequential file opened for read */
159 #define READING         0
160
161 /** sequential file opened for write */
162 #define WRITING         1
163
164 /** direct access file */
165 #define UPDATING        2
166
167 /** file not opened */
168 #define UNKNOWN         3
169
170 /** @} */
171
172 /**
173  * \defgroup RuntimeErrorTypes Run time error types :
174  * @{
175  */
176 /** SL chain cut off */
177 #define RTESLCOF  0
178
179 /** unimplemented standard procedure */
180 #define RTEUNSTP  1
181
182 /** illegal attach */
183 #define RTEILLAT  2
184
185 /** illegal detach */
186 #define RTEILLDT  3
187
188 /** coroutine terminated */
189 #define RTECORTM  4
190
191 /** coroutine active */
192 #define RTECORAC  5
193
194 /** array index error */
195 #define RTEINVIN  6
196
197 /** incorrect array bounds */
198 #define RTEILLAB  7
199
200 /** improper QUA */
201 #define RTEINCQA  8
202
203 /** illegal assignment */
204 #define RTEINCAS  9
205
206 /** formal type missing */
207 #define RTEFTPMS 10
208
209 /** illegal kill */
210 #define RTEILLKL 11
211
212 /** illegal copy */
213 #define RTEILLCP 12
214
215 /** incompatible headers */
216 #define RTEINCHS 13
217
218 /** handler not found */
219 #define RTEHNDNF 14
220
221 /** memory overflow */
222 #define RTEMEMOV 15
223
224 /** formal header too long */
225 #define RTEFHTLG 16
226
227 /** illegal return */
228 #define RTEILLRT 17
229
230 /** reference to NONE */
231 #define RTEREFTN 18
232
233 /** division by zero */
234 #define RTEDIVBZ 19
235
236 /** system error */
237 #define RTESYSER 20
238
239 /** illegal I/O operation */
240 #define RTEILLIO 21
241
242 /** I/O error */
243 #define RTEIOERR 22
244
245 /** Cannot open file */
246 #define RTECNTOP 23
247
248 /** Input data format bad */
249 #define RTEBADFM 24
250
251 /** illegal resume */
252 #define RTEILLRS 25
253
254 /** too many processes on one machine */
255 #define RTETMPRC 26
256
257 /** invalid node number */
258 #define RTEINVND 27
259
260 /** negative step value */
261 #define RTENEGST 28
262
263 /** only process may be global */
264 #define RTENONGL 29
265 /** @} */
266
267 union value {
268         unsigned int xint;
269         word xword;
270         real xreal;
271         virtaddr xvirt;
272         word xbool;
273 };
274
275 #define MAXINSTANCE 255
276
277 /**
278  * \defgroup Variables Variables
279  * @{
280  */
281 /** main memory for code and data */
282 extern memory M;
283
284 /** pointer to standard proc. param list */
285 extern union value *param;
286
287 /** offset conversion table for compact. */
288 extern int offset[];
289
290 /** signal to number conversion table */
291 extern int scot[];
292
293 /** appetites of primitive types */
294 extern int primapet[];
295
296 /** instruction counter */
297 extern word ic;
298
299 /** previous ic for redecoding after comp. */
300 extern word lastic;
301
302 /** opcode of L-code instruction */
303 extern int opcode;
304
305 /** arguments of L-code instruction */
306 extern word a1, a2, a3;
307
308 /** @}*/
309
310
311 /**
312  * \defgroup KernelVariables kernel variables for the running system
313  * @{
314  */
315 /** size of memory array for code and data */
316 extern word memorysize;
317
318 /** DISPLAY offset in process object */
319 extern word dispoff;
320
321 /** indirect DISPLAY offset in process object */
322 extern word disp2off;
323
324 /** DISPLAY address - physical addresses */
325 extern word display;
326
327 /** DISPLAY address - indirect addresses */
328 extern word display2;
329
330 /** pointers to current object */
331 extern word c1, c2;
332
333 /** main block object */
334 extern word mainprog;
335
336 /** offset of variable main */
337 extern word mnoff;
338
339 /* TODO: Does this groups ends here ?*/
340 /** @} */
341
342 /** TRUE if compactification message printed */
343 extern bool infmode;
344
345 /** TRUE if trace is printed */
346 extern bool debug;
347
348 /** output file for trace */
349 extern FILE *tracefile;
350
351 /** is graphics active ? */
352 bool graphics;
353
354 /** for continue execution */
355 extern jmp_buf contenv;
356
357 extern int internal_sock,graph_sock,net_sock;
358 extern int connected;
359 extern int GraphRes;
360 extern int fcol;
361 extern int bcol;
362 extern int curx;
363 extern int cury;
364 extern char ProgName[255];
365 extern ctx_struct my_ctx;
366 extern void send_to_graph(G_MESSAGE*);
367 extern int read_from_graph(G_MESSAGE*);
368 extern int read_from_net(MESSAGE*);
369 extern char mygname[80],mykname[80],mynname[80];
370 extern int DirConn[MAXINSTANCE];