Browse Source

Spin moved to legacy, APEX dependent

Signed-off-by: Álvaro Jurado <elbingmiss@gmail.com>
Álvaro Jurado 3 years ago
parent
commit
f2bd037f54
42 changed files with 0 additions and 38167 deletions
  1. 0 380
      sys/man/1/spin
  2. 0 11
      sys/src/cmd/spin/README
  3. 0 420
      sys/src/cmd/spin/dstep.c
  4. 0 1080
      sys/src/cmd/spin/flow.c
  5. 0 351
      sys/src/cmd/spin/guided.c
  6. 0 868
      sys/src/cmd/spin/main.c
  7. 0 794
      sys/src/cmd/spin/mesg.c
  8. 0 57
      sys/src/cmd/spin/mkfile
  9. 0 1538
      sys/src/cmd/spin/pangen1.c
  10. 0 7309
      sys/src/cmd/spin/pangen1.h
  11. 0 3203
      sys/src/cmd/spin/pangen2.c
  12. 0 1162
      sys/src/cmd/spin/pangen2.h
  13. 0 439
      sys/src/cmd/spin/pangen3.c
  14. 0 1193
      sys/src/cmd/spin/pangen3.h
  15. 0 360
      sys/src/cmd/spin/pangen4.c
  16. 0 736
      sys/src/cmd/spin/pangen4.h
  17. 0 866
      sys/src/cmd/spin/pangen5.c
  18. 0 433
      sys/src/cmd/spin/pangen5.h
  19. 0 2351
      sys/src/cmd/spin/pangen6.c
  20. 0 2849
      sys/src/cmd/spin/pangen6.h
  21. 0 934
      sys/src/cmd/spin/pangen7.c
  22. 0 461
      sys/src/cmd/spin/pc_zpp.c
  23. 0 455
      sys/src/cmd/spin/ps_msc.c
  24. 0 145
      sys/src/cmd/spin/reprosrc.c
  25. 0 641
      sys/src/cmd/spin/run.c
  26. 0 1103
      sys/src/cmd/spin/sched.c
  27. 0 429
      sys/src/cmd/spin/spin.h
  28. 0 947
      sys/src/cmd/spin/spin.y
  29. 0 1530
      sys/src/cmd/spin/spinlex.c
  30. 0 678
      sys/src/cmd/spin/structs.c
  31. 0 605
      sys/src/cmd/spin/sym.c
  32. 0 141
      sys/src/cmd/spin/tl.h
  33. 0 683
      sys/src/cmd/spin/tl_buchi.c
  34. 0 345
      sys/src/cmd/spin/tl_cache.c
  35. 0 254
      sys/src/cmd/spin/tl_lex.c
  36. 0 276
      sys/src/cmd/spin/tl_main.c
  37. 0 129
      sys/src/cmd/spin/tl_mem.c
  38. 0 411
      sys/src/cmd/spin/tl_parse.c
  39. 0 319
      sys/src/cmd/spin/tl_rewrt.c
  40. 0 904
      sys/src/cmd/spin/tl_trans.c
  41. 0 367
      sys/src/cmd/spin/vars.c
  42. 0 10
      sys/src/cmd/spin/version.h

+ 0 - 380
sys/man/1/spin

@@ -1,380 +0,0 @@
-.TH SPIN 1
-.SH NAME
-spin - verification tool for models of concurrent systems
-.SH SYNOPSIS
-.B spin
-[
-.I options
-]
-.I file
-.br
-.B spin
-.B -V
-.SH DESCRIPTION
-.I Spin
-is a tool for analyzing the logical consistency of
-asynchronous systems, specifically distributed software,
-multi-threaded systems, and communication protocols.
-A model of the system is specified
-in a guarded command language called Promela (process meta language).
-This modeling language supports dynamic creation of
-processes, nondeterministic case selection, loops, gotos,
-local and global variables.
-It also allows for a concise specification of logical
-correctness requirements, including, but not restricted
-to requirements expressed in linear temporal logic.
-.PP
-Given a Promela model stored in
-.IR file ,
-.I spin
-can perform interactive, guided, or random simulations
-of the system's execution.
-It can also generate a C program that performs an exhaustive
-verification of the correctness requirements for the system.
-The main options supported are as follows. (You can always get
-a full list of current options with the command "spin --").
-.
-.TF -Exxx
-.PD
-.TP
-.B -a
-Generate a verifier (a model checker) for the specification.
-The output is written into a set of C files named
-.BR pan.[cbhmt] ,
-that can be compiled
-.RB ( "pcc pan.c" )
-to produce an executable verifier.
-The online
-.I spin
-manuals contain
-the details on compilation and use of the verifiers.
-.
-.TP
-.B -b
-Do not execute
-.I printf
-statements in a simulation run.
-.
-.TP
-.B -c
-Produce an ASCII approximation of a message sequence
-chart for a random or guided (when combined with
-.BR -t )
-simulation run. See also option
-.BR -M .
-.
-.TP
-.B -Dxxx
-Pass
-.I -Dxxx
-to the preprocessor (see also
-.I -E
-and
-.IR -I ).
-.
-.TP
-.B -d
-Produce symbol table information for the model specified in
-.IR file .
-For each Promela object this information includes the type, name and
-number of elements (if declared as an array), the initial
-value (if a data object) or size (if a message channel), the
-scope (global or local), and whether the object is declared as
-a variable or as a parameter.  For message channels, the data types
-of the message fields are listed.
-For structure variables, the third field defines the
-name of the structure declaration that contains the variable.
-.
-.TP
-.B -Exxx
-Pass
-.I xxx
-to the preprocessor (see also
-.I -D
-and
-.IR -I ).
-.
-.TP
-.B -e
-If the specification contains multiple never claims, or ltl properties,
-compute the synchronous product of all claims and write the result
-to the standard output.
-.
-.TP
-.BI -f " ltl"
-Translate the LTL formula
-.I ltl
-into a
-.I never
-claim.
-.br
-This option reads a formula in LTL syntax from the second argument
-and translates it into Promela syntax (a
-.I never
-claim, which is Promela's
-equivalent of a Büchi Automaton).
-The LTL operators are written:
-.B []
-(always),
-.B <>
-(eventually),
-and
-.B U
-(strong until).  There is no
-.B X
-(next) operator, to secure
-compatibility with the partial order reduction rules that are
-applied during the verification process.
-If the formula contains spaces, it should be quoted to form a
-single argument to the
-.I spin
-command.
-.br
-This option has largely been replaced with the support
-for inline specification of ltl formula, in Spin version 6.0.
-.
-.TP
-.BI -F " file"
-Translate the LTL formula stored in
-.I file
-into a
-.I never
-claim.
-.br
-This behaves identically to option
-.B -f
-but will read the formula from the
-.I file
-instead of from the command line.
-The file should contain the formula as the first line.  Any text
-that follows this first line is ignored, so it can be used to
-store comments or annotation on the formula.
-(On some systems the quoting conventions of the shell complicate
-the use of option
-.BR -f .
-Option
-.B -F
-is meant to solve those problems.)
-.
-.TP
-.B -g
-In combination with option
-.BR -p ,
-print all global variable updates in a simulation run.
-.
-.TP
-.B -h
-At the end of a simulation run, print the value of the seed
-that was used for the random number generator.
-By specifying the same seed with the
-.B -n
-option, the exact
-run can be repeated later.
-.
-.TP
-.B -I
-Show the result of inlining and preprocessing.
-.
-.TP
-.B -i
-Perform an interactive simulation, prompting the user at
-every execution step that requires a nondeterministic choice
-to be made.  The simulation proceeds without user intervention
-when execution is deterministic.
-.
-.TP
-.BI -j N
-Skip printing for the first
-.I N
-steps in a simulation run.
-.
-.TP
-.B -J
-Reverse the evaluation order for nested unless statements,
-e.g., to match the way in which Java handles exceptions.
-.
-.TP
-.BI -k " file"
-Use the file name
-.I file
-as the trail-file, see also
-.BR -t .
-.
-.TP
-.B -l
-In combination with option
-.BR -p ,
-include all local variable updates in the output of a simulation run.
-.
-.TP
-.B -M
-Produce a message sequence chart in Postscript form for a
-random simulation or a guided simulation
-(when combined with
-.BR -t ),
-for the model in
-.IR file ,
-and write the result into
-.IR file.ps .
-See also option
-.BR -c .
-.
-.TP
-.B -m
-Changes the semantics of send events.
-Ordinarily, a send action will be (blocked) if the
-target message buffer is full.
-With this option a message sent to a full buffer is lost.
-.
-.TP
-.BI -n N
-Set the seed for a random simulation to the integer value
-.IR N .
-There is no space between the
-.B -n
-and the integer
-.IR N .
-.
-.TP
-.BI -N " file"
-Use the never claim stored in
-.I file
-to generate the verified (see
-.BR -a ).
-.
-.TP
-.BI -O
-Use the original scope rules from pre-Spin version 6.
-.
-.TP
-.BI -o [123]
-Turn off data-flow optimization (
-.IR -o1 ).
-Do not hide write-only variables (
-.I -o2
-) during verification.
-Turn off statement merging (
-.I -o3
-) during verification.
-Turn on rendezvous optimization (
-.I -o4
-) during verification.
-Turn on case caching (
-.I -o5
-) to reduce the size of pan.m,
-but losing accuracy in reachability reports.
-.
-.TP
-.BI -O
-Use the scope rules pre-version 6.0. In this case there are only two
-possible levels of scope for all data declarations: global, or proctype local.
-In version 6.0 and later there is a third level of scope: inlines or blocks.
-.
-.TP
-.BI -P xxx
-Use the command
-.I xxx
-for preprocessing instead of the standard C preprocessor.
-.
-.TP
-.B -p
-Include all statement executions in the output of simulation runs.
-.
-.TP
-.BI -q N
-Suppress the output generated for channel
-.B N
-during simulation runs.
-.
-.TP
-.B -r
-Show all message-receive events, giving
-the name and number of the receiving process
-and the corresponding the source line number.
-For each message parameter, show
-the message type and the message channel number and name.
-.
-.TP
-.B -s
-Include all send operations in the output of simulation runs.
-.
-.TP
-.B -T
-Do not automatically indent the
-.I printf
-output of process
-.I i
-with
-.I i
-tabs.
-.
-.TP
-.B -t[\f2N\f1]
-Perform a guided simulation, following the [\f2N\f1th] error trail that
-was produces by an earlier verification run, see the online manuals
-for the details on verification. By default the error trail is looked for
-in a file with the same basename as the model, and with extension .trail.
-See also
-.BR -k .
-.
-.TP
-.B -v
-Verbose mode, add some more detail, and generate more
-hints and warnings about the model.
-.
-.TP
-.B -V
-Prints the
-.I spin
-version number and exit.
-.
-.PP
-With only a filename as an argument and no option flags,
-.I spin
-performs a random simulation of the model specified in
-the file.
-This normally does not generate output, except what is generated
-explicitly by the user within the model with
-.I printf
-statements, and some details about the final state that is
-reached after the simulation completes.
-The group of options
-.B -bgilmprstv
-is used to set the desired level of information that the user wants
-about a random, guided, or interactive simulation run.
-Every line of output normally contains a reference to the source
-line in the specification that generated it.
-If option
-.B -i
-is included, the simulation i
-.IR interactive ,
-or if option
-.B -t
-or
-.BI -k file
-is added, the simulation is
-.IR guided .
-.
-.SH SOURCE
-.B /sys/src/cmd/spin
-.SH SEE ALSO
-.in +4
-.ti -4
-.B http://spinroot.com/spin/Man/
-.br
-.in -4
-G.J. Holzmann,
-.IR "The Spin Model Checker (Primer and Reference Manual)" ,
-Addison-Wesley, Reading, Mass., 2004.
-.br
-—, `The model checker Spin,'
-.IR "IEEE Trans. on SE" ,
-Vol, 23, No. 5, May 1997.
-.br
-—, `Design and validation of protocols: a tutorial,'
-.IR "Computer Networks and ISDN Systems" ,
-Vol. 25, No. 9, 1993, pp. 981-1017.
-.br
-—,
-.IR "Design and Validation of Computer Protocols" ,
-Prentice Hall, Englewood Cliffs, NJ, 1991.

+ 0 - 11
sys/src/cmd/spin/README

@@ -1,11 +0,0 @@
-the latest version of spin is always
-available via:
-	http://spinroot.com/spin/whatispin.html
-
-to make the sources compile with the mkfile on Plan 9
-the following changes were made:
-
-	omitted memory.h from spin.h
-	changed /lib/cpp to /bin/cpp in main.c
-	simplified non_fatal() in main.c to remove
-	use of yychar

+ 0 - 420
sys/src/cmd/spin/dstep.c

@@ -1,420 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-/***** spin: dstep.c *****/
-
-/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
-/* All Rights Reserved.  This software is for educational purposes only.  */
-/* No guarantee whatsoever is expressed or implied by the distribution of */
-/* this code.  Permission is given to distribute this code provided that  */
-/* this introductory message is not removed and no monies are exchanged.  */
-/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
-/*             http://spinroot.com/                                       */
-/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
-
-#include "spin.h"
-#include "y.tab.h"
-
-#define MAXDSTEP	2048	/* was 512 */
-
-char	*NextLab[64];
-int	Level=0, GenCode=0, IsGuard=0, TestOnly=0;
-
-static int	Tj=0, Jt=0, LastGoto=0;
-static int	Tojump[MAXDSTEP], Jumpto[MAXDSTEP], Special[MAXDSTEP];
-static void	putCode(FILE *, Element *, Element *, Element *, int);
-
-extern int	Pid, separate, OkBreak;
-
-static void
-Sourced(int n, int special)
-{	int i;
-	for (i = 0; i < Tj; i++)
-		if (Tojump[i] == n)
-			return;
-	if (Tj >= MAXDSTEP)
-		fatal("d_step sequence too long", (char *)0);
-	Special[Tj] = special;
-	Tojump[Tj++] = n;
-}
-
-static void
-Dested(int n)
-{	int i;
-	for (i = 0; i < Tj; i++)
-		if (Tojump[i] == n)
-			return;
-	for (i = 0; i < Jt; i++)
-		if (Jumpto[i] == n)
-			return;
-	if (Jt >= MAXDSTEP)
-		fatal("d_step sequence too long", (char *)0);
-	Jumpto[Jt++] = n;
-	LastGoto = 1;
-}
-
-static void
-Mopup(FILE *fd)
-{	int i, j;
-
-	for (i = 0; i < Jt; i++)
-	{	for (j = 0; j < Tj; j++)
-			if (Tojump[j] == Jumpto[i])
-				break;
-		if (j == Tj)
-		{	char buf[16];
-			if (Jumpto[i] == OkBreak)
-			{	if (!LastGoto)
-				fprintf(fd, "S_%.3d_0:	/* break-dest */\n",
-					OkBreak);
-			} else {
-				sprintf(buf, "S_%.3d_0", Jumpto[i]);
-				non_fatal("goto %s breaks from d_step seq", buf);
-	}	}	}
-	for (j = 0; j < Tj; j++)
-	{	for (i = 0; i < Jt; i++)
-			if (Tojump[j] == Jumpto[i])
-				break;
-#ifdef DEBUG
-		if (i == Jt && !Special[i])
-			fprintf(fd, "\t\t/* no goto's to S_%.3d_0 */\n",
-			Tojump[j]);
-#endif
-	}
-	for (j = i = 0; j < Tj; j++)
-		if (Special[j])
-		{	Tojump[i] = Tojump[j];
-			Special[i] = 2;
-			if (i >= MAXDSTEP)
-			fatal("cannot happen (dstep.c)", (char *)0);
-			i++;
-		}
-	Tj = i;	/* keep only the global exit-labels */
-	Jt = 0;
-}
-
-static int
-FirstTime(int n)
-{	int i;
-	for (i = 0; i < Tj; i++)
-		if (Tojump[i] == n)
-			return (Special[i] <= 1);
-	return 1;
-}
-
-static void
-illegal(Element *e, char *str)
-{
-	printf("illegal operator in 'd_step:' '");
-	comment(stdout, e->n, 0);
-	printf("'\n");
-	fatal("'%s'", str);
-}
-
-static void
-filterbad(Element *e)
-{
-	switch (e->n->ntyp) {
-	case ASSERT:
-	case PRINT:
-	case 'c':
-		/* run cannot be completely undone
-		 * with sv_save-sv_restor
-		 */
-		if (any_oper(e->n->lft, RUN))
-			illegal(e, "run operator in d_step");
-
-		/* remote refs inside d_step sequences
-		 * would be okay, but they cannot always
-		 * be interpreted by the simulator the
-		 * same as by the verifier (e.g., for an
-		 * error trail)
-		 */
-		if (any_oper(e->n->lft, 'p'))
-			illegal(e, "remote reference in d_step");
-		break;
-	case '@':
-		illegal(e, "process termination");
-		break;
-	case D_STEP:
-		illegal(e, "nested d_step sequence");
-		break;
-	case ATOMIC:
-		illegal(e, "nested atomic sequence");
-		break;
-	default:
-		break;
-	}
-}
-
-static int
-CollectGuards(FILE *fd, Element *e, int inh)
-{	SeqList *h; Element *ee;
-
-	for (h = e->sub; h; h = h->nxt)
-	{	ee = huntstart(h->this->frst);
-		filterbad(ee);
-		switch (ee->n->ntyp) {
-		case NON_ATOMIC:
-			inh += CollectGuards(fd, ee->n->sl->this->frst, inh);
-			break;
-		case  IF:
-			inh += CollectGuards(fd, ee, inh);
-			break;
-		case '.':
-			if (ee->nxt->n->ntyp == DO)
-				inh += CollectGuards(fd, ee->nxt, inh);
-			break;
-		case ELSE:
-			if (inh++ > 0) fprintf(fd, " || ");
-/* 4.2.5 */		if (!pid_is_claim(Pid))
-				fprintf(fd, "(boq == -1 /* else */)");
-			else
-				fprintf(fd, "(1 /* else */)");
-			break;
-		case 'R':
-			if (inh++ > 0) fprintf(fd, " || ");
-			fprintf(fd, "("); TestOnly=1;
-			putstmnt(fd, ee->n, ee->seqno);
-			fprintf(fd, ")"); TestOnly=0;
-			break;
-		case 'r':
-			if (inh++ > 0) fprintf(fd, " || ");
-			fprintf(fd, "("); TestOnly=1;
-			putstmnt(fd, ee->n, ee->seqno);
-			fprintf(fd, ")"); TestOnly=0;
-			break;
-		case 's':
-			if (inh++ > 0) fprintf(fd, " || ");
-			fprintf(fd, "("); TestOnly=1;
-/* 4.2.1 */		if (!pid_is_claim(Pid)) fprintf(fd, "(boq == -1) && ");
-			putstmnt(fd, ee->n, ee->seqno);
-			fprintf(fd, ")"); TestOnly=0;
-			break;
-		case 'c':
-			if (inh++ > 0) fprintf(fd, " || ");
-			fprintf(fd, "("); TestOnly=1;
-			if (!pid_is_claim(Pid))
-				fprintf(fd, "(boq == -1 && ");
-			putstmnt(fd, ee->n->lft, e->seqno);
-			if (!pid_is_claim(Pid))
-				fprintf(fd, ")");
-			fprintf(fd, ")"); TestOnly=0;
-			break;
-	}	}
-	return inh;
-}
-
-int
-putcode(FILE *fd, Sequence *s, Element *nxt, int justguards, int ln, int seqno)
-{	int isg=0; char buf[64];
-
-	NextLab[0] = "continue";
-	filterbad(s->frst);
-
-	switch (s->frst->n->ntyp) {
-	case UNLESS:
-		non_fatal("'unless' inside d_step - ignored", (char *) 0);
-		return putcode(fd, s->frst->n->sl->this, nxt, 0, ln, seqno);
-	case NON_ATOMIC:
-		(void) putcode(fd, s->frst->n->sl->this, ZE, 1, ln, seqno);
-		break;
-	case IF:
-		fprintf(fd, "if (!(");
-		if (!CollectGuards(fd, s->frst, 0))	/* what about boq? */
-			fprintf(fd, "1");
-		fprintf(fd, "))\n\t\t\tcontinue;");
-		isg = 1;
-		break;
-	case '.':
-		if (s->frst->nxt->n->ntyp == DO)
-		{	fprintf(fd, "if (!(");
-			if (!CollectGuards(fd, s->frst->nxt, 0))
-				fprintf(fd, "1");
-			fprintf(fd, "))\n\t\t\tcontinue;");
-			isg = 1;
-		}
-		break;
-	case 'R': /* <- can't really happen (it's part of a 'c') */
-		fprintf(fd, "if (!("); TestOnly=1;
-		putstmnt(fd, s->frst->n, s->frst->seqno);
-		fprintf(fd, "))\n\t\t\tcontinue;"); TestOnly=0;
-		break;
-	case 'r':
-		fprintf(fd, "if (!("); TestOnly=1;
-		putstmnt(fd, s->frst->n, s->frst->seqno);
-		fprintf(fd, "))\n\t\t\tcontinue;"); TestOnly=0;
-		break;
-	case 's':
-		fprintf(fd, "if (");
-#if 1
-/* 4.2.1 */	if (!pid_is_claim(Pid)) fprintf(fd, "(boq != -1) || ");
-#endif
-		fprintf(fd, "!("); TestOnly=1;
-		putstmnt(fd, s->frst->n, s->frst->seqno);
-		fprintf(fd, "))\n\t\t\tcontinue;"); TestOnly=0;
-		break;
-	case 'c':
-		fprintf(fd, "if (!(");
-		if (!pid_is_claim(Pid)) fprintf(fd, "boq == -1 && ");
-		TestOnly=1;
-		putstmnt(fd, s->frst->n->lft, s->frst->seqno);
-		fprintf(fd, "))\n\t\t\tcontinue;"); TestOnly=0;
-		break;
-	case ELSE:
-		fprintf(fd, "if (boq != -1 || (");
-		if (separate != 2) fprintf(fd, "trpt->");
-		fprintf(fd, "o_pm&1))\n\t\t\tcontinue;");
-		break;
-	case ASGN:	/* new 3.0.8 */
-		fprintf(fd, "IfNotBlocked");
-		break;
-	}
-	if (justguards) return 0;
-
-	fprintf(fd, "\n\t\tsv_save();\n\t\t");
-#if 1
-	fprintf(fd, "reached[%d][%d] = 1;\n\t\t", Pid, seqno);
-	fprintf(fd, "reached[%d][t->st] = 1;\n\t\t", Pid);	/* true next state */
-	fprintf(fd, "reached[%d][tt] = 1;\n", Pid);		/* true current state */
-#endif
-	sprintf(buf, "Uerror(\"block in d_step seq, line %d\")", ln);
-	NextLab[0] = buf;
-	putCode(fd, s->frst, s->extent, nxt, isg);
-
-	if (nxt)
-	{	extern Symbol *Fname;
-		extern int lineno;
-
-		if (FirstTime(nxt->Seqno)
-		&& (!(nxt->status & DONE2) || !(nxt->status & D_ATOM)))
-		{	fprintf(fd, "S_%.3d_0: /* 1 */\n", nxt->Seqno);
-			nxt->status |= DONE2;
-			LastGoto = 0;
-		}
-		Sourced(nxt->Seqno, 1);
-		lineno = ln;
-		Fname = nxt->n->fn;
-		Mopup(fd);
-	}
-	unskip(s->frst->seqno);
-	return LastGoto;
-}
-
-static void
-putCode(FILE *fd, Element *f, Element *last, Element *next, int isguard)
-{	Element *e, *N;
-	SeqList *h; int i;
-	char NextOpt[64];
-	static int bno = 0;
-
-	for (e = f; e; e = e->nxt)
-	{	if (e->status & DONE2)
-			continue;
-		e->status |= DONE2;
-
-		if (!(e->status & D_ATOM))
-		{	if (!LastGoto)
-			{	fprintf(fd, "\t\tgoto S_%.3d_0;\n",
-					e->Seqno);
-				Dested(e->Seqno);
-			}
-			break;
-		}
-		fprintf(fd, "S_%.3d_0: /* 2 */\n", e->Seqno);
-		LastGoto = 0;
-		Sourced(e->Seqno, 0);
-
-		if (!e->sub)
-		{	filterbad(e);
-			switch (e->n->ntyp) {
-			case NON_ATOMIC:
-				h = e->n->sl;
-				putCode(fd, h->this->frst,
-					h->this->extent, e->nxt, 0);
-				break;
-			case BREAK:
-				if (LastGoto) break;
-				if (e->nxt)
-				{	i = target( huntele(e->nxt,
-						e->status, -1))->Seqno;
-					fprintf(fd, "\t\tgoto S_%.3d_0;	", i);
-					fprintf(fd, "/* 'break' */\n");
-					Dested(i);
-				} else
-				{	if (next)
-					{	fprintf(fd, "\t\tgoto S_%.3d_0;",
-							next->Seqno);
-						fprintf(fd, " /* NEXT */\n");
-						Dested(next->Seqno);
-					} else
-					fatal("cannot interpret d_step", 0);
-				}
-				break;
-			case GOTO:
-				if (LastGoto) break;
-				i = huntele( get_lab(e->n,1),
-					e->status, -1)->Seqno;
-				fprintf(fd, "\t\tgoto S_%.3d_0;	", i);
-				fprintf(fd, "/* 'goto' */\n");
-				Dested(i);
-				break;
-			case '.':
-				if (LastGoto) break;
-				if (e->nxt && (e->nxt->status & DONE2))
-				{	i = e->nxt?e->nxt->Seqno:0;
-					fprintf(fd, "\t\tgoto S_%.3d_0;", i);
-					fprintf(fd, " /* '.' */\n");
-					Dested(i);
-				}
-				break;
-			default:
-				putskip(e->seqno);
-				GenCode = 1; IsGuard = isguard;
-				fprintf(fd, "\t\t");
-				putstmnt(fd, e->n, e->seqno);
-				fprintf(fd, ";\n");
-				GenCode = IsGuard = isguard = LastGoto = 0;
-				break;
-			}
-			i = e->nxt?e->nxt->Seqno:0;
-			if (e->nxt && e->nxt->status & DONE2 && !LastGoto)
-			{	fprintf(fd, "\t\tgoto S_%.3d_0; ", i);
-				fprintf(fd, "/* ';' */\n");
-				Dested(i);
-				break;
-			}
-		} else
-		{	for (h = e->sub, i=1; h; h = h->nxt, i++)
-			{	sprintf(NextOpt, "goto S_%.3d_%d",
-					e->Seqno, i);
-				NextLab[++Level] = NextOpt;
-				N = (e->n && e->n->ntyp == DO) ? e : e->nxt;
-				putCode(fd, h->this->frst,
-					h->this->extent, N, 1);
-				Level--;
-				fprintf(fd, "%s: /* 3 */\n", &NextOpt[5]);
-				LastGoto = 0;
-			}
-			if (!LastGoto)
-			{	fprintf(fd, "\t\tUerror(\"blocking sel ");
-				fprintf(fd, "in d_step (nr.%d, near line %d)\");\n",
-				bno++, (e->n)?e->n->ln:0);
-				LastGoto = 0;
-			}
-		}
-		if (e == last)
-		{	if (!LastGoto && next)
-			{	fprintf(fd, "\t\tgoto S_%.3d_0;\n",
-					next->Seqno);
-				Dested(next->Seqno);
-			}
-			break;
-	}	}
-}

+ 0 - 1080
sys/src/cmd/spin/flow.c

@@ -1,1080 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-/***** spin: flow.c *****/
-
-/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
-/* All Rights Reserved.  This software is for educational purposes only.  */
-/* No guarantee whatsoever is expressed or implied by the distribution of */
-/* this code.  Permission is given to distribute this code provided that  */
-/* this introductory message is not removed and no monies are exchanged.  */
-/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
-/*             http://spinroot.com/                                       */
-/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
-
-#include "spin.h"
-#include "y.tab.h"
-
-extern Symbol	*Fname;
-extern int	nr_errs, lineno, verbose, in_for;
-extern int16_t	has_unless, has_badelse, has_xu;
-extern char CurScope[MAXSCOPESZ];
-
-Element *Al_El = ZE;
-Label	*labtab = (Label *) 0;
-int	Unique = 0, Elcnt = 0, DstepStart = -1;
-int	initialization_ok = 1;
-
-static Lbreak	*breakstack = (Lbreak *) 0;
-static Lextok	*innermost;
-static SeqList	*cur_s = (SeqList *) 0;
-static int	break_id=0;
-
-static Element	*if_seq(Lextok *);
-static Element	*new_el(Lextok *);
-static Element	*unless_seq(Lextok *);
-static void	add_el(Element *, Sequence *);
-static void	attach_escape(Sequence *, Sequence *);
-static void	mov_lab(Symbol *, Element *, Element *);
-static void	walk_atomic(Element *, Element *, int);
-
-void
-open_seq(int top)
-{	SeqList *t;
-	Sequence *s = (Sequence *) emalloc(sizeof(Sequence));
-
-	t = seqlist(s, cur_s);
-	cur_s = t;
-	if (top)
-	{	Elcnt = 1;
-		initialization_ok = 1;
-	}
-}
-
-void
-rem_Seq(void)
-{
-	DstepStart = Unique;
-}
-
-void
-unrem_Seq(void)
-{
-	DstepStart = -1;
-}
-
-static int
-Rjumpslocal(Element *q, Element *stop)
-{	Element *lb, *f;
-	SeqList *h;
-
-	/* allow no jumps out of a d_step sequence */
-	for (f = q; f && f != stop; f = f->nxt)
-	{	if (f && f->n && f->n->ntyp == GOTO)
-		{	lb = get_lab(f->n, 0);
-			if (!lb || lb->Seqno < DstepStart)
-			{	lineno = f->n->ln;
-				Fname = f->n->fn;
-				return 0;
-		}	}
-		for (h = f->sub; h; h = h->nxt)
-		{	if (!Rjumpslocal(h->this->frst, h->this->last))
-				return 0;
-
-	}	}
-	return 1;
-}
-
-void
-cross_dsteps(Lextok *a, Lextok *b)
-{
-	if (a && b
-	&&  a->indstep != b->indstep)
-	{	lineno = a->ln;
-		Fname  = a->fn;
-		fatal("jump into d_step sequence", (char *) 0);
-	}
-}
-
-int
-is_skip(Lextok *n)
-{
-	return (n->ntyp == PRINT
-	||	n->ntyp == PRINTM
-	||	(n->ntyp == 'c'
-		&& n->lft
-		&& n->lft->ntyp == CONST
-		&& n->lft->val  == 1));
-}
-
-void
-check_sequence(Sequence *s)
-{	Element *e, *le = ZE;
-	Lextok *n;
-	int cnt = 0;
-
-	for (e = s->frst; e; le = e, e = e->nxt)
-	{	n = e->n;
-		if (is_skip(n) && !has_lab(e, 0))
-		{	cnt++;
-			if (cnt > 1
-			&&  n->ntyp != PRINT
-			&&  n->ntyp != PRINTM)
-			{	if (verbose&32)
-					printf("spin: %s:%d, redundant skip\n",
-						n->fn->name, n->ln);
-				if (e != s->frst
-				&&  e != s->last
-				&&  e != s->extent)
-				{	e->status |= DONE;	/* not unreachable */
-					le->nxt = e->nxt;	/* remove it */
-					e = le;
-				}
-			}
-		} else
-			cnt = 0;
-	}
-}
-
-void
-prune_opts(Lextok *n)
-{	SeqList *l;
-	extern Symbol *context;
-	extern char *claimproc;
-
-	if (!n
-	|| (context && claimproc && strcmp(context->name, claimproc) == 0))
-		return;
-
-	for (l = n->sl; l; l = l->nxt)	/* find sequences of unlabeled skips */
-		check_sequence(l->this);
-}
-
-Sequence *
-close_seq(int nottop)
-{	Sequence *s = cur_s->this;
-	Symbol *z;
-
-	if (nottop == 0)	/* end of proctype body */
-	{	initialization_ok = 1;
-	}
-
-	if (nottop > 0 && (z = has_lab(s->frst, 0)))
-	{	printf("error: (%s:%d) label %s placed incorrectly\n",
-			(s->frst->n)?s->frst->n->fn->name:"-",
-			(s->frst->n)?s->frst->n->ln:0,
-			z->name);
-		switch (nottop) {
-		case 1:
-			printf("=====> stmnt unless Label: stmnt\n");
-			printf("sorry, cannot jump to the guard of an\n");
-			printf("escape (it is not a unique state)\n");
-			break;
-		case 2:
-			printf("=====> instead of  ");
-			printf("\"Label: stmnt unless stmnt\"\n");
-			printf("=====> always use  ");
-			printf("\"Label: { stmnt unless stmnt }\"\n");
-			break;
-		case 3:
-			printf("=====> instead of  ");
-			printf("\"atomic { Label: statement ... }\"\n");
-			printf("=====> always use  ");
-			printf("\"Label: atomic { statement ... }\"\n");
-			break;
-		case 4:
-			printf("=====> instead of  ");
-			printf("\"d_step { Label: statement ... }\"\n");
-			printf("=====> always use  ");
-			printf("\"Label: d_step { statement ... }\"\n");
-			break;
-		case 5:
-			printf("=====> instead of  ");
-			printf("\"{ Label: statement ... }\"\n");
-			printf("=====> always use  ");
-			printf("\"Label: { statement ... }\"\n");
-			break;
-		case 6:
-			printf("=====>instead of\n");
-			printf("	do (or if)\n");
-			printf("	:: ...\n");
-			printf("	:: Label: statement\n");
-			printf("	od (of fi)\n");
-			printf("=====>always use\n");
-			printf("Label:	do (or if)\n");
-			printf("	:: ...\n");
-			printf("	:: statement\n");
-			printf("	od (or fi)\n");
-			break;
-		case 7:
-			printf("cannot happen - labels\n");
-			break;
-		}
-		alldone(1);
-	}
-
-	if (nottop == 4
-	&& !Rjumpslocal(s->frst, s->last))
-		fatal("non_local jump in d_step sequence", (char *) 0);
-
-	cur_s = cur_s->nxt;
-	s->maxel = Elcnt;
-	s->extent = s->last;
-	if (!s->last)
-		fatal("sequence must have at least one statement",
-		      (char *) 0);
-	return s;
-}
-
-Lextok *
-do_unless(Lextok *No, Lextok *Es)
-{	SeqList *Sl;
-	Lextok *Re = nn(ZN, UNLESS, ZN, ZN);
-	Re->ln = No->ln;
-	Re->fn = No->fn;
-
-	has_unless++;
-	if (Es->ntyp == NON_ATOMIC)
-		Sl = Es->sl;
-	else
-	{	open_seq(0); add_seq(Es);
-		Sl = seqlist(close_seq(1), 0);
-	}
-
-	if (No->ntyp == NON_ATOMIC)
-	{	No->sl->nxt = Sl;
-		Sl = No->sl;
-	} else	if (No->ntyp == ':'
-		&& (No->lft->ntyp == NON_ATOMIC
-		||  No->lft->ntyp == ATOMIC
-		||  No->lft->ntyp == D_STEP))
-	{
-		int tok = No->lft->ntyp;
-
-		No->lft->sl->nxt = Sl;
-		Re->sl = No->lft->sl;
-
-		open_seq(0); add_seq(Re);
-		Re = nn(ZN, tok, ZN, ZN);
-		Re->sl = seqlist(close_seq(7), 0);
-		Re->ln = No->ln;
-		Re->fn = No->fn;
-
-		Re = nn(No, ':', Re, ZN);	/* lift label */
-		Re->ln = No->ln;
-		Re->fn = No->fn;
-		return Re;
-	} else
-	{	open_seq(0); add_seq(No);
-		Sl = seqlist(close_seq(2), Sl);
-	}
-
-	Re->sl = Sl;
-	return Re;
-}
-
-SeqList *
-seqlist(Sequence *s, SeqList *r)
-{	SeqList *t = (SeqList *) emalloc(sizeof(SeqList));
-
-	t->this = s;
-	t->nxt = r;
-	return t;
-}
-
-static Element *
-new_el(Lextok *n)
-{	Element *m;
-
-	if (n)
-	{	if (n->ntyp == IF || n->ntyp == DO)
-			return if_seq(n);
-		if (n->ntyp == UNLESS)
-			return unless_seq(n);
-	}
-	m = (Element *) emalloc(sizeof(Element));
-	m->n = n;
-	m->seqno = Elcnt++;
-	m->Seqno = Unique++;
-	m->Nxt = Al_El; Al_El = m;
-	return m;
-}
-
-static int
-has_chanref(Lextok *n)
-{
-	if (!n) return 0;
-
-	switch (n->ntyp) {
-	case 's':	case 'r':
-#if 0
-	case 'R':	case LEN:
-#endif
-	case FULL:	case NFULL:
-	case EMPTY:	case NEMPTY:
-		return 1;
-	default:
-		break;
-	}
-	if (has_chanref(n->lft))
-		return 1;
-
-	return has_chanref(n->rgt);
-}
-
-void
-loose_ends(void)	/* properly tie-up ends of sub-sequences */
-{	Element *e, *f;
-
-	for (e = Al_El; e; e = e->Nxt)
-	{	if (!e->n
-		||  !e->nxt)
-			continue;
-		switch (e->n->ntyp) {
-		case ATOMIC:
-		case NON_ATOMIC:
-		case D_STEP:
-			f = e->nxt;
-			while (f && f->n->ntyp == '.')
-				f = f->nxt;
-			if (0) printf("link %d, {%d .. %d} -> %d (ntyp=%d) was %d\n",
-				e->seqno,
-				e->n->sl->this->frst->seqno,
-				e->n->sl->this->last->seqno,
-				f?f->seqno:-1, f?f->n->ntyp:-1,
-				e->n->sl->this->last->nxt?e->n->sl->this->last->nxt->seqno:-1);
-			if (!e->n->sl->this->last->nxt)
-				e->n->sl->this->last->nxt = f;
-			else
-			{	if (e->n->sl->this->last->nxt->n->ntyp != GOTO)
-				{	if (!f || e->n->sl->this->last->nxt->seqno != f->seqno)
-					non_fatal("unexpected: loose ends",
-						  (char *)0);
-				} else
-					e->n->sl->this->last = e->n->sl->this->last->nxt;
-				/*
-				 * fix_dest can push a goto into the nxt position
-				 * in that case the goto wins and f is not needed
-				 * but the last fields needs adjusting
-				 */
-			}
-			break;
-	}	}
-}
-
-static Element *
-if_seq(Lextok *n)
-{	int	tok = n->ntyp;
-	SeqList	*s  = n->sl;
-	Element	*e  = new_el(ZN);
-	Element	*t  = new_el(nn(ZN,'.',ZN,ZN)); /* target */
-	SeqList	*z, *prev_z = (SeqList *) 0;
-	SeqList *move_else  = (SeqList *) 0;	/* to end of optionlist */
-	int	ref_chans = 0;
-
-	for (z = s; z; z = z->nxt)
-	{	if (!z->this->frst)
-			continue;
-		if (z->this->frst->n->ntyp == ELSE)
-		{	if (move_else)
-				fatal("duplicate `else'", (char *) 0);
-			if (z->nxt)	/* is not already at the end */
-			{	move_else = z;
-				if (prev_z)
-					prev_z->nxt = z->nxt;
-				else
-					s = n->sl = z->nxt;
-				continue;
-			}
-		} else
-			ref_chans |= has_chanref(z->this->frst->n);
-		prev_z = z;
-	}
-	if (move_else)
-	{	move_else->nxt = (SeqList *) 0;
-		/* if there is no prev, then else was at the end */
-		if (!prev_z) fatal("cannot happen - if_seq", (char *) 0);
-		prev_z->nxt = move_else;
-		prev_z = move_else;
-	}
-	if (prev_z
-	&&  ref_chans
-	&&  prev_z->this->frst->n->ntyp == ELSE)
-	{	prev_z->this->frst->n->val = 1;
-		has_badelse++;
-		if (has_xu)
-		{	fatal("invalid use of 'else' combined with i/o and xr/xs assertions,",
-				(char *)0);
-		} else
-		{	non_fatal("dubious use of 'else' combined with i/o,",
-				(char *)0);
-		}
-		nr_errs--;
-	}
-
-	e->n = nn(n, tok, ZN, ZN);
-	e->n->sl = s;			/* preserve as info only */
-	e->sub = s;
-	for (z = s; z; prev_z = z, z = z->nxt)
-		add_el(t, z->this);	/* append target */
-	if (tok == DO)
-	{	add_el(t, cur_s->this); /* target upfront */
-		t = new_el(nn(n, BREAK, ZN, ZN)); /* break target */
-		set_lab(break_dest(), t);	/* new exit  */
-		breakstack = breakstack->nxt;	/* pop stack */
-	}
-	add_el(e, cur_s->this);
-	add_el(t, cur_s->this);
-	return e;			/* destination node for label */
-}
-
-static void
-escape_el(Element *f, Sequence *e)
-{	SeqList *z;
-
-	for (z = f->esc; z; z = z->nxt)
-		if (z->this == e)
-			return;	/* already there */
-
-	/* cover the lower-level escapes of this state */
-	for (z = f->esc; z; z = z->nxt)
-		attach_escape(z->this, e);
-
-	/* now attach escape to the state itself */
-
-	f->esc = seqlist(e, f->esc);	/* in lifo order... */
-#ifdef DEBUG
-	printf("attach %d (", e->frst->Seqno);
-	comment(stdout, e->frst->n, 0);
-	printf(")	to %d (", f->Seqno);
-	comment(stdout, f->n, 0);
-	printf(")\n");
-#endif
-	switch (f->n->ntyp) {
-	case UNLESS:
-		attach_escape(f->sub->this, e);
-		break;
-	case IF:
-	case DO:
-		for (z = f->sub; z; z = z->nxt)
-			attach_escape(z->this, e);
-		break;
-	case D_STEP:
-		/* attach only to the guard stmnt */
-		escape_el(f->n->sl->this->frst, e);
-		break;
-	case ATOMIC:
-	case NON_ATOMIC:
-		/* attach to all stmnts */
-		attach_escape(f->n->sl->this, e);
-		break;
-	}
-}
-
-static void
-attach_escape(Sequence *n, Sequence *e)
-{	Element *f;
-
-	for (f = n->frst; f; f = f->nxt)
-	{	escape_el(f, e);
-		if (f == n->extent)
-			break;
-	}
-}
-
-static Element *
-unless_seq(Lextok *n)
-{	SeqList	*s  = n->sl;
-	Element	*e  = new_el(ZN);
-	Element	*t  = new_el(nn(ZN,'.',ZN,ZN)); /* target */
-	SeqList	*z;
-
-	e->n = nn(n, UNLESS, ZN, ZN);
-	e->n->sl = s;			/* info only */
-	e->sub = s;
-
-	/* need 2 sequences: normal execution and escape */
-	if (!s || !s->nxt || s->nxt->nxt)
-		fatal("unexpected unless structure", (char *)0);
-
-	/* append the target state to both */
-	for (z = s; z; z = z->nxt)
-		add_el(t, z->this);
-
-	/* attach escapes to all states in normal sequence */
-	attach_escape(s->this, s->nxt->this);
-
-	add_el(e, cur_s->this);
-	add_el(t, cur_s->this);
-#ifdef DEBUG
-	printf("unless element (%d,%d):\n", e->Seqno, t->Seqno);
-	for (z = s; z; z = z->nxt)
-	{	Element *x; printf("\t%d,%d,%d :: ",
-		z->this->frst->Seqno,
-		z->this->extent->Seqno,
-		z->this->last->Seqno);
-		for (x = z->this->frst; x; x = x->nxt)
-			printf("(%d)", x->Seqno);
-		printf("\n");
-	}
-#endif
-	return e;
-}
-
-Element *
-mk_skip(void)
-{	Lextok  *t = nn(ZN, CONST, ZN, ZN);
-	t->val = 1;
-	return new_el(nn(ZN, 'c', t, ZN));
-}
-
-static void
-add_el(Element *e, Sequence *s)
-{
-	if (e->n->ntyp == GOTO)
-	{	Symbol *z = has_lab(e, (1|2|4));
-		if (z)
-		{	Element *y; /* insert a skip */
-			y = mk_skip();
-			mov_lab(z, e, y); /* inherit label */
-			add_el(y, s);
-	}	}
-#ifdef DEBUG
-	printf("add_el %d after %d -- ",
-	e->Seqno, (s->last)?s->last->Seqno:-1);
-	comment(stdout, e->n, 0);
-	printf("\n");
-#endif
-	if (!s->frst)
-		s->frst = e;
-	else
-		s->last->nxt = e;
-	s->last = e;
-}
-
-static Element *
-colons(Lextok *n)
-{
-	if (!n)
-		return ZE;
-	if (n->ntyp == ':')
-	{	Element *e = colons(n->lft);
-		set_lab(n->sym, e);
-		return e;
-	}
-	innermost = n;
-	return new_el(n);
-}
-
-void
-add_seq(Lextok *n)
-{	Element *e;
-
-	if (!n) return;
-	innermost = n;
-	e = colons(n);
-	if (innermost->ntyp != IF
-	&&  innermost->ntyp != DO
-	&&  innermost->ntyp != UNLESS)
-		add_el(e, cur_s->this);
-}
-
-void
-show_lab(void)
-{	Label *l;
-	for (l = labtab; l; l = l->nxt)
-		printf("label %s\n", l->s->name);
-}
-
-void
-set_lab(Symbol *s, Element *e)
-{	Label *l; extern Symbol *context;
-	int cur_uiid = is_inline();
-
-	if (!s) return;
-
-	for (l = labtab; l; l = l->nxt)
-	{	if (strcmp(l->s->name, s->name) == 0
-		&&  l->c == context
-		&&  l->uiid == cur_uiid)
-		{	non_fatal("label %s redeclared", s->name);
-			break;
-	}	}
-
-	l = (Label *) emalloc(sizeof(Label));
-	l->s = s;
-	l->c = context;
-	l->e = e;
-	l->uiid = cur_uiid;
-	l->nxt = labtab;
-	labtab = l;
-}
-
-static Label *
-get_labspec(Lextok *n)
-{	Symbol *s = n->sym;
-	Label *l, *anymatch = (Label *) 0;
-	int cur_uiid = n->uiid;
-	/*
-	 * try to find a label with the same uiid
-	 * but if it doesn't exist, return any other
-	 * that is defined within the same scope
-	 */
-	for (l = labtab; l; l = l->nxt)
-	{	if (strcmp(s->name, l->s->name) == 0
-		&&  s->context == l->s->context)
-		{	anymatch = l;
-			if (cur_uiid == l->uiid) /* best match */
-			{	return l;
-	}	}	}
-
-	return anymatch; /* likely to be 0 */
-}
-
-Element *
-get_lab(Lextok *n, int md)
-{	Label *l = get_labspec(n);
-
-	if (l != (Label *) 0)
-	{	return (l->e);
-	}
-
-	if (md)
-	{	lineno = n->ln;
-		Fname  = n->fn;
-		fatal("undefined label %s", n->sym->name);
-	}
-
-	return ZE;
-}
-
-Symbol *
-has_lab(Element *e, int special)
-{	Label *l;
-
-	for (l = labtab; l; l = l->nxt)
-	{	if (e != l->e)
-			continue;
-		if (special == 0
-		||  ((special&1) && !strncmp(l->s->name, "accept", 6))
-		||  ((special&2) && !strncmp(l->s->name, "end", 3))
-		||  ((special&4) && !strncmp(l->s->name, "progress", 8)))
-			return (l->s);
-	}
-	return ZS;
-}
-
-static void
-mov_lab(Symbol *z, Element *e, Element *y)
-{	Label *l;
-
-	for (l = labtab; l; l = l->nxt)
-		if (e == l->e)
-		{	l->e = y;
-			return;
-		}
-	if (e->n)
-	{	lineno = e->n->ln;
-		Fname  = e->n->fn;
-	}
-	fatal("cannot happen - mov_lab %s", z->name);
-}
-
-void
-fix_dest(Symbol *c, Symbol *a)		/* c:label name, a:proctype name */
-{	Label *l; extern Symbol *context;
-
-#if 0
-	printf("ref to label '%s' in proctype '%s', search:\n",
-		c->name, a->name);
-	for (l = labtab; l; l = l->nxt)
-		printf("	%s in	%s\n", l->s->name, l->c->name);
-#endif
-
-	for (l = labtab; l; l = l->nxt)
-	{	if (strcmp(c->name, l->s->name) == 0
-		&&  strcmp(a->name, l->c->name) == 0)	/* ? */
-			break;
-	}
-	if (!l)
-	{	printf("spin: label '%s' (proctype %s)\n", c->name, a->name);
-		non_fatal("unknown label '%s'", c->name);
-		if (context == a)
-		printf("spin: cannot remote ref a label inside the same proctype\n");
-		return;
-	}
-	if (!l->e || !l->e->n)
-		fatal("fix_dest error (%s)", c->name);
-	if (l->e->n->ntyp == GOTO)
-	{	Element	*y = (Element *) emalloc(sizeof(Element));
-		int	keep_ln = l->e->n->ln;
-		Symbol	*keep_fn = l->e->n->fn;
-
-		/* insert skip - or target is optimized away */
-		y->n = l->e->n;		  /* copy of the goto   */
-		y->seqno = find_maxel(a); /* unique seqno within proc */
-		y->nxt = l->e->nxt;
-		y->Seqno = Unique++; y->Nxt = Al_El; Al_El = y;
-
-		/* turn the original element+seqno into a skip */
-		l->e->n = nn(ZN, 'c', nn(ZN, CONST, ZN, ZN), ZN);
-		l->e->n->ln = l->e->n->lft->ln = keep_ln;
-		l->e->n->fn = l->e->n->lft->fn = keep_fn;
-		l->e->n->lft->val = 1;
-		l->e->nxt = y;		/* append the goto  */
-	}
-	l->e->status |= CHECK2;	/* treat as if global */
-	if (l->e->status & (ATOM | L_ATOM | D_ATOM))
-	{	non_fatal("cannot reference label inside atomic or d_step (%s)",
-			c->name);
-	}
-}
-
-int
-find_lab(Symbol *s, Symbol *c, int markit)
-{	Label *l;
-
-	for (l = labtab; l; l = l->nxt)
-	{	if (strcmp(s->name, l->s->name) == 0
-		&&  strcmp(c->name, l->c->name) == 0)
-		{	l->visible |= markit;
-			return (l->e->seqno);
-	}	}
-	return 0;
-}
-
-void
-pushbreak(void)
-{	Lbreak *r = (Lbreak *) emalloc(sizeof(Lbreak));
-	Symbol *l;
-	char buf[64];
-
-	sprintf(buf, ":b%d", break_id++);
-	l = lookup(buf);
-	r->l = l;
-	r->nxt = breakstack;
-	breakstack = r;
-}
-
-Symbol *
-break_dest(void)
-{
-	if (!breakstack)
-		fatal("misplaced break statement", (char *)0);
-	return breakstack->l;
-}
-
-void
-make_atomic(Sequence *s, int added)
-{	Element *f;
-
-	walk_atomic(s->frst, s->last, added);
-
-	f = s->last;
-	switch (f->n->ntyp) {	/* is last step basic stmnt or sequence ? */
-	case NON_ATOMIC:
-	case ATOMIC:
-		/* redo and search for the last step of that sequence */
-		make_atomic(f->n->sl->this, added);
-		break;
-
-	case UNLESS:
-		/* escapes are folded into main sequence */
-		make_atomic(f->sub->this, added);
-		break;
-
-	default:
-		f->status &= ~ATOM;
-		f->status |= L_ATOM;
-		break;
-	}
-}
-
-#if 0
-static int depth = 0;
-void dump_sym(Symbol *, char *);
-
-void
-dump_lex(Lextok *t, char *s)
-{	int i;
-
-	depth++;
-	printf(s);
-	for (i = 0; i < depth; i++)
-		printf("\t");
-	explain(t->ntyp);
-	if (t->ntyp == NAME) printf(" %s ", t->sym->name);
-	if (t->ntyp == CONST) printf(" %d ", t->val);
-	if (t->ntyp == STRUCT)
-	{	dump_sym(t->sym, "\n:Z:");
-	}
-	if (t->lft)
-	{	dump_lex(t->lft, "\nL");
-	}
-	if (t->rgt)
-	{	dump_lex(t->rgt, "\nR");
-	}
-	depth--;
-}
-void
-dump_sym(Symbol *z, char *s)
-{	int i;
-	char txt[64];
-	depth++;
-	printf(s);
-	for (i = 0; i < depth; i++)
-		printf("\t");
-
-	if (z->type == CHAN)
-	{	if (z->ini && z->ini->rgt && z->ini->rgt->sym)
-		{	// dump_sym(z->ini->rgt->sym, "\n:I:"); /* could also be longer list */
-			if (z->ini->rgt->rgt
-			|| !z->ini->rgt->sym)
-			fatal("chan %s in for should have only one field (a typedef)", z->name);
-			printf(" -- %s %p -- ", z->ini->rgt->sym->name, z->ini->rgt->sym);
-		}
-	} else if (z->type == STRUCT)
-	{	if (z->Snm)
-			printf(" == %s %p == ", z->Snm->name, z->Snm);
-		else
-		{	if (z->Slst)
-				dump_lex(z->Slst, "\n:X:");
-			if (z->ini)
-				dump_lex(z->ini, "\n:I:");
-		}
-	}
-	depth--;
-
-}
-#endif
-
-int
-match_struct(Symbol *s, Symbol *t)
-{
-	if (!t
-	||  !t->ini
-	||  !t->ini->rgt
-	||  !t->ini->rgt->sym
-	||   t->ini->rgt->rgt)
-	{	fatal("chan %s in for should have only one field (a typedef)", t->name);
-	}
-	/* we already know that s is a STRUCT */
-	if (0)
-	{	printf("index type %s %p ==\n", s->Snm->name, s->Snm);
-		printf("chan type  %s %p --\n\n", t->ini->rgt->sym->name, t->ini->rgt->sym);
-	}
-
-	return (s->Snm == t->ini->rgt->sym);
-}
-
-void
-valid_name(Lextok *a3, Lextok *a5, Lextok *a8, char *tp)
-{
-	if (a3->ntyp != NAME)
-	{	fatal("%s ( .name : from .. to ) { ... }", tp);
-	}
-	if (a3->sym->type == CHAN
-	||  a3->sym->type == STRUCT
-	||  a3->sym->isarray != 0)
-	{	fatal("bad index in for-construct %s", a3->sym->name);
-	}
-	if (a5->ntyp == CONST && a8->ntyp == CONST && a5->val > a8->val)
-	{	non_fatal("start value for %s exceeds end-value", a3->sym->name);
-	}
-}
-
-void
-for_setup(Lextok *a3, Lextok *a5, Lextok *a8)
-{	/* for ( a3 : a5 .. a8 ) */
-
-	valid_name(a3, a5, a8, "for");
-	/* a5->ntyp = a8->ntyp = CONST; */
-	add_seq(nn(a3, ASGN, a3, a5));	/* start value */
-	open_seq(0);
-	add_seq(nn(ZN, 'c', nn(a3, LE, a3, a8), ZN));	/* condition */
-}
-
-Lextok *
-for_index(Lextok *a3, Lextok *a5)
-{	Lextok *z0, *z1, *z2, *z3;
-	Symbol *tmp_cnt;
-	char tmp_nm[MAXSCOPESZ];
-	/* for ( a3 in a5 ) { ... } */
-
-	if (a3->ntyp != NAME)
-	{	fatal("for ( .name in name ) { ... }", (char *) 0);
-	}
-
-	if (a5->ntyp != NAME)
-	{	fatal("for ( %s in .name ) { ... }", a3->sym->name);
-	}
-
-	if (a3->sym->type == STRUCT)
-	{	if (a5->sym->type != CHAN)
-		{	fatal("for ( %s in .channel_name ) { ... }",
-				a3->sym->name);
-		}
-		z0 = a5->sym->ini;
-		if (!z0
-		|| z0->val <= 0
-		|| z0->rgt->ntyp != STRUCT
-		|| z0->rgt->rgt != NULL)
-		{	fatal("bad channel type %s in for", a5->sym->name);
-		}
-
-		if (!match_struct(a3->sym, a5->sym))
-		{	fatal("type of %s does not match chan", a3->sym->name);
-		}
-
-		z1 = nn(ZN, CONST, ZN, ZN); z1->val = 0;
-		z2 = nn(a5, LEN, a5, ZN);
-
-		sprintf(tmp_nm, "_f0r_t3mp%s", CurScope); /* make sure it's unique */
-		tmp_cnt = lookup(tmp_nm);
-		if (z0->val > 255)			/* check nr of slots, i.e. max length */
-		{	tmp_cnt->type = SHORT;	/* should be rare */
-		} else
-		{	tmp_cnt->type = BYTE;
-		}
-		z3 = nn(ZN, NAME, ZN, ZN);
-		z3->sym = tmp_cnt;
-
-		add_seq(nn(z3, ASGN, z3, z1));	/* start value 0 */
-
-		open_seq(0);
-
-		add_seq(nn(ZN, 'c', nn(z3, LT, z3, z2), ZN));	/* condition */
-
-		/* retrieve  message from the right slot -- for now: rotate contents */
-		in_for = 0;
-		add_seq(nn(a5, 'r', a5, expand(a3, 1)));	/* receive */
-		add_seq(nn(a5, 's', a5, expand(a3, 1)));	/* put back in to rotate */
-		in_for = 1;
-		return z3;
-	} else
-	{	if (a5->sym->isarray == 0
-		||  a5->sym->nel <= 0)
-		{	fatal("bad arrayname %s", a5->sym->name);
-		}
-		z1 = nn(ZN, CONST, ZN, ZN); z1->val = 0;
-		z2 = nn(ZN, CONST, ZN, ZN); z2->val = a5->sym->nel - 1;
-		for_setup(a3, z1, z2);
-		return a3;
-	}
-}
-
-Lextok *
-for_body(Lextok *a3, int with_else)
-{	Lextok *t1, *t2, *t0, *rv;
-
-	rv = nn(ZN, CONST, ZN, ZN); rv->val = 1;
-	rv = nn(ZN,  '+', a3, rv);
-	rv = nn(a3, ASGN, a3, rv);
-	add_seq(rv);	/* initial increment */
-
-	pushbreak();
-
-	/* completed loop body, main sequence */
-	t1 = nn(ZN, 0, ZN, ZN);
-	t1->sq = close_seq(8);
-
-	open_seq(0);		/* add else -> break sequence */
-	if (with_else)
-	{	add_seq(nn(ZN, ELSE, ZN, ZN));
-	}
-	t2 = nn(ZN, GOTO, ZN, ZN);
-	t2->sym = break_dest();
-	add_seq(t2);
-	t2 = nn(ZN, 0, ZN, ZN);
-	t2->sq = close_seq(9);
-
-	t0 = nn(ZN, 0, ZN, ZN);
-	t0->sl = seqlist(t2->sq, seqlist(t1->sq, 0));
-
-	rv = nn(ZN, DO, ZN, ZN);
-	rv->sl = t0->sl;
-	return rv;
-}
-
-Lextok *
-sel_index(Lextok *a3, Lextok *a5, Lextok *a7)
-{	/* select ( a3 : a5 .. a7 ) */
-
-	valid_name(a3, a5, a7, "select");
-	/* a5->ntyp = a7->ntyp = CONST; */
-
-	add_seq(nn(a3, ASGN, a3, a5));	/* start value */
-	open_seq(0);
-	add_seq(nn(ZN, 'c', nn(a3, LT, a3, a7), ZN));	/* condition */
-
-	return for_body(a3, 0);	/* no else, just a non-deterministic break */
-}
-
-static void
-walk_atomic(Element *a, Element *b, int added)
-{	Element *f; Symbol *ofn; int oln;
-	SeqList *h;
-
-	ofn = Fname;
-	oln = lineno;
-	for (f = a; ; f = f->nxt)
-	{	f->status |= (ATOM|added);
-		switch (f->n->ntyp) {
-		case ATOMIC:
-			if (verbose&32)
-			  printf("spin: warning, %s:%d, atomic inside %s (ignored)\n",
-			  f->n->fn->name, f->n->ln, (added)?"d_step":"atomic");
-			goto mknonat;
-		case D_STEP:
-			if (!(verbose&32))
-			{	if (added) goto mknonat;
-				break;
-			}
-			printf("spin: warning, %s:%d, d_step inside ",
-			 f->n->fn->name, f->n->ln);
-			if (added)
-			{	printf("d_step (ignored)\n");
-				goto mknonat;
-			}
-			printf("atomic\n");
-			break;
-		case NON_ATOMIC:
-mknonat:		f->n->ntyp = NON_ATOMIC; /* can jump here */
-			h = f->n->sl;
-			walk_atomic(h->this->frst, h->this->last, added);
-			break;
-		case UNLESS:
-			if (added)
-			{ printf("spin: error, %s:%d, unless in d_step (ignored)\n",
-			 	 f->n->fn->name, f->n->ln);
-			}
-		}
-		for (h = f->sub; h; h = h->nxt)
-			walk_atomic(h->this->frst, h->this->last, added);
-		if (f == b)
-			break;
-	}
-	Fname = ofn;
-	lineno = oln;
-}
-
-void
-dumplabels(void)
-{	Label *l;
-
-	for (l = labtab; l; l = l->nxt)
-		if (l->c != 0 && l->s->name[0] != ':')
-		{	printf("label	%s	%d	",
-				l->s->name, l->e->seqno);
-			if (l->uiid == 0)
-				printf("<%s>\n", l->c->name);
-			else
-				printf("<%s i%d>\n", l->c->name, l->uiid);
-		}
-}

+ 0 - 351
sys/src/cmd/spin/guided.c

@@ -1,351 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-/***** spin: guided.c *****/
-
-/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
-/* All Rights Reserved.  This software is for educational purposes only.  */
-/* No guarantee whatsoever is expressed or implied by the distribution of */
-/* this code.  Permission is given to distribute this code provided that  */
-/* this introductory message is not removed and no monies are exchanged.  */
-/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
-/*             http://spinroot.com/                                       */
-/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
-
-#include "spin.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "y.tab.h"
-
-extern RunList	*run, *X;
-extern Element	*Al_El;
-extern Symbol	*Fname, *oFname;
-extern int	verbose, lineno, xspin, jumpsteps, depth, merger, cutoff;
-extern int	nproc, nstop, Tval, ntrail, columns;
-extern int16_t	Have_claim, Skip_claim;
-extern void ana_src(int, int);
-extern char	**trailfilename;
-
-int	TstOnly = 0, pno;
-
-static int	lastclaim = -1;
-static FILE	*fd;
-static void	lost_trail(void);
-
-static void
-whichproc(int p)
-{	RunList *oX;
-
-	for (oX = run; oX; oX = oX->nxt)
-		if (oX->pid == p)
-		{	printf("(%s) ", oX->n->name);
-			break;
-		}
-}
-
-static int
-newer(char *f1, char *f2)
-{
-#if defined(WIN32) || defined(WIN64)
-	struct _stat x, y;
-#else
-	struct stat x, y;
-#endif
-
-	if (stat(f1, (struct stat *)&x) < 0) return 0;
-	if (stat(f2, (struct stat *)&y) < 0) return 1;
-	if (x.st_mtime < y.st_mtime) return 0;
-
-	return 1;
-}
-
-void
-hookup(void)
-{	Element *e;
-
-	for (e = Al_El; e; e = e->Nxt)
-		if (e->n
-		&& (e->n->ntyp == ATOMIC
-		||  e->n->ntyp == NON_ATOMIC
-		||  e->n->ntyp == D_STEP))
-			(void) huntstart(e);
-}
-
-int
-not_claim(void)
-{
-	return (!Have_claim || !X || X->pid != 0);
-}
-
-void
-match_trail(void)
-{	int i, a, nst;
-	Element *dothis;
-	char snap[512], *q;
-
-	/*
-	 * if source model name is leader.pml
-	 * look for the trail file under these names:
-	 *	leader.pml.trail
-	 *	leader.pml.tra
-	 *	leader.trail
-	 *	leader.tra
-	 */
-
-	if (trailfilename)
-	{	if (strlen(*trailfilename) < sizeof(snap))
-		{	strcpy(snap, (const char *) *trailfilename);
-		} else
-		{	fatal("filename %s too long", *trailfilename);
-		}
-	} else
-	{	if (ntrail)
-			sprintf(snap, "%s%d.trail", oFname->name, ntrail);
-		else
-			sprintf(snap, "%s.trail", oFname->name);
-	}
-
-	if ((fd = fopen(snap, "r")) == NULL)
-	{	snap[strlen(snap)-2] = '\0';	/* .tra */
-		if ((fd = fopen(snap, "r")) == NULL)
-		{	if ((q = strchr(oFname->name, '.')) != NULL)
-			{	*q = '\0';
-				if (ntrail)
-					sprintf(snap, "%s%d.trail",
-						oFname->name, ntrail);
-				else
-					sprintf(snap, "%s.trail",
-						oFname->name);
-				*q = '.';
-
-				if ((fd = fopen(snap, "r")) != NULL)
-					goto okay;
-
-				snap[strlen(snap)-2] = '\0';	/* last try */
-				if ((fd = fopen(snap, "r")) != NULL)
-					goto okay;
-			}
-			printf("spin: cannot find trail file\n");
-			alldone(1);
-	}	}
-okay:
-	if (xspin == 0 && newer(oFname->name, snap))
-	printf("spin: warning, \"%s\" is newer than %s\n",
-		oFname->name, snap);
-
-	Tval = 1;
-
-	/*
-	 * sets Tval because timeouts may be part of trail
-	 * this used to also set m_loss to 1, but that is
-	 * better handled with the runtime -m flag
-	 */
-
-	hookup();
-
-	while (fscanf(fd, "%d:%d:%d\n", &depth, &pno, &nst) == 3)
-	{	if (depth == -2) { start_claim(pno); continue; }
-		if (depth == -4) { merger = 1; ana_src(0, 1); continue; }
-		if (depth == -1)
-		{	if (verbose)
-			{	if (columns == 2)
-				dotag(stdout, " CYCLE>\n");
-				else
-				dotag(stdout, "<<<<<START OF CYCLE>>>>>\n");
-			}
-			continue;
-		}
-
-		if (cutoff > 0 && depth >= cutoff)
-		{	printf("-------------\n");
-			printf("depth-limit (-u%d steps) reached\n", cutoff);
-			break;
-		}
-
-		if (Skip_claim && pno == 0) continue;
-
-		for (dothis = Al_El; dothis; dothis = dothis->Nxt)
-		{	if (dothis->Seqno == nst)
-				break;
-		}
-		if (!dothis)
-		{	printf("%3d: proc %d, no matching stmnt %d\n",
-				depth, pno - Have_claim, nst);
-			lost_trail();
-		}
-
-		i = nproc - nstop + Skip_claim;
-
-		if (dothis->n->ntyp == '@')
-		{	if (pno == i-1)
-			{	run = run->nxt;
-				nstop++;
-				if (verbose&4)
-				{	if (columns == 2)
-					{	dotag(stdout, "<end>\n");
-						continue;
-					}
-					if (Have_claim && pno == 0)
-					printf("%3d: claim terminates\n",
-						depth);
-					else
-					printf("%3d: proc %d terminates\n",
-						depth, pno - Have_claim);
-				}
-				continue;
-			}
-			if (pno <= 1) continue;	/* init dies before never */
-			printf("%3d: stop error, ", depth);
-			printf("proc %d (i=%d) trans %d, %c\n",
-				pno - Have_claim, i, nst, dothis->n->ntyp);
-			lost_trail();
-		}
-
-		if (!xspin && (verbose&32))
-		{	printf("i=%d pno %d\n", i, pno);
-		}
-
-		for (X = run; X; X = X->nxt)
-		{	if (--i == pno)
-				break;
-		}
-
-		if (!X)
-		{	if (verbose&32)
-			{	printf("%3d: no process %d (step %d)\n", depth, pno - Have_claim, nst);
-				printf(" max %d (%d - %d + %d) claim %d",
-					nproc - nstop + Skip_claim,
-					nproc, nstop, Skip_claim, Have_claim);
-				printf("active processes:\n");
-				for (X = run; X; X = X->nxt)
-				{	printf("\tpid %d\tproctype %s\n", X->pid, X->n->name);
-				}
-				printf("\n");
-				continue;
-			} else
-			{	printf("%3d:\tproc  %d (?) ", depth, pno);
-				lost_trail();
-			}
-		} else
-		{	X->pc  = dothis;
-		}
-
-		lineno = dothis->n->ln;
-		Fname  = dothis->n->fn;
-
-		if (dothis->n->ntyp == D_STEP)
-		{	Element *g, *og = dothis;
-			do {
-				g = eval_sub(og);
-				if (g && depth >= jumpsteps
-				&& ((verbose&32) || ((verbose&4) && not_claim())))
-				{	if (columns != 2)
-					{	p_talk(og, 1);
-
-						if (og->n->ntyp == D_STEP)
-						og = og->n->sl->this->frst;
-
-						printf("\t[");
-						comment(stdout, og->n, 0);
-						printf("]\n");
-					}
-					if (verbose&1) dumpglobals();
-					if (verbose&2) dumplocal(X);
-					if (xspin) printf("\n");
-				}
-				og = g;
-			} while (g && g != dothis->nxt);
-			if (X != NULL)
-			{	X->pc = g?huntele(g, 0, -1):g;
-			}
-		} else
-		{
-keepgoing:		if (dothis->merge_start)
-				a = dothis->merge_start;
-			else
-				a = dothis->merge;
-
-			if (X != NULL)
-			{	X->pc = eval_sub(dothis);
-				if (X->pc) X->pc = huntele(X->pc, 0, a);
-			}
-
-			if (depth >= jumpsteps
-			&& ((verbose&32) || ((verbose&4) && not_claim())))	/* -v or -p */
-			{	if (columns != 2)
-				{	p_talk(dothis, 1);
-
-					if (dothis->n->ntyp == D_STEP)
-					dothis = dothis->n->sl->this->frst;
-
-					printf("\t[");
-					comment(stdout, dothis->n, 0);
-					printf("]");
-					if (a && (verbose&32))
-					printf("\t<merge %d now @%d>",
-						dothis->merge,
-						(X && X->pc)?X->pc->seqno:-1);
-					printf("\n");
-				}
-				if (verbose&1) dumpglobals();
-				if (verbose&2) dumplocal(X);
-				if (xspin) printf("\n");
-
-				if (X && !X->pc)
-				{	X->pc = dothis;
-					printf("\ttransition failed\n");
-					a = 0;	/* avoid inf loop */
-				}
-			}
-			if (a && X && X->pc && X->pc->seqno != a)
-			{	dothis = X->pc;
-				goto keepgoing;
-		}	}
-
-		if (Have_claim && X && X->pid == 0
-		&&  dothis->n
-		&&  lastclaim != dothis->n->ln)
-		{	lastclaim = dothis->n->ln;
-			if (columns == 2)
-			{	char t[128];
-				sprintf(t, "#%d", lastclaim);
-				pstext(0, t);
-			} else
-			{
-				printf("Never claim moves to line %d\t[", lastclaim);
-				comment(stdout, dothis->n, 0);
-				printf("]\n");
-	}	}	}
-	printf("spin: trail ends after %d steps\n", depth);
-	wrapup(0);
-}
-
-static void
-lost_trail(void)
-{	int d, p, n, l;
-
-	while (fscanf(fd, "%d:%d:%d:%d\n", &d, &p, &n, &l) == 4)
-	{	printf("step %d: proc  %d ", d, p); whichproc(p);
-		printf("(state %d) - d %d\n", n, l);
-	}
-	wrapup(1);	/* no return */
-}
-
-int
-pc_value(Lextok *n)
-{	int i = nproc - nstop;
-	int pid = eval(n);
-	RunList *Y;
-
-	for (Y = run; Y; Y = Y->nxt)
-	{	if (--i == pid)
-			return Y->pc->seqno;
-	}
-	return 0;
-}

+ 0 - 868
sys/src/cmd/spin/main.c

@@ -1,868 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-/***** spin: main.c *****/
-
-/* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories.     */
-/* All Rights Reserved.  This software is for educational purposes only.  */
-/* No guarantee whatsoever is expressed or implied by the distribution of */
-/* this code.  Permission is given to distribute this code provided that  */
-/* this introductory message is not removed and no monies are exchanged.  */
-/* Software written by Gerard J. Holzmann.  For tool documentation see:   */
-/*             http://spinroot.com/                                       */
-/* Send all bug-reports and/or questions to: bugs@spinroot.com            */
-
-#include <stdlib.h>
-#include "spin.h"
-#include "version.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <signal.h>
-/* #include <malloc.h> */
-#include <time.h>
-#ifdef PC
-#include <io.h>
-extern int unlink(const char *);
-#else
-#include <unistd.h>
-#endif
-#include "y.tab.h"
-
-extern int	DstepStart, lineno, tl_terse;
-extern FILE	*yyin, *yyout, *tl_out;
-extern Symbol	*context;
-extern char	*claimproc;
-extern void	repro_src(void);
-extern void	qhide(int);
-extern char	CurScope[MAXSCOPESZ];
-
-Symbol	*Fname, *oFname;
-
-int	Etimeouts;	/* nr timeouts in program */
-int	Ntimeouts;	/* nr timeouts in never claim */
-int	analyze, columns, dumptab, has_remote, has_remvar;
-int	interactive, jumpsteps, m_loss, nr_errs, cutoff;
-int	s_trail, ntrail, verbose, xspin, notabs, rvopt;
-int	no_print, no_wrapup, Caccess, limited_vis, like_java;
-int	separate;	/* separate compilation */
-int	export_ast;	/* pangen5.c */
-int	old_scope_rules;	/* use pre 5.3.0 rules */
-int	split_decl = 1, product, Strict;
-
-int	merger = 1, deadvar = 1;
-int	ccache = 0; /* oyvind teig: 5.2.0 case caching off by default */
-
-static int preprocessonly, SeedUsed;
-static int seedy;	/* be verbose about chosen seed */
-static int inlineonly;	/* show inlined code */
-static int dataflow = 1;
-
-#if 0
-meaning of flags on verbose:
-	1	-g global variable values
-	2	-l local variable values
-	4	-p all process actions
-	8	-r receives
-	16	-s sends
-	32	-v verbose
-	64	-w very verbose
-#endif
-
-static char	Operator[] = "operator: ";
-static char	Keyword[]  = "keyword: ";
-static char	Function[] = "function-name: ";
-static char	**add_ltl  = (char **) 0;
-static char	**ltl_file = (char **) 0;
-static char	**nvr_file = (char **) 0;
-static char	*ltl_claims = (char *) 0;
-static FILE	*fd_ltl = (FILE *) 0;
-static char	*PreArg[64];
-static int	PreCnt = 0;
-static char	out1[64];
-
-char	**trailfilename;	/* new option 'k' */
-
-void	explain(int);
-
-	/* to use visual C++:
-		#define CPP	"CL -E/E"
-	   or call spin as:	"spin -PCL  -E/E"
-
-	   on OS2:
-		#define CPP	"icc -E/Pd+ -E/Q+"
-	   or call spin as:	"spin -Picc -E/Pd+ -E/Q+"
-	*/
-#ifndef CPP
-	#if defined(PC) || defined(MAC)
-		#define CPP	"gcc -E -x c"	/* most systems have gcc or cpp */
-		/* if gcc-4 is available, this setting is modified below */
-	#else
-		#ifdef SOLARIS
-			#define CPP	"/usr/ccs/lib/cpp"
-		#else
-			#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
-				#define CPP	"cpp"
-			#else
-				#define CPP	"/bin/cpp"	/* classic Unix systems */
-			#endif
-		#endif
-	#endif
-#endif
-
-static char	*PreProc = CPP;
-extern int	depth; /* at least some steps were made */
-
-void
-alldone(int estatus)
-{
-	if (preprocessonly == 0
-	&&  strlen(out1) > 0)
-		(void) unlink((const char *)out1);
-
-	if (seedy && !analyze && !export_ast
-	&& !s_trail && !preprocessonly && depth > 0)
-		printf("seed used: %d\n", SeedUsed);
-
-	if (xspin && (analyze || s_trail))
-	{	if (estatus)
-			printf("spin: %d error(s) - aborting\n",
-			estatus);
-		else
-			printf("Exit-Status 0\n");
-	}
-	exit(estatus);
-}
-
-void
-preprocess(char *a, char *b, int a_tmp)
-{	char precmd[1024], cmd[2048]; int i;
-#if defined(WIN32) || defined(WIN64)
-	struct _stat x;
-/*	struct stat x;	*/
-#endif
-#ifdef PC
-	extern int try_zpp(char *, char *);
-	if (PreCnt == 0 && try_zpp(a, b))
-	{	goto out;
-	}
-#endif
-#if defined(WIN32) || defined(WIN64)
-	if (strncmp(PreProc, "gcc -E -x c", strlen("gcc -E -x c")) == 0)
-	{	if (stat("/bin/gcc-4.exe", (struct stat *)&x) == 0	/* for PCs with cygwin */
-		||  stat("c:/cygwin/bin/gcc-4.exe", (struct stat *)&x) == 0)
-		{	PreProc = "gcc-4 -E -x c";
-		} else if (stat("/bin/gcc-3.exe", (struct stat *)&x) == 0
-		       ||  stat("c:/cygwin/bin/gcc-3.exe", (struct stat *)&x) == 0)
-		{	PreProc = "gcc-3 -E -x c";
-	}	}
-#endif
-	strcpy(precmd, PreProc);
-	for (i = 1; i <= PreCnt; i++)
-	{	strcat(precmd, " ");
-		strcat(precmd, PreArg[i]);
-	}
-	if (strlen(precmd) > sizeof(precmd))
-	{	fprintf(stdout, "spin: too many -D args, aborting\n");
-		alldone(1);
-	}
-	sprintf(cmd, "%s %s > %s", precmd, a, b);
-	if (system((const char *)cmd))
-	{	(void) unlink((const char *) b);
-		if (a_tmp) (void) unlink((const char *) a);
-		fprintf(stdout, "spin: preprocessing failed\n");	/* 4.1.2 was stderr */
-		alldone(1); /* no return, error exit */
-	}
-#ifdef PC
-out:
-#endif
-	if (a_tmp) (void) unlink((const char *) a);
-}
-
-void
-usage(void)
-{
-	printf("use: spin [-option] ... [-option] file\n");
-	printf("\tNote: file must always be the last argument\n");
-	printf("\t-A apply slicing algorithm\n");
-	printf("\t-a generate a verifier in pan.c\n");
-	printf("\t-B no final state details in simulations\n");
-	printf("\t-b don't execute printfs in simulation\n");
-	printf("\t-C print channel access info (combine with -g etc.)\n");
-	printf("\t-c columnated -s -r simulation output\n");
-	printf("\t-d produce symbol-table information\n");
-	printf("\t-Dyyy pass -Dyyy to the preprocessor\n");
-	printf("\t-Eyyy pass yyy to the preprocessor\n");
-	printf("\t-e compute synchronous product of multiple never claims (modified by -L)\n");
-	printf("\t-f \"..formula..\"  translate LTL ");
-	printf("into never claim\n");
-	printf("\t-F file  like -f, but with the LTL formula stored in a 1-line file\n");
-	printf("\t-g print all global variables\n");
-	printf("\t-h at end of run, print value of seed for random nr generator used\n");
-	printf("\t-i interactive (random simulation)\n");
-	printf("\t-I show result of inlining and preprocessing\n");
-	printf("\t-J reverse eval order of nested unlesses\n");
-	printf("\t-jN skip the first N steps ");
-	printf("in simulation trail\n");
-	printf("\t-k fname use the trailfile stored in file fname, see also -t\n");
-	printf("\t-L when using -e, use strict language intersection\n");
-	printf("\t-l print all local variables\n");
-	printf("\t-M print msc-flow in Postscript\n");
-	printf("\t-m lose msgs sent to full queues\n");
-	printf("\t-N fname use never claim stored in file fname\n");
-	printf("\t-nN seed for random nr generator\n");
-	printf("\t-O use old scope rules (pre 5.3.0)\n");
-	printf("\t-o1 turn off dataflow-optimizations in verifier\n");
-	printf("\t-o2 don't hide write-only variables in verifier\n");
-	printf("\t-o3 turn off statement merging in verifier\n");
-	printf("\t-o4 turn on rendezvous optiomizations in verifier\n");
-	printf("\t-o5 turn on case caching (reduces size of pan.m, but affects reachability reports)\n");
-	printf("\t-Pxxx use xxx for preprocessing\n");
-	printf("\t-p print all statements\n");
-	printf("\t-qN suppress io for queue N in printouts\n");
-	printf("\t-r print receive events\n");
-	printf("\t-S1 and -S2 separate pan source for claim and model\n");
-	printf("\t-s print send events\n");
-	printf("\t-T do not indent printf output\n");
-	printf("\t-t[N] follow [Nth] simulation trail, see also -k\n");
-	printf("\t-Uyyy pass -Uyyy to the preprocessor\n");
-	printf("\t-uN stop a simulation run after N steps\n");
-	printf("\t-v verbose, more warnings\n");
-	printf("\t-w very verbose (when combined with -l or -g)\n");
-	printf("\t-[XYZ] reserved for use by xspin interface\n");
-	printf("\t-V print version number and exit\n");
-	alldone(1);
-}
-
-void
-optimizations(int nr)
-{
-	switch (nr) {
-	case '1':
-		dataflow = 1 - dataflow; /* dataflow */
-		if (verbose&32)
-		printf("spin: dataflow optimizations turned %s\n",
-			dataflow?"on":"off");
-		break;
-	case '2':
-		/* dead variable elimination */
-		deadvar = 1 - deadvar;
-		if (verbose&32)
-		printf("spin: dead variable elimination turned %s\n",
-			deadvar?"on":"off");
-		break;
-	case '3':
-		/* statement merging */
-		merger = 1 - merger;
-		if (verbose&32)
-		printf("spin: statement merging turned %s\n",
-			merger?"on":"off");
-		break;
-
-	case '4':
-		/* rv optimization */
-		rvopt = 1 - rvopt;
-		if (verbose&32)
-		printf("spin: rendezvous optimization turned %s\n",
-			rvopt?"on":"off");
-		break;
-	case '5':
-		/* case caching */
-		ccache = 1 - ccache;
-		if (verbose&32)
-		printf("spin: case caching turned %s\n",
-			ccache?"on":"off");
-		break;
-	default:
-		printf("spin: bad or missing parameter on -o\n");
-		usage();
-		break;
-	}
-}
-
-int
-main(int argc, char *argv[])
-{	Symbol *s;
-	int T = (int) time((time_t *)0);
-	int usedopts = 0;
-	extern void ana_src(int, int);
-
-	yyin  = stdin;
-	yyout = stdout;
-	tl_out = stdout;
-	strcpy(CurScope, "_");
-
-	/* unused flags: y, z, G, L, Q, R, W */
-	while (argc > 1 && argv[1][0] == '-')
-	{	switch (argv[1][1]) {
-		/* generate code for separate compilation: S1 or S2 */
-		case 'S': separate = atoi(&argv[1][2]);
-			  /* fall through */
-		case 'a': analyze  = 1; break;
-		case 'A': export_ast = 1; break;
-		case 'B': no_wrapup = 1; break;
-		case 'b': no_print = 1; break;
-		case 'C': Caccess = 1; break;
-		case 'c': columns = 1; break;
-		case 'D': PreArg[++PreCnt] = (char *) &argv[1][0];
-			  break;	/* define */
-		case 'd': dumptab =  1; break;
-		case 'E': PreArg[++PreCnt] = (char *) &argv[1][2];
-			  break;
-		case 'e': product++; break; /* see also 'L' */
-		case 'F': ltl_file = (char **) (argv+2);
-			  argc--; argv++; break;
-		case 'f': add_ltl = (char **) argv;
-			  argc--; argv++; break;
-		case 'g': verbose +=  1; break;
-		case 'h': seedy = 1; break;
-		case 'i': interactive = 1; break;
-		case 'I': inlineonly = 1; break;
-		case 'J': like_java = 1; break;
-		case 'j': jumpsteps = atoi(&argv[1][2]); break;
-		case 'k': s_trail = 1;
-			  trailfilename = (char **) (argv+2);
-			  argc--; argv++; break;
-		case 'L': Strict++; break; /* modified -e */
-		case 'l': verbose +=  2; break;
-		case 'M': columns = 2; break;
-		case 'm': m_loss   =  1; break;
-		case 'N': nvr_file = (char **) (argv+2);
-			  argc--; argv++; break;
-		case 'n': T = atoi(&argv[1][2]); tl_terse = 1; break;
-		case 'O': old_scope_rules = 1; break;
-		case 'o': optimizations(argv[1][2]);
-			  usedopts = 1; break;
-		case 'P': PreProc = (char *) &argv[1][2]; break;
-		case 'p': verbose +=  4; break;
-		case 'q': if (isdigit((int) argv[1][2]))
-				qhide(atoi(&argv[1][2]));
-			  break;
-		case 'r': verbose +=  8; break;
-		case 's': verbose += 16; break;
-		case 'T': notabs = 1; break;
-		case 't': s_trail  =  1;
-			  if (isdigit((int)argv[1][2]))
-				ntrail = atoi(&argv[1][2]);
-			  break;
-		case 'U': PreArg[++PreCnt] = (char *) &argv[1][0];
-			  break;	/* undefine */
-		case 'u': cutoff = atoi(&argv[1][2]); break;	/* new 3.4.14 */
-		case 'v': verbose += 32; break;
-		case 'V': printf("%s\n", SpinVersion);
-			  alldone(0);
-			  break;
-		case 'w': verbose += 64; break;
-#if 0
-		case 'x': split_decl = 0; break;	/* experimental */
-#endif
-		case 'X': xspin = notabs = 1;
-#ifndef PC
-			  signal(SIGPIPE, alldone); /* not posix... */
-#endif
-			  break;
-		case 'Y': limited_vis = 1; break;	/* used by xspin */
-		case 'Z': preprocessonly = 1; break;	/* used by xspin */
-
-		default : usage(); break;
-		}
-		argc--; argv++;
-	}
-
-	if (usedopts && !analyze)
-		printf("spin: warning -o[123] option ignored in simulations\n");
-
-	if (ltl_file)
-	{	char formula[4096];
-		add_ltl = ltl_file-2; add_ltl[1][1] = 'f';
-		if (!(tl_out = fopen(*ltl_file, "r")))
-		{	printf("spin: cannot open %s\n", *ltl_file);
-			alldone(1);
-		}
-		if (!fgets(formula, 4096, tl_out))
-		{	printf("spin: cannot read %s\n", *ltl_file);
-		}
-		fclose(tl_out);
-		tl_out = stdout;
-		*ltl_file = (char *) formula;
-	}
-	if (argc > 1)
-	{	FILE *fd = stdout;
-		char cmd[512], out2[512];
-
-		/* must remain in current dir */
-		strcpy(out1, "pan.pre");
-
-		if (add_ltl || nvr_file)
-		{	sprintf(out2, "%s.nvr", argv[1]);
-			if ((fd = fopen(out2, MFLAGS)) == NULL)
-			{	printf("spin: cannot create tmp file %s\n",
-					out2);
-				alldone(1);
-			}
-			fprintf(fd, "#include \"%s\"\n", argv[1]);
-		}
-
-		if (add_ltl)
-		{	tl_out = fd;
-			nr_errs = tl_main(2, add_ltl);
-			fclose(fd);
-			preprocess(out2, out1, 1);
-		} else if (nvr_file)
-		{	fprintf(fd, "#include \"%s\"\n", *nvr_file);
-			fclose(fd);
-			preprocess(out2, out1, 1);
-		} else
-		{	preprocess(argv[1], out1, 0);
-		}
-
-		if (preprocessonly)
-			alldone(0);
-
-		if (!(yyin = fopen(out1, "r")))
-		{	printf("spin: cannot open %s\n", out1);
-			alldone(1);
-		}
-
-		if (strncmp(argv[1], "progress", (size_t) 8) == 0
-		||  strncmp(argv[1], "accept", (size_t) 6) == 0)
-			sprintf(cmd, "_%s", argv[1]);
-		else
-			strcpy(cmd, argv[1]);
-		oFname = Fname = lookup(cmd);
-		if (oFname->name[0] == '\"')
-		{	int i = (int) strlen(oFname->name);
-			oFname->name[i-1] = '\0';
-			oFname = lookup(&oFname->name[1]);
-		}
-	} else
-	{	oFname = Fname = lookup("<stdin>");
-		if (add_ltl)
-		{	if (argc > 0)
-				exit(tl_main(2, add_ltl));
-			printf("spin: missing argument to -f\n");
-			alldone(1);
-		}
-		printf("%s\n", SpinVersion);
-		fprintf(stderr, "spin: error, no filename specified");
-		fflush(stdout);
-		alldone(1);
-	}
-	if (columns == 2)
-	{	extern void putprelude(void);
-		if (xspin || verbose&(1|4|8|16|32))
-		{	printf("spin: -c precludes all flags except -t\n");
-			alldone(1);
-		}
-		putprelude();
-	}
-	if (columns && !(verbose&8) && !(verbose&16))
-		verbose += (8+16);
-	if (columns == 2 && limited_vis)
-		verbose += (1+4);
-	Srand((unsigned int) T);	/* defined in run.c */
-	SeedUsed = T;
-	s = lookup("_");	s->type = PREDEF; /* write-only global var */
-	s = lookup("_p");	s->type = PREDEF;
-	s = lookup("_pid");	s->type = PREDEF;
-	s = lookup("_last");	s->type = PREDEF;
-	s = lookup("_nr_pr");	s->type = PREDEF; /* new 3.3.10 */
-
-	yyparse();
-	fclose(yyin);
-
-	if (ltl_claims)
-	{	Symbol *r;
-		fclose(fd_ltl);
-		if (!(yyin = fopen(ltl_claims, "r")))
-		{	fatal("cannot open %s", ltl_claims);
-		}
-		r = oFname;
-		oFname = Fname = lookup(ltl_claims);
-		lineno = 0;
-		yyparse();
-		fclose(yyin);
-		oFname = Fname = r;
-		if (0)
-		{	(void) unlink(ltl_claims);
-	}	}
-
-	loose_ends();
-
-	if (inlineonly)
-	{	repro_src();
-		return 0;
-	}
-
-	chanaccess();
-	if (!Caccess)
-	{	if (!s_trail && (dataflow || merger))
-			ana_src(dataflow, merger);
-		sched();
-		alldone(nr_errs);
-	}
-	return 0;
-}
-
-void
-ltl_list(char *nm, char *fm)
-{
-	if (analyze || dumptab)	/* when generating pan.c only */
-	{	if (!ltl_claims)
-		{	ltl_claims = "_spin_nvr.tmp";
-			if ((fd_ltl = fopen(ltl_claims, MFLAGS)) == NULL)
-			{	fatal("cannot open tmp file %s", ltl_claims);
-			}
-			tl_out = fd_ltl;
-		}
-
-		add_ltl = (char **) emalloc(5 * sizeof(char *));
-		add_ltl[1] = "-c";
-		add_ltl[2] = nm;
-		add_ltl[3] = "-f";
-		add_ltl[4] = (char *) emalloc(strlen(fm)+4);
-		strcpy(add_ltl[4], "!(");
-		strcat(add_ltl[4], fm);
-		strcat(add_ltl[4], ")");
-		/* add_ltl[4] = fm; */
-
-		nr_errs += tl_main(4, add_ltl);
-
-		fflush(tl_out);
-		/* should read this file after the main file is read */
-	}
-}
-
-int
-yywrap(void)	/* dummy routine */
-{
-	return 1;
-}
-
-void
-non_fatal(char *s1, char *s2)
-{	extern char yytext[];
-
-	printf("spin: %s:%d, Error: ",
-		oFname?oFname->name:"nofilename", lineno);
-	if (s2)
-		printf(s1, s2);
-	else
-		printf(s1);
-	if (strlen(yytext)>1)
-		printf(" near '%s'", yytext);
-	printf("\n");
-	nr_errs++;
-}
-
-void
-fatal(char *s1, char *s2)
-{
-	non_fatal(s1, s2);
-	(void) unlink("pan.b");
-	(void) unlink("pan.c");
-	(void) unlink("pan.h");
-	(void) unlink("pan.m");
-	(void) unlink("pan.t");
-	(void) unlink("pan.pre");
-	alldone(1);
-}
-
-char *
-emalloc(size_t n)
-{	char *tmp;
-	static unsigned long cnt = 0;
-
-	if (n == 0)
-		return NULL;	/* robert shelton 10/20/06 */
-
-	if (!(tmp = (char *) malloc(n)))
-	{	printf("spin: allocated %ld Gb, wanted %d bytes more\n",
-			cnt/(1024*1024*1024), (int) n);
-		fatal("not enough memory", (char *)0);
-	}
-	cnt += (unsigned long) n;
-	memset(tmp, 0, n);
-	return tmp;
-}
-
-void
-trapwonly(Lextok *n /* , char *unused */)
-{	extern int realread;
-	int16_t i = (n->sym)?n->sym->type:0;
-
-	if (i != MTYPE
-	&&  i != BIT
-	&&  i != BYTE
-	&&  i != SHORT
-	&&  i != INT
-	&&  i != UNSIGNED)
-		return;
-
-	if (realread)
-	n->sym->hidden |= 128;	/* var is read at least once */
-}
-
-void
-setaccess(Symbol *sp, Symbol *what, int cnt, int t)
-{	Access *a;
-
-	for (a = sp->access; a; a = a->lnk)
-		if (a->who == context
-		&&  a->what == what
-		&&  a->cnt == cnt
-		&&  a->typ == t)
-			return;
-
-	a = (Access *) emalloc(sizeof(Access));
-	a->who = context;
-	a->what = what;
-	a->cnt = cnt;
-	a->typ = t;
-	a->lnk = sp->access;
-	sp->access = a;
-}
-
-Lextok *
-nn(Lextok *s, int t, Lextok *ll, Lextok *rl)
-{	Lextok *n = (Lextok *) emalloc(sizeof(Lextok));
-	static int warn_nn = 0;
-
-	n->uiid = is_inline();	/* record origin of the statement */
-	n->ntyp = (int16_t) t;
-	if (s && s->fn)
-	{	n->ln = s->ln;
-		n->fn = s->fn;
-	} else if (rl && rl->fn)
-	{	n->ln = rl->ln;
-		n->fn = rl->fn;
-	} else if (ll && ll->fn)
-	{	n->ln = ll->ln;
-		n->fn = ll->fn;
-	} else
-	{	n->ln = lineno;
-		n->fn = Fname;
-	}
-	if (s) n->sym  = s->sym;
-	n->lft  = ll;
-	n->rgt  = rl;
-	n->indstep = DstepStart;
-
-	if (t == TIMEOUT) Etimeouts++;
-
-	if (!context) return n;
-
-	if (t == 'r' || t == 's')
-		setaccess(n->sym, ZS, 0, t);
-	if (t == 'R')
-		setaccess(n->sym, ZS, 0, 'P');
-
-	if (context->name == claimproc)
-	{	int forbidden = separate;
-		switch (t) {
-		case ASGN:
-			printf("spin: Warning, never claim has side-effect\n");
-			break;
-		case 'r': case 's':
-			non_fatal("never claim contains i/o stmnts",(char *)0);
-			break;
-		case TIMEOUT:
-			/* never claim polls timeout */
-			if (Ntimeouts && Etimeouts)
-				forbidden = 0;
-			Ntimeouts++; Etimeouts--;
-			break;
-		case LEN: case EMPTY: case FULL:
-		case 'R': case NFULL: case NEMPTY:
-			/* status becomes non-exclusive */
-			if (n->sym && !(n->sym->xu&XX))
-			{	n->sym->xu |= XX;
-				if (separate == 2) {
-				printf("spin: warning, make sure that the S1 model\n");
-				printf("      also polls channel '%s' in its claim\n",
-				n->sym->name);
-			}	}
-			forbidden = 0;
-			break;
-		case 'c':
-			AST_track(n, 0);	/* register as a slice criterion */
-			/* fall thru */
-		default:
-			forbidden = 0;
-			break;
-		}
-		if (forbidden)
-		{	printf("spin: never, saw "); explain(t); printf("\n");
-			fatal("incompatible with separate compilation",(char *)0);
-		}
-	} else if ((t == ENABLED || t == PC_VAL) && !(warn_nn&t))
-	{	printf("spin: Warning, using %s outside never claim\n",
-			(t == ENABLED)?"enabled()":"pc_value()");
-		warn_nn |= t;
-	} else if (t == NONPROGRESS)
-	{	fatal("spin: Error, using np_ outside never claim\n",
-		       (char *)0);
-	}
-	return n;
-}
-
-Lextok *
-rem_lab(Symbol *a, Lextok *b, Symbol *c)	/* proctype name, pid, label name */
-{	Lextok *tmp1, *tmp2, *tmp3;
-
-	has_remote++;
-	c->type = LABEL;	/* refered to in global context here */
-	fix_dest(c, a);		/* in case target of rem_lab is jump */
-	tmp1 = nn(ZN, '?',   b, ZN); tmp1->sym = a;
-	tmp1 = nn(ZN, 'p', tmp1, ZN);
-	tmp1->sym = lookup("_p");
-	tmp2 = nn(ZN, NAME,  ZN, ZN); tmp2->sym = a;
-	tmp3 = nn(ZN, 'q', tmp2, ZN); tmp3->sym = c;
-	return nn(ZN, EQ, tmp1, tmp3);
-#if 0
-	      .---------------EQ-------.
-	     /                          \
-	   'p' -sym-> _p               'q' -sym-> c (label name)
-	   /                           /
-	 '?' -sym-> a (proctype)     NAME -sym-> a (proctype name)
-	 /
-	b (pid expr)
-#endif
-}
-
-Lextok *
-rem_var(Symbol *a, Lextok *b, Symbol *c, Lextok *ndx)
-{	Lextok *tmp1;
-
-	has_remote++;
-	has_remvar++;