convert from svn repository: remove tags directory
[lttv.git] / trunk / verif / Spin / Src5.1.6 / spin.h
CommitLineData
0b55f123 1/***** spin: spin.h *****/
2
3/* Copyright (c) 1989-2007 by Lucent Technologies, Bell Laboratories. */
4/* All Rights Reserved. This software is for educational purposes only. */
5/* No guarantee whatsoever is expressed or implied by the distribution of */
6/* this code. Permission is given to distribute this code provided that */
7/* this introductory message is not removed and no monies are exchanged. */
8/* Software written by Gerard J. Holzmann. For tool documentation see: */
9/* http://spinroot.com/ */
10/* Send all bug-reports and/or questions to: bugs@spinroot.com */
11
12#ifndef SEEN_SPIN_H
13#define SEEN_SPIN_H
14
15#include <stdio.h>
16#include <string.h>
17#include <ctype.h>
18#ifndef PC
19#include <memory.h>
20#endif
21
22typedef struct Lextok {
23 unsigned short ntyp; /* node type */
24 short ismtyp; /* CONST derived from MTYP */
25 int val; /* value attribute */
26 int ln; /* line number */
27 int indstep; /* part of d_step sequence */
28 struct Symbol *fn; /* file name */
29 struct Symbol *sym; /* symbol reference */
30 struct Sequence *sq; /* sequence */
31 struct SeqList *sl; /* sequence list */
32 struct Lextok *lft, *rgt; /* children in parse tree */
33} Lextok;
34
35typedef struct Slicer {
36 Lextok *n; /* global var, usable as slice criterion */
37 short code; /* type of use: DEREF_USE or normal USE */
38 short used; /* set when handled */
39 struct Slicer *nxt; /* linked list */
40} Slicer;
41
42typedef struct Access {
43 struct Symbol *who; /* proctype name of accessor */
44 struct Symbol *what; /* proctype name of accessed */
45 int cnt, typ; /* parameter nr and, e.g., 's' or 'r' */
46 struct Access *lnk; /* linked list */
47} Access;
48
49typedef struct Symbol {
50 char *name;
51 int Nid; /* unique number for the name */
52 unsigned short type; /* bit,short,.., chan,struct */
53 unsigned char hidden; /* bit-flags:
54 1=hide, 2=show,
55 4=bit-equiv, 8=byte-equiv,
56 16=formal par, 32=inline par,
57 64=treat as if local; 128=read at least once
58 */
59 unsigned char colnr; /* for use with xspin during simulation */
60 int nbits; /* optional width specifier */
61 int nel; /* 1 if scalar, >1 if array */
62 int setat; /* last depth value changed */
63 int *val; /* runtime value(s), initl 0 */
64 Lextok **Sval; /* values for structures */
65
66 int xu; /* exclusive r or w by 1 pid */
67 struct Symbol *xup[2]; /* xr or xs proctype */
68 struct Access *access;/* e.g., senders and receives of chan */
69 Lextok *ini; /* initial value, or chan-def */
70 Lextok *Slst; /* template for structure if struct */
71 struct Symbol *Snm; /* name of the defining struct */
72 struct Symbol *owner; /* set for names of subfields in typedefs */
73 struct Symbol *context; /* 0 if global, or procname */
74 struct Symbol *next; /* linked list */
75} Symbol;
76
77typedef struct Ordered { /* links all names in Symbol table */
78 struct Symbol *entry;
79 struct Ordered *next;
80} Ordered;
81
82typedef struct Queue {
83 short qid; /* runtime q index */
84 int qlen; /* nr messages stored */
85 int nslots, nflds; /* capacity, flds/slot */
86 int setat; /* last depth value changed */
87 int *fld_width; /* type of each field */
88 int *contents; /* the values stored */
89 int *stepnr; /* depth when each msg was sent */
90 struct Queue *nxt; /* linked list */
91} Queue;
92
93typedef struct FSM_state { /* used in pangen5.c - dataflow */
94 int from; /* state number */
95 int seen; /* used for dfs */
96 int in; /* nr of incoming edges */
97 int cr; /* has reachable 1-relevant successor */
98 int scratch;
99 unsigned long *dom, *mod; /* to mark dominant nodes */
100 struct FSM_trans *t; /* outgoing edges */
101 struct FSM_trans *p; /* incoming edges, predecessors */
102 struct FSM_state *nxt; /* linked list of all states */
103} FSM_state;
104
105typedef struct FSM_trans { /* used in pangen5.c - dataflow */
106 int to;
107 short relevant; /* when sliced */
108 short round; /* ditto: iteration when marked */
109 struct FSM_use *Val[2]; /* 0=reads, 1=writes */
110 struct Element *step;
111 struct FSM_trans *nxt;
112} FSM_trans;
113
114typedef struct FSM_use { /* used in pangen5.c - dataflow */
115 Lextok *n;
116 Symbol *var;
117 int special;
118 struct FSM_use *nxt;
119} FSM_use;
120
121typedef struct Element {
122 Lextok *n; /* defines the type & contents */
123 int Seqno; /* identifies this el within system */
124 int seqno; /* identifies this el within a proc */
125 int merge; /* set by -O if step can be merged */
126 int merge_start;
127 int merge_single;
128 short merge_in; /* nr of incoming edges */
129 short merge_mark; /* state was generated in merge sequence */
130 unsigned int status; /* used by analyzer generator */
131 struct FSM_use *dead; /* optional dead variable list */
132 struct SeqList *sub; /* subsequences, for compounds */
133 struct SeqList *esc; /* zero or more escape sequences */
134 struct Element *Nxt; /* linked list - for global lookup */
135 struct Element *nxt; /* linked list - program structure */
136} Element;
137
138typedef struct Sequence {
139 Element *frst;
140 Element *last; /* links onto continuations */
141 Element *extent; /* last element in original */
142 int maxel; /* 1+largest id in sequence */
143} Sequence;
144
145typedef struct SeqList {
146 Sequence *this; /* one sequence */
147 struct SeqList *nxt; /* linked list */
148} SeqList;
149
150typedef struct Label {
151 Symbol *s;
152 Symbol *c;
153 Element *e;
154 int visible; /* label referenced in claim (slice relevant) */
155 struct Label *nxt;
156} Label;
157
158typedef struct Lbreak {
159 Symbol *l;
160 struct Lbreak *nxt;
161} Lbreak;
162
163typedef struct RunList {
164 Symbol *n; /* name */
165 int tn; /* ordinal of type */
166 int pid; /* process id */
167 int priority; /* for simulations only */
168 Element *pc; /* current stmnt */
169 Sequence *ps; /* used by analyzer generator */
170 Lextok *prov; /* provided clause */
171 Symbol *symtab; /* local variables */
172 struct RunList *nxt; /* linked list */
173} RunList;
174
175typedef struct ProcList {
176 Symbol *n; /* name */
177 Lextok *p; /* parameters */
178 Sequence *s; /* body */
179 Lextok *prov; /* provided clause */
180 short tn; /* ordinal number */
181 unsigned char det; /* deterministic */
182 unsigned char unsafe; /* contains global var inits */
183 struct ProcList *nxt; /* linked list */
184} ProcList;
185
186typedef Lextok *Lexptr;
187
188#define YYSTYPE Lexptr
189
190#define ZN (Lextok *)0
191#define ZS (Symbol *)0
192#define ZE (Element *)0
193
194#define DONE 1 /* status bits of elements */
195#define ATOM 2 /* part of an atomic chain */
196#define L_ATOM 4 /* last element in a chain */
197#define I_GLOB 8 /* inherited global ref */
198#define DONE2 16 /* used in putcode and main*/
199#define D_ATOM 32 /* deterministic atomic */
200#define ENDSTATE 64 /* normal endstate */
201#define CHECK2 128 /* status bits for remote ref check */
202#define CHECK3 256 /* status bits for atomic jump check */
203
204#define Nhash 255 /* slots in symbol hash-table */
205
206#define XR 1 /* non-shared receive-only */
207#define XS 2 /* non-shared send-only */
208#define XX 4 /* overrides XR or XS tag */
209
210#define CODE_FRAG 2 /* auto-numbered code-fragment */
211#define CODE_DECL 4 /* auto-numbered c_decl */
212#define PREDEF 3 /* predefined name: _p, _last */
213
214#define UNSIGNED 5 /* val defines width in bits */
215#define BIT 1 /* also equal to width in bits */
216#define BYTE 8 /* ditto */
217#define SHORT 16 /* ditto */
218#define INT 32 /* ditto */
219#define CHAN 64 /* not */
220#define STRUCT 128 /* user defined structure name */
221
222#define SOMETHINGBIG 65536
223#define RATHERSMALL 512
224
225#ifndef max
226#define max(a,b) (((a)<(b)) ? (b) : (a))
227#endif
228
229enum { INIV, PUTV, LOGV }; /* for pangen[14].c */
230
231/***** prototype definitions *****/
232Element *eval_sub(Element *);
233Element *get_lab(Lextok *, int);
234Element *huntele(Element *, int, int);
235Element *huntstart(Element *);
236Element *target(Element *);
237
238Lextok *do_unless(Lextok *, Lextok *);
239Lextok *expand(Lextok *, int);
240Lextok *getuname(Symbol *);
241Lextok *mk_explicit(Lextok *, int, int);
242Lextok *nn(Lextok *, int, Lextok *, Lextok *);
243Lextok *rem_lab(Symbol *, Lextok *, Symbol *);
244Lextok *rem_var(Symbol *, Lextok *, Symbol *, Lextok *);
245Lextok *tail_add(Lextok *, Lextok *);
246
247ProcList *ready(Symbol *, Lextok *, Sequence *, int, Lextok *);
248
249SeqList *seqlist(Sequence *, SeqList *);
250Sequence *close_seq(int);
251
252Symbol *break_dest(void);
253Symbol *findloc(Symbol *);
254Symbol *has_lab(Element *, int);
255Symbol *lookup(char *);
256Symbol *prep_inline(Symbol *, Lextok *);
257
258char *emalloc(size_t);
259long Rand(void);
260
261int any_oper(Lextok *, int);
262int any_undo(Lextok *);
263int c_add_sv(FILE *);
264int cast_val(int, int, int);
265int checkvar(Symbol *, int);
266int Cnt_flds(Lextok *);
267int cnt_mpars(Lextok *);
268int complete_rendez(void);
269int enable(Lextok *);
270int Enabled0(Element *);
271int eval(Lextok *);
272int find_lab(Symbol *, Symbol *, int);
273int find_maxel(Symbol *);
274int full_name(FILE *, Lextok *, Symbol *, int);
275int getlocal(Lextok *);
276int getval(Lextok *);
277int glob_inline(char *);
278int has_typ(Lextok *, int);
279int in_bound(Symbol *, int);
280int interprint(FILE *, Lextok *);
281int printm(FILE *, Lextok *);
282int ismtype(char *);
283int isproctype(char *);
284int isutype(char *);
285int Lval_struct(Lextok *, Symbol *, int, int);
286int main(int, char **);
287int pc_value(Lextok *);
288int proper_enabler(Lextok *);
289int putcode(FILE *, Sequence *, Element *, int, int, int);
290int q_is_sync(Lextok *);
291int qlen(Lextok *);
292int qfull(Lextok *);
293int qmake(Symbol *);
294int qrecv(Lextok *, int);
295int qsend(Lextok *);
296int remotelab(Lextok *);
297int remotevar(Lextok *);
298int Rval_struct(Lextok *, Symbol *, int);
299int setlocal(Lextok *, int);
300int setval(Lextok *, int);
301int sputtype(char *, int);
302int Sym_typ(Lextok *);
303int tl_main(int, char *[]);
304int Width_set(int *, int, Lextok *);
305int yyparse(void);
306int yywrap(void);
307int yylex(void);
308
309void AST_track(Lextok *, int);
310void add_seq(Lextok *);
311void alldone(int);
312void announce(char *);
313void c_state(Symbol *, Symbol *, Symbol *);
314void c_add_def(FILE *);
315void c_add_loc(FILE *, char *);
316void c_add_locinit(FILE *, int, char *);
317void c_add_use(FILE *);
318void c_chandump(FILE *);
319void c_preview(void);
320void c_struct(FILE *, char *, Symbol *);
321void c_track(Symbol *, Symbol *, Symbol *);
322void c_var(FILE *, char *, Symbol *);
323void c_wrapper(FILE *);
324void chanaccess(void);
325void check_param_count(int, Lextok *);
326void checkrun(Symbol *, int);
327void comment(FILE *, Lextok *, int);
328void cross_dsteps(Lextok *, Lextok *);
329void doq(Symbol *, int, RunList *);
330void dotag(FILE *, char *);
331void do_locinits(FILE *);
332void do_var(FILE *, int, char *, Symbol *, char *, char *, char *);
333void dump_struct(Symbol *, char *, RunList *);
334void dumpclaims(FILE *, int, char *);
335void dumpglobals(void);
336void dumplabels(void);
337void dumplocal(RunList *);
338void dumpsrc(int, int);
339void fatal(char *, char *);
340void fix_dest(Symbol *, Symbol *);
341void genaddproc(void);
342void genaddqueue(void);
343void gencodetable(FILE *);
344void genheader(void);
345void genother(void);
346void gensrc(void);
347void gensvmap(void);
348void genunio(void);
349void ini_struct(Symbol *);
350void loose_ends(void);
351void make_atomic(Sequence *, int);
352void match_trail(void);
353void no_side_effects(char *);
354void nochan_manip(Lextok *, Lextok *, int);
355void non_fatal(char *, char *);
356void ntimes(FILE *, int, int, char *c[]);
357void open_seq(int);
358void p_talk(Element *, int);
359void pickup_inline(Symbol *, Lextok *);
360void plunk_c_decls(FILE *);
361void plunk_c_fcts(FILE *);
362void plunk_expr(FILE *, char *);
363void plunk_inline(FILE *, char *, int);
364void prehint(Symbol *);
365void preruse(FILE *, Lextok *);
366void prune_opts(Lextok *);
367void pstext(int, char *);
368void pushbreak(void);
369void putname(FILE *, char *, Lextok *, int, char *);
370void putremote(FILE *, Lextok *, int);
371void putskip(int);
372void putsrc(Element *);
373void putstmnt(FILE *, Lextok *, int);
374void putunames(FILE *);
375void rem_Seq(void);
376void runnable(ProcList *, int, int);
377void sched(void);
378void setaccess(Symbol *, Symbol *, int, int);
379void set_lab(Symbol *, Element *);
380void setmtype(Lextok *);
381void setpname(Lextok *);
382void setptype(Lextok *, int, Lextok *);
383void setuname(Lextok *);
384void setutype(Lextok *, Symbol *, Lextok *);
385void setxus(Lextok *, int);
386void Srand(unsigned);
387void start_claim(int);
388void struct_name(Lextok *, Symbol *, int, char *);
389void symdump(void);
390void symvar(Symbol *);
391void trackchanuse(Lextok *, Lextok *, int);
392void trackvar(Lextok *, Lextok *);
393void trackrun(Lextok *);
394void trapwonly(Lextok * /* , char * */); /* spin.y and main.c */
395void typ2c(Symbol *);
396void typ_ck(int, int, char *);
397void undostmnt(Lextok *, int);
398void unrem_Seq(void);
399void unskip(int);
400void varcheck(Element *, Element *);
401void whoruns(int);
402void wrapup(int);
403void yyerror(char *, ...);
404#endif
This page took 0.036706 seconds and 4 git commands to generate.