structs.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  1. /***** spin: structs.c *****/
  2. /* Copyright (c) 1989-2003 by Lucent Technologies, Bell Laboratories. */
  3. /* All Rights Reserved. This software is for educational purposes only. */
  4. /* No guarantee whatsoever is expressed or implied by the distribution of */
  5. /* this code. Permission is given to distribute this code provided that */
  6. /* this introductory message is not removed and no monies are exchanged. */
  7. /* Software written by Gerard J. Holzmann. For tool documentation see: */
  8. /* http://spinroot.com/ */
  9. /* Send all bug-reports and/or questions to: bugs@spinroot.com */
  10. #include "spin.h"
  11. #include "y.tab.h"
  12. typedef struct UType {
  13. Symbol *nm; /* name of the type */
  14. Lextok *cn; /* contents */
  15. struct UType *nxt; /* linked list */
  16. } UType;
  17. extern Symbol *Fname;
  18. extern int lineno, depth, Expand_Ok, has_hidden, in_for;
  19. Symbol *owner;
  20. static UType *Unames = 0;
  21. static UType *Pnames = 0;
  22. static Lextok *cpnn(Lextok *, int, int, int);
  23. extern void sr_mesg(FILE *, int, int);
  24. void
  25. setuname(Lextok *n)
  26. { UType *tmp;
  27. if (!owner)
  28. fatal("illegal reference inside typedef", (char *) 0);
  29. for (tmp = Unames; tmp; tmp = tmp->nxt)
  30. if (!strcmp(owner->name, tmp->nm->name))
  31. { non_fatal("typename %s was defined before",
  32. tmp->nm->name);
  33. return;
  34. }
  35. tmp = (UType *) emalloc(sizeof(UType));
  36. tmp->nm = owner;
  37. tmp->cn = n;
  38. tmp->nxt = Unames;
  39. Unames = tmp;
  40. }
  41. static void
  42. putUname(FILE *fd, UType *tmp)
  43. { Lextok *fp, *tl;
  44. if (!tmp) return;
  45. putUname(fd, tmp->nxt); /* postorder */
  46. fprintf(fd, "struct %s { /* user defined type */\n",
  47. tmp->nm->name);
  48. for (fp = tmp->cn; fp; fp = fp->rgt)
  49. for (tl = fp->lft; tl; tl = tl->rgt)
  50. typ2c(tl->sym);
  51. fprintf(fd, "};\n");
  52. }
  53. void
  54. putunames(FILE *fd)
  55. {
  56. putUname(fd, Unames);
  57. }
  58. int
  59. isutype(char *t)
  60. { UType *tmp;
  61. for (tmp = Unames; tmp; tmp = tmp->nxt)
  62. { if (!strcmp(t, tmp->nm->name))
  63. return 1;
  64. }
  65. return 0;
  66. }
  67. Lextok *
  68. getuname(Symbol *t)
  69. { UType *tmp;
  70. for (tmp = Unames; tmp; tmp = tmp->nxt)
  71. { if (!strcmp(t->name, tmp->nm->name))
  72. return tmp->cn;
  73. }
  74. fatal("%s is not a typename", t->name);
  75. return (Lextok *)0;
  76. }
  77. void
  78. setutype(Lextok *p, Symbol *t, Lextok *vis) /* user-defined types */
  79. { int oln = lineno;
  80. Symbol *ofn = Fname;
  81. Lextok *m, *n;
  82. m = getuname(t);
  83. for (n = p; n; n = n->rgt)
  84. { lineno = n->ln;
  85. Fname = n->fn;
  86. if (n->sym->type)
  87. fatal("redeclaration of '%s'", n->sym->name);
  88. if (n->sym->nbits > 0)
  89. non_fatal("(%s) only an unsigned can have width-field",
  90. n->sym->name);
  91. if (Expand_Ok)
  92. n->sym->hidden |= (4|8|16); /* formal par */
  93. if (vis)
  94. { if (strncmp(vis->sym->name, ":hide:", (size_t) 6) == 0)
  95. { n->sym->hidden |= 1;
  96. has_hidden++;
  97. } else if (strncmp(vis->sym->name, ":show:", (size_t) 6) == 0)
  98. n->sym->hidden |= 2;
  99. else if (strncmp(vis->sym->name, ":local:", (size_t) 7) == 0)
  100. n->sym->hidden |= 64;
  101. }
  102. n->sym->type = STRUCT; /* classification */
  103. n->sym->Slst = m; /* structure itself */
  104. n->sym->Snm = t; /* name of typedef */
  105. n->sym->Nid = 0; /* this is no chan */
  106. n->sym->hidden |= 4;
  107. if (n->sym->nel <= 0)
  108. non_fatal("bad array size for '%s'", n->sym->name);
  109. }
  110. lineno = oln;
  111. Fname = ofn;
  112. }
  113. static Symbol *
  114. do_same(Lextok *n, Symbol *v, int xinit)
  115. { Lextok *tmp, *fp, *tl;
  116. int ix = eval(n->lft);
  117. int oln = lineno;
  118. Symbol *ofn = Fname;
  119. lineno = n->ln;
  120. Fname = n->fn;
  121. /* n->sym->type == STRUCT
  122. * index: n->lft
  123. * subfields: n->rgt
  124. * structure template: n->sym->Slst
  125. * runtime values: n->sym->Sval
  126. */
  127. if (xinit) ini_struct(v); /* once, at top level */
  128. if (ix >= v->nel || ix < 0)
  129. { printf("spin: indexing %s[%d] - size is %d\n",
  130. v->name, ix, v->nel);
  131. fatal("indexing error \'%s\'", v->name);
  132. }
  133. if (!n->rgt || !n->rgt->lft)
  134. { non_fatal("no subfields %s", v->name); /* i.e., wants all */
  135. lineno = oln; Fname = ofn;
  136. return ZS;
  137. }
  138. if (n->rgt->ntyp != '.')
  139. { printf("bad subfield type %d\n", n->rgt->ntyp);
  140. alldone(1);
  141. }
  142. tmp = n->rgt->lft;
  143. if (tmp->ntyp != NAME && tmp->ntyp != TYPE)
  144. { printf("bad subfield entry %d\n", tmp->ntyp);
  145. alldone(1);
  146. }
  147. for (fp = v->Sval[ix]; fp; fp = fp->rgt)
  148. for (tl = fp->lft; tl; tl = tl->rgt)
  149. if (!strcmp(tl->sym->name, tmp->sym->name))
  150. { lineno = oln; Fname = ofn;
  151. return tl->sym;
  152. }
  153. fatal("cannot locate subfield %s", tmp->sym->name);
  154. return ZS;
  155. }
  156. int
  157. Rval_struct(Lextok *n, Symbol *v, int xinit) /* n varref, v valref */
  158. { Symbol *tl;
  159. Lextok *tmp;
  160. int ix;
  161. if (!n || !(tl = do_same(n, v, xinit)))
  162. return 0;
  163. tmp = n->rgt->lft;
  164. if (tmp->sym->type == STRUCT)
  165. { return Rval_struct(tmp, tl, 0);
  166. } else if (tmp->rgt)
  167. fatal("non-zero 'rgt' on non-structure", 0);
  168. ix = eval(tmp->lft);
  169. /* printf("%d: ix: %d (%d) %d\n", depth, ix, tl->nel, tl->val[ix]); */
  170. if (ix >= tl->nel || ix < 0)
  171. fatal("indexing error \'%s\'", tl->name);
  172. return cast_val(tl->type, tl->val[ix], tl->nbits);
  173. }
  174. int
  175. Lval_struct(Lextok *n, Symbol *v, int xinit, int a) /* a = assigned value */
  176. { Symbol *tl;
  177. Lextok *tmp;
  178. int ix;
  179. if (!(tl = do_same(n, v, xinit)))
  180. return 1;
  181. tmp = n->rgt->lft;
  182. if (tmp->sym->type == STRUCT)
  183. return Lval_struct(tmp, tl, 0, a);
  184. else if (tmp->rgt)
  185. fatal("non-zero 'rgt' on non-structure", 0);
  186. ix = eval(tmp->lft);
  187. if (ix >= tl->nel || ix < 0)
  188. fatal("indexing error \'%s\'", tl->name);
  189. if (tl->nbits > 0)
  190. a = (a & ((1<<tl->nbits)-1));
  191. if (a != tl->val[ix])
  192. { tl->val[ix] = a;
  193. tl->setat = depth;
  194. }
  195. return 1;
  196. }
  197. int
  198. Cnt_flds(Lextok *m)
  199. { Lextok *fp, *tl, *n;
  200. int cnt = 0;
  201. if (m->ntyp == ',')
  202. { n = m;
  203. goto is_lst;
  204. }
  205. if (!m->sym || m->ntyp != STRUCT)
  206. return 1;
  207. n = getuname(m->sym);
  208. is_lst:
  209. for (fp = n; fp; fp = fp->rgt)
  210. for (tl = fp->lft; tl; tl = tl->rgt)
  211. { if (tl->sym->type == STRUCT)
  212. { if (tl->sym->nel > 1 || tl->sym->isarray)
  213. fatal("array of structures in param list, %s",
  214. tl->sym->name);
  215. cnt += Cnt_flds(tl->sym->Slst);
  216. } else
  217. cnt += tl->sym->nel;
  218. }
  219. return cnt;
  220. }
  221. int
  222. Sym_typ(Lextok *t)
  223. { Symbol *s = t->sym;
  224. if (!s) return 0;
  225. if (s->type != STRUCT)
  226. return s->type;
  227. if (!t->rgt
  228. || t->rgt->ntyp != '.' /* gh: had ! in wrong place */
  229. || !t->rgt->lft)
  230. return STRUCT; /* not a field reference */
  231. return Sym_typ(t->rgt->lft);
  232. }
  233. int
  234. Width_set(int *wdth, int i, Lextok *n)
  235. { Lextok *fp, *tl;
  236. int j = i, k;
  237. for (fp = n; fp; fp = fp->rgt)
  238. for (tl = fp->lft; tl; tl = tl->rgt)
  239. { if (tl->sym->type == STRUCT)
  240. j = Width_set(wdth, j, tl->sym->Slst);
  241. else
  242. { for (k = 0; k < tl->sym->nel; k++, j++)
  243. wdth[j] = tl->sym->type;
  244. } }
  245. return j;
  246. }
  247. void
  248. ini_struct(Symbol *s)
  249. { int i; Lextok *fp, *tl;
  250. if (s->type != STRUCT) /* last step */
  251. { (void) checkvar(s, 0);
  252. return;
  253. }
  254. if (s->Sval == (Lextok **) 0)
  255. { s->Sval = (Lextok **) emalloc(s->nel * sizeof(Lextok *));
  256. for (i = 0; i < s->nel; i++)
  257. { s->Sval[i] = cpnn(s->Slst, 1, 1, 1);
  258. for (fp = s->Sval[i]; fp; fp = fp->rgt)
  259. for (tl = fp->lft; tl; tl = tl->rgt)
  260. ini_struct(tl->sym);
  261. } }
  262. }
  263. static Lextok *
  264. cpnn(Lextok *s, int L, int R, int S)
  265. { Lextok *d; extern int Nid;
  266. if (!s) return ZN;
  267. d = (Lextok *) emalloc(sizeof(Lextok));
  268. d->uiid = s->uiid;
  269. d->ntyp = s->ntyp;
  270. d->val = s->val;
  271. d->ln = s->ln;
  272. d->fn = s->fn;
  273. d->sym = s->sym;
  274. if (L) d->lft = cpnn(s->lft, 1, 1, S);
  275. if (R) d->rgt = cpnn(s->rgt, 1, 1, S);
  276. if (S && s->sym)
  277. { d->sym = (Symbol *) emalloc(sizeof(Symbol));
  278. memcpy(d->sym, s->sym, sizeof(Symbol));
  279. if (d->sym->type == CHAN)
  280. d->sym->Nid = ++Nid;
  281. }
  282. if (s->sq || s->sl)
  283. fatal("cannot happen cpnn", (char *) 0);
  284. return d;
  285. }
  286. int
  287. full_name(FILE *fd, Lextok *n, Symbol *v, int xinit)
  288. { Symbol *tl;
  289. Lextok *tmp;
  290. int hiddenarrays = 0;
  291. fprintf(fd, "%s", v->name);
  292. if (!n || !(tl = do_same(n, v, xinit)))
  293. return 0;
  294. tmp = n->rgt->lft;
  295. if (tmp->sym->type == STRUCT)
  296. { fprintf(fd, ".");
  297. hiddenarrays = full_name(fd, tmp, tl, 0);
  298. goto out;
  299. }
  300. fprintf(fd, ".%s", tl->name);
  301. out: if (tmp->sym->nel > 1 || tmp->sym->isarray == 1)
  302. { fprintf(fd, "[%d]", eval(tmp->lft));
  303. hiddenarrays = 1;
  304. }
  305. return hiddenarrays;
  306. }
  307. void
  308. validref(Lextok *p, Lextok *c)
  309. { Lextok *fp, *tl;
  310. char lbuf[512];
  311. for (fp = p->sym->Slst; fp; fp = fp->rgt)
  312. for (tl = fp->lft; tl; tl = tl->rgt)
  313. if (strcmp(tl->sym->name, c->sym->name) == 0)
  314. return;
  315. sprintf(lbuf, "no field '%s' defined in structure '%s'\n",
  316. c->sym->name, p->sym->name);
  317. non_fatal(lbuf, (char *) 0);
  318. }
  319. void
  320. struct_name(Lextok *n, Symbol *v, int xinit, char *buf)
  321. { Symbol *tl;
  322. Lextok *tmp;
  323. char lbuf[512];
  324. if (!n || !(tl = do_same(n, v, xinit)))
  325. return;
  326. tmp = n->rgt->lft;
  327. if (tmp->sym->type == STRUCT)
  328. { strcat(buf, ".");
  329. struct_name(tmp, tl, 0, buf);
  330. return;
  331. }
  332. sprintf(lbuf, ".%s", tl->name);
  333. strcat(buf, lbuf);
  334. if (tmp->sym->nel > 1 || tmp->sym->isarray == 1)
  335. { sprintf(lbuf, "[%d]", eval(tmp->lft));
  336. strcat(buf, lbuf);
  337. }
  338. }
  339. void
  340. walk2_struct(char *s, Symbol *z)
  341. { Lextok *fp, *tl;
  342. char eprefix[128];
  343. int ix;
  344. extern void Done_case(char *, Symbol *);
  345. ini_struct(z);
  346. if (z->nel == 1 && z->isarray == 0)
  347. sprintf(eprefix, "%s%s.", s, z->name);
  348. for (ix = 0; ix < z->nel; ix++)
  349. { if (z->nel > 1 || z->isarray == 1)
  350. sprintf(eprefix, "%s%s[%d].", s, z->name, ix);
  351. for (fp = z->Sval[ix]; fp; fp = fp->rgt)
  352. for (tl = fp->lft; tl; tl = tl->rgt)
  353. { if (tl->sym->type == STRUCT)
  354. walk2_struct(eprefix, tl->sym);
  355. else if (tl->sym->type == CHAN)
  356. Done_case(eprefix, tl->sym);
  357. } }
  358. }
  359. void
  360. walk_struct(FILE *ofd, int dowhat, char *s, Symbol *z, char *a, char *b, char *c)
  361. { Lextok *fp, *tl;
  362. char eprefix[128];
  363. int ix;
  364. ini_struct(z);
  365. if (z->nel == 1 && z->isarray == 0)
  366. sprintf(eprefix, "%s%s.", s, z->name);
  367. for (ix = 0; ix < z->nel; ix++)
  368. { if (z->nel > 1 || z->isarray == 1)
  369. sprintf(eprefix, "%s%s[%d].", s, z->name, ix);
  370. for (fp = z->Sval[ix]; fp; fp = fp->rgt)
  371. for (tl = fp->lft; tl; tl = tl->rgt)
  372. { if (tl->sym->type == STRUCT)
  373. walk_struct(ofd, dowhat, eprefix, tl->sym, a,b,c);
  374. else
  375. do_var(ofd, dowhat, eprefix, tl->sym, a,b,c);
  376. } }
  377. }
  378. void
  379. c_struct(FILE *fd, char *ipref, Symbol *z)
  380. { Lextok *fp, *tl;
  381. char pref[256], eprefix[300];
  382. int ix;
  383. ini_struct(z);
  384. for (ix = 0; ix < z->nel; ix++)
  385. for (fp = z->Sval[ix]; fp; fp = fp->rgt)
  386. for (tl = fp->lft; tl; tl = tl->rgt)
  387. { strcpy(eprefix, ipref);
  388. if (z->nel > 1 || z->isarray == 1)
  389. { /* insert index before last '.' */
  390. eprefix[strlen(eprefix)-1] = '\0';
  391. sprintf(pref, "[ %d ].", ix);
  392. strcat(eprefix, pref);
  393. }
  394. if (tl->sym->type == STRUCT)
  395. { strcat(eprefix, tl->sym->name);
  396. strcat(eprefix, ".");
  397. c_struct(fd, eprefix, tl->sym);
  398. } else
  399. c_var(fd, eprefix, tl->sym);
  400. }
  401. }
  402. void
  403. dump_struct(Symbol *z, char *prefix, RunList *r)
  404. { Lextok *fp, *tl;
  405. char eprefix[256];
  406. int ix, jx;
  407. ini_struct(z);
  408. for (ix = 0; ix < z->nel; ix++)
  409. { if (z->nel > 1 || z->isarray == 1)
  410. sprintf(eprefix, "%s[%d]", prefix, ix);
  411. else
  412. strcpy(eprefix, prefix);
  413. for (fp = z->Sval[ix]; fp; fp = fp->rgt)
  414. for (tl = fp->lft; tl; tl = tl->rgt)
  415. { if (tl->sym->type == STRUCT)
  416. { char pref[300];
  417. strcpy(pref, eprefix);
  418. strcat(pref, ".");
  419. strcat(pref, tl->sym->name);
  420. dump_struct(tl->sym, pref, r);
  421. } else
  422. for (jx = 0; jx < tl->sym->nel; jx++)
  423. { if (tl->sym->type == CHAN)
  424. doq(tl->sym, jx, r);
  425. else
  426. { printf("\t\t");
  427. if (r)
  428. printf("%s(%d):", r->n->name, r->pid);
  429. printf("%s.%s", eprefix, tl->sym->name);
  430. if (tl->sym->nel > 1 || tl->sym->isarray == 1)
  431. printf("[%d]", jx);
  432. printf(" = ");
  433. sr_mesg(stdout, tl->sym->val[jx],
  434. tl->sym->type == MTYPE);
  435. printf("\n");
  436. } } }
  437. }
  438. }
  439. static int
  440. retrieve(Lextok **targ, int i, int want, Lextok *n, int Ntyp)
  441. { Lextok *fp, *tl;
  442. int j = i, k;
  443. for (fp = n; fp; fp = fp->rgt)
  444. for (tl = fp->lft; tl; tl = tl->rgt)
  445. { if (tl->sym->type == STRUCT)
  446. { j = retrieve(targ, j, want, tl->sym->Slst, Ntyp);
  447. if (j < 0)
  448. { Lextok *x = cpnn(tl, 1, 0, 0);
  449. x->rgt = nn(ZN, '.', (*targ), ZN);
  450. (*targ) = x;
  451. return -1;
  452. }
  453. } else
  454. { for (k = 0; k < tl->sym->nel; k++, j++)
  455. { if (j == want)
  456. { *targ = cpnn(tl, 1, 0, 0);
  457. (*targ)->lft = nn(ZN, CONST, ZN, ZN);
  458. (*targ)->lft->val = k;
  459. if (Ntyp)
  460. (*targ)->ntyp = (short) Ntyp;
  461. return -1;
  462. }
  463. } } }
  464. return j;
  465. }
  466. static int
  467. is_explicit(Lextok *n)
  468. {
  469. if (!n) return 0;
  470. if (!n->sym) fatal("unexpected - no symbol", 0);
  471. if (n->sym->type != STRUCT) return 1;
  472. if (!n->rgt) return 0;
  473. if (n->rgt->ntyp != '.')
  474. { lineno = n->ln;
  475. Fname = n->fn;
  476. printf("ntyp %d\n", n->rgt->ntyp);
  477. fatal("unexpected %s, no '.'", n->sym->name);
  478. }
  479. return is_explicit(n->rgt->lft);
  480. }
  481. Lextok *
  482. expand(Lextok *n, int Ok)
  483. /* turn rgt-lnked list of struct nms, into ',' list of flds */
  484. { Lextok *x = ZN, *y;
  485. if (!Ok) return n;
  486. while (n)
  487. { y = mk_explicit(n, 1, 0);
  488. if (x)
  489. (void) tail_add(x, y);
  490. else
  491. x = y;
  492. n = n->rgt;
  493. }
  494. return x;
  495. }
  496. Lextok *
  497. mk_explicit(Lextok *n, int Ok, int Ntyp)
  498. /* produce a single ',' list of fields */
  499. { Lextok *bld = ZN, *x;
  500. int i, cnt; extern int IArgs;
  501. if (n->sym->type != STRUCT
  502. || in_for
  503. || is_explicit(n))
  504. return n;
  505. if (n->rgt
  506. && n->rgt->ntyp == '.'
  507. && n->rgt->lft
  508. && n->rgt->lft->sym
  509. && n->rgt->lft->sym->type == STRUCT)
  510. { Lextok *y;
  511. bld = mk_explicit(n->rgt->lft, Ok, Ntyp);
  512. for (x = bld; x; x = x->rgt)
  513. { y = cpnn(n, 1, 0, 0);
  514. y->rgt = nn(ZN, '.', x->lft, ZN);
  515. x->lft = y;
  516. }
  517. return bld;
  518. }
  519. if (!Ok || !n->sym->Slst)
  520. { if (IArgs) return n;
  521. printf("spin: saw '");
  522. comment(stdout, n, 0);
  523. printf("'\n");
  524. fatal("incomplete structure ref '%s'", n->sym->name);
  525. }
  526. cnt = Cnt_flds(n->sym->Slst);
  527. for (i = cnt-1; i >= 0; i--)
  528. { bld = nn(ZN, ',', ZN, bld);
  529. if (retrieve(&(bld->lft), 0, i, n->sym->Slst, Ntyp) >= 0)
  530. { printf("cannot retrieve field %d\n", i);
  531. fatal("bad structure %s", n->sym->name);
  532. }
  533. x = cpnn(n, 1, 0, 0);
  534. x->rgt = nn(ZN, '.', bld->lft, ZN);
  535. bld->lft = x;
  536. }
  537. return bld;
  538. }
  539. Lextok *
  540. tail_add(Lextok *a, Lextok *b)
  541. { Lextok *t;
  542. for (t = a; t->rgt; t = t->rgt)
  543. if (t->ntyp != ',')
  544. fatal("unexpected type - tail_add", 0);
  545. t->rgt = b;
  546. return a;
  547. }
  548. void
  549. setpname(Lextok *n)
  550. { UType *tmp;
  551. for (tmp = Pnames; tmp; tmp = tmp->nxt)
  552. if (!strcmp(n->sym->name, tmp->nm->name))
  553. { non_fatal("proctype %s redefined",
  554. n->sym->name);
  555. return;
  556. }
  557. tmp = (UType *) emalloc(sizeof(UType));
  558. tmp->nm = n->sym;
  559. tmp->nxt = Pnames;
  560. Pnames = tmp;
  561. }
  562. int
  563. isproctype(char *t)
  564. { UType *tmp;
  565. for (tmp = Pnames; tmp; tmp = tmp->nxt)
  566. { if (!strcmp(t, tmp->nm->name))
  567. return 1;
  568. }
  569. return 0;
  570. }