Annotation of researchv10dc/cmd/trace/trace5.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include "trace.h"
        !             3: #include "trace.d"
        !             4: 
        !             5:  extern struct QUEUE **head, **tail;
        !             6:  extern int *qsize, nrqs, level, maxreached;
        !             7:  extern double iseen, ireseen, zapper;
        !             8:  extern double tryswiff, noswiff, cannot;
        !             9:  char *Realloc(), *Emalloc(), *Smalloc(), *emalloc();
        !            10: 
        !            11:  struct HTABLE {
        !            12:        struct STATE **index;           /* index [h] [ibound]    */
        !            13:        short ibound;                   /* nr of available slots */
        !            14:        short nr;                       /* nr of occupied  slots */
        !            15:  } oldstates[NOTOOBIG+1];              /* index of hash values  */
        !            16: 
        !            17:  int hbound=0, hlast=0;
        !            18: 
        !            19: growindex(h)
        !            20: { int nsz = (int) oldstates[h].ibound + 8;
        !            21: 
        !            22:        if (nsz == 8)
        !            23:                oldstates[h].index = (struct STATE **)
        !            24:                        Emalloc(nsz * sizeof(struct STATE *));
        !            25:        else
        !            26:                oldstates[h].index = (struct STATE **)
        !            27:                        Realloc(oldstates[h].index, nsz * sizeof(struct STATE *));
        !            28:        
        !            29:        oldstates[h].ibound = (short) nsz;
        !            30: }
        !            31: 
        !            32: initable()
        !            33: {      register int i;
        !            34: 
        !            35:        for (i = 0; i < NOTOOBIG+1; i++)
        !            36:        {       oldstates[i].nr = 0;
        !            37:                oldstates[i].ibound = 0;
        !            38:        }
        !            39:        hbound = NOTOOBIG+1;
        !            40: }
        !            41: 
        !            42: insert(h, pnt)         /* enter state pointer into the table at hash value h */
        !            43:        struct STATE *pnt;
        !            44: { short cin;
        !            45: 
        !            46:        if (h >= hbound)
        !            47:        {       fprintf(stderr, "h %d, hbound %d, NOTOOBIG %d\n",h,hbound,NOTOOBIG);
        !            48:                whoops("cannot happen - insert");
        !            49:        }
        !            50:        cin = oldstates[h].nr++;
        !            51:        iseen += (double) 1;
        !            52: 
        !            53:        if (cin >= oldstates[h].ibound)
        !            54:                growindex(h);
        !            55: 
        !            56:        oldstates[h].index[cin] = pnt;
        !            57: }
        !            58: 
        !            59: mark(stt, vis)
        !            60:        struct STATE *stt;
        !            61:        struct VISIT *vis;
        !            62: {
        !            63:        vis->prop.countme = 0;
        !            64:        vis->depth |= ANALYZED;
        !            65: }
        !            66: 
        !            67: relink(vis)
        !            68:        struct VISIT *vis;
        !            69: { struct CONTS *inqtable();
        !            70:   register int i, j, k;
        !            71: 
        !            72:        for (i = j = k = 0; i < nrqs ; i++)
        !            73:                if (qsize[i] > 0)
        !            74:                {       j++;
        !            75:                        k += (1 << i);
        !            76:                }
        !            77:        vis->howmany = k;
        !            78: 
        !            79:        if (zapper == 0)        /* grow without bound */
        !            80:                vis->c = (struct CONTS **)
        !            81:                        Smalloc(j * sizeof(struct CONTS *));
        !            82:        else
        !            83:                vis->c = (struct CONTS **)
        !            84:                        emalloc(j * sizeof(struct CONTS *));
        !            85: 
        !            86:        for (i = k = 0; i < nrqs; i++)
        !            87:        {       if (qsize[i] == 0)
        !            88:                        continue;
        !            89: 
        !            90:                vis->c[k++] = inqtable(i);
        !            91:        }
        !            92: }
        !            93: 
        !            94: member(h) {    return (h < hbound) ? oldstates[h].nr : 0; }
        !            95: 
        !            96: struct STATE *
        !            97: giveme(h, n)
        !            98: { int m = n - 1;
        !            99:        if (h >= hbound || oldstates[h].nr <= m || oldstates[h].index[m] == NULL)
        !           100:                whoops("cannot happen - giveme");
        !           101: 
        !           102:        return oldstates[h].index[m];
        !           103: }
        !           104: 
        !           105: struct VISIT *
        !           106: findany(avoid)
        !           107:        struct STATE *avoid;
        !           108: { register int i, j;
        !           109:   struct VISIT *try, *pickstate();
        !           110: 
        !           111:        for (i = (hlast+1)%hbound; i != hlast; i++, i %= hbound)
        !           112:        for (j = 0; j < oldstates[i].nr; j++)
        !           113:                if (oldstates[i].index[j] != avoid
        !           114:                &&  (try = pickstate(oldstates[i].index[j])) != NULL)
        !           115:                {       hlast = i;
        !           116:                        return try;
        !           117:                }
        !           118: 
        !           119:        cannot += (double) 1;   /* couldn't find a victim */
        !           120:        try = (struct VISIT *) Smalloc(sizeof(struct VISIT));
        !           121:        try->next = NULL;
        !           122: 
        !           123:        return try;
        !           124: }
        !           125: 
        !           126: struct VISIT *
        !           127: findastate(avoid)
        !           128:        struct STATE *avoid;
        !           129: { struct VISIT *try = NULL;
        !           130:   struct VISIT *findany(), *picknown();
        !           131:   struct Swiffle *unswiffle(), *trs;
        !           132: 
        !           133:        if (ireseen < zapper || zapper == 0)
        !           134:        {       try = (struct VISIT *) Smalloc(sizeof(struct VISIT));
        !           135:                try->next = NULL;
        !           136:                return try;
        !           137:        }
        !           138:        tryswiff += (double) 1;
        !           139:        if ((trs = unswiffle(avoid)) != NULL
        !           140:        && (try = picknown(trs->st, trs->vi)) != NULL)
        !           141:                return try;
        !           142:        noswiff += (double) 1;
        !           143: 
        !           144:        return findany(avoid);
        !           145: }

unix.superglobalmegacorp.com

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