|
|
1.1 root 1: #include <stdio.h>
2: #include "trace.h"
3: #include "trace.d"
4:
5: extern struct QUEUE **head, **tail;
6: extern int *qsize, nrqs, level;
7:
8: char *Realloc(), *Emalloc(), *Smalloc();
9:
10: struct CONTS ***oldqueues; /* index of queue states */
11: long *nrqstates, *qbound;
12:
13: iniqtable()
14: { register int i;
15: nrqstates = (long *)
16: Smalloc(nrqs * sizeof(long));
17: qbound = (long *)
18: Smalloc(nrqs * sizeof(long));
19:
20: oldqueues = (struct CONTS ***)
21: Smalloc(nrqs * sizeof(struct CONTS **));
22:
23: for (i = 0; i < nrqs; i++)
24: nrqstates[i] = qbound[i] = 0;
25: }
26:
27: growqtable(p)
28: { int nsz = qbound[p] + 32;
29:
30: if (nsz == 32)
31: oldqueues[p] = (struct CONTS **)
32: Emalloc(nsz * sizeof(struct CONTS *));
33: else
34: oldqueues[p] = (struct CONTS **)
35: Realloc(oldqueues[p], nsz * sizeof(struct CONTS *));
36:
37: qbound[p] = nsz;
38: }
39:
40: struct CONTS *
41: Qinsert(p)
42: { struct CONTS * try;
43: struct QUEUE * tmp;
44: register int i, j;
45:
46: i = p;
47: j = qsize[p];
48:
49: if (nrqstates[p] >= qbound[p])
50: growqtable(p);
51:
52: try = (struct CONTS *)
53: Smalloc((j+1) * sizeof(struct CONTS));
54:
55: try[0].mesg = i;
56: try[0].cargo = j;
57:
58: for (tmp = head[i], j = 1; tmp != tail[i]; tmp = tmp->next, j++)
59: { try[j].mesg = (tmp->mesg & ~PASSED);
60: try[j].cargo = tmp->cargo;
61: }
62:
63: if (--j != qsize[p])
64: whoops("cannot happen - Qinsert");
65:
66: oldqueues[p][nrqstates[p]] = try;
67: nrqstates[p] += 1;
68:
69: return try;
70: }
71:
72: struct CONTS *
73: inqtable(p)
74: { register int i;
75:
76: if (qsize[p] == 0)
77: whoops("cannot happen - inqtable");
78:
79: for (i = 0; i < nrqstates[p]; i++)
80: if (samequeue(oldqueues[p][i]))
81: return oldqueues[p][i];
82:
83: return Qinsert(p);
84: }
85:
86: samequeue(at)
87: struct CONTS *at;
88: {
89: register struct QUEUE *tmp;
90: register int j, k, m;
91:
92: k = at[0].mesg; /* which queue is this */
93: m = at[0].cargo; /* how many elements are here */
94:
95: if (qsize[k] != m)
96: return 0;
97:
98: for (tmp = head[k], j = 1; tmp != tail[k]; tmp = tmp->next, j++)
99: { if (at[j].mesg != (tmp->mesg & ~PASSED)
100: || at[j].cargo != tmp->cargo)
101: return 0;
102: }
103: return 1;
104: }
105:
106: Queuesmatch(vis, k)
107: struct VISIT *vis;
108: register int k;
109: {
110: register int i;
111:
112: for (i = 0; i < k; i++)
113: if (samequeue(vis->c[i]) == 0)
114: return 0;
115: return 1;
116: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.