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