Annotation of researchv10no/cmd/pret/pret9.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include "pret.h"
        !             3: 
        !             4: #define MAXACTUALS     (MANY)
        !             5: 
        !             6:  struct ACTUALS {
        !             7:        int typefs[MAXACTUALS];         /* queue mesg or pvar */
        !             8:        int index [MAXACTUALS];         /* qid,  if mesg      */
        !             9:        struct ACTUALS *nxtcall;
        !            10:        int nractuals;
        !            11:        int whattask;                   /* id of task called  */
        !            12:  };
        !            13: 
        !            14:  struct ACTUALS *calls;                /* procedure call data   */
        !            15:  int nrcalls;                  /* nr of procedure calls */
        !            16: 
        !            17:  extern pid, rid, linenumber;
        !            18: 
        !            19: newcalltable()
        !            20: {      nrcalls = 0;
        !            21:        calls = NULL;
        !            22: }
        !            23: 
        !            24: scrapcalltable()
        !            25: { struct ACTUALS *tmp;
        !            26:   struct ACTUALS *hook = calls;
        !            27:   int i;
        !            28: 
        !            29:        for (i = 0; i < nrcalls; i++)
        !            30:        {       tmp = hook;
        !            31:                hook = hook->nxtcall;
        !            32:                free(tmp);
        !            33:        }
        !            34: }
        !            35: 
        !            36: newcall(ofwhat)
        !            37: { int i, j;
        !            38:   struct ACTUALS *new, *old;
        !            39: 
        !            40:        new = ( struct ACTUALS *)
        !            41:                Emalloc( sizeof(struct ACTUALS) );
        !            42:        new->nractuals = 0;
        !            43:        new->whattask = ofwhat;
        !            44: 
        !            45:        if ((j = nrcalls++) == 0)
        !            46:                calls = new;
        !            47:        else
        !            48:        {       old = calls;
        !            49:                for (i = 1; i < j; i++)
        !            50:                        old = old->nxtcall;
        !            51:                old->nxtcall = new;
        !            52:        }
        !            53:        return nrcalls-1;
        !            54: }
        !            55: 
        !            56: putcalls(tb)
        !            57:        FILE *tb;
        !            58: { struct ACTUALS *hook;
        !            59:   int j, k, a, b;
        !            60:   int maxm = 0;
        !            61:   int maxv = 0;
        !            62: 
        !            63:        fprintf(tb, "FCT_CALLS %d\n",  nrcalls);
        !            64:        for (j = 0, hook = calls; j < nrcalls; j++)
        !            65:        {
        !            66:                for (k = a = b = 0; k < hook->nractuals; k++)
        !            67:                {       if (hook->typefs[k] == ISM)
        !            68:                                a++;
        !            69:                        else if (hook->typefs[k] == ISV)
        !            70:                                b++;
        !            71:                }
        !            72:                if (a > maxm) maxm = a;
        !            73:                if (b > maxv) maxv = b;
        !            74: 
        !            75:                fprintf(tb, "%d-%d/%d:", hook->whattask, a, b);
        !            76:                for (k = 0; k < hook->nractuals; k++)
        !            77:                {       if (hook->typefs[k] != ISQ)
        !            78:                        fprintf(tb, " %d/%d", hook->typefs[k], hook->index[k]);
        !            79:                }
        !            80:                putc('\n', tb);
        !            81:                hook = hook->nxtcall;
        !            82:        }
        !            83:        fprintf(tb, "PARS %d/%d\n",  maxm, maxv);
        !            84: }
        !            85: 
        !            86: callentry(x, val)
        !            87: { int i;
        !            88:   struct ACTUALS *hook = calls;
        !            89: 
        !            90:        for (i = 1; i < nrcalls; i++)
        !            91:                hook = hook->nxtcall;
        !            92: 
        !            93:        if ((i = hook->nractuals++) >= MAXACTUALS)
        !            94:                whoops("too many parameters");
        !            95:        hook->typefs[i] = x;
        !            96:        hook->index[i] = val;
        !            97: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.