Annotation of researchv10no/cmd/trace/trace8.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include "trace.h"
        !             3: #include "trace.d"
        !             4: 
        !             5:  extern int *globvars;
        !             6:  extern int nrprocs, nrrefs, nrvars;
        !             7:  extern struct PROCSTACK **procstack;
        !             8:  extern struct VARPARS *procpars;
        !             9: 
        !            10:  char *Realloc(), *Emalloc(), *Smalloc();
        !            11: 
        !            12:  struct TEMPLATE **templates;
        !            13:  int nrtemplates = 0, tbound = 0;
        !            14: 
        !            15: growttable()
        !            16: { int nsz = tbound + 32;
        !            17: 
        !            18:        if (nsz == 32)
        !            19:                templates = (struct TEMPLATE **)
        !            20:                        Emalloc(nsz * sizeof(struct TEMPLATE *));
        !            21:        else
        !            22:                templates = (struct TEMPLATE **)
        !            23:                        Realloc(templates, nsz * sizeof(struct TEMPLATE *));
        !            24:        
        !            25:        tbound = nsz;
        !            26: 
        !            27: }
        !            28: 
        !            29: struct TEMPLATE *
        !            30: Tinsert()
        !            31: { struct TEMPLATE *try;
        !            32:   register int i;
        !            33: 
        !            34:        if (nrtemplates >= tbound)
        !            35:                growttable();
        !            36: 
        !            37:        try = (struct TEMPLATE *)
        !            38:                Smalloc(sizeof(struct TEMPLATE));
        !            39:        try->l_vars = (struct LOCVARS **)
        !            40:                Smalloc(nrprocs * sizeof(struct LOCVARS *));
        !            41:        try->g_vars = (short *)
        !            42:                Smalloc(nrvars * sizeof(short));
        !            43: 
        !            44:        for (i = 0; i < nrvars; i++)
        !            45:                try->g_vars[i] = (short) globvars[i];
        !            46: 
        !            47:        if (nrrefs > 0)
        !            48:                try->traceback = (struct PROCSTACK **)
        !            49:                        Smalloc(nrprocs * sizeof(struct PROCSTACK *));
        !            50: 
        !            51:        for (i = 0; i < nrprocs; i++)
        !            52:        {       try->l_vars[i] = (struct LOCVARS *)
        !            53:                        Smalloc(sizeof(struct LOCVARS));
        !            54: 
        !            55:                cpylvars(try->l_vars[i], &(procpars[i]));
        !            56: 
        !            57:                if (nrrefs > 0)
        !            58:                {       if (procstack[i] == NULL)
        !            59:                        {       try->traceback[i] = NULL;
        !            60:                                continue;
        !            61:                        }
        !            62:                        try->traceback[i] = (struct PROCSTACK *)
        !            63:                                Smalloc(sizeof(struct PROCSTACK));
        !            64:                        cpystacks(try->traceback[i], procstack[i]);
        !            65:        }       }
        !            66: 
        !            67:        templates[nrtemplates] = try;
        !            68:        nrtemplates++;
        !            69: 
        !            70:        return try;
        !            71: }
        !            72: 
        !            73: struct TEMPLATE *
        !            74: inTtable()
        !            75: { register int i;
        !            76: 
        !            77:        for (i = 0; i < nrtemplates; i++)
        !            78:                if (sametempl(templates[i]))
        !            79:                        return templates[i];
        !            80: 
        !            81:        return Tinsert();
        !            82: }
        !            83: 
        !            84: sametempl(at)
        !            85:        struct TEMPLATE *at;
        !            86: { register int i;
        !            87: 
        !            88:        for (i = 0; i < nrprocs; i++)
        !            89:        {       if (cmplvars(at->l_vars[i], &(procpars[i])) == 0 ||
        !            90:                   (nrrefs > 0 && cmpstacks(at->traceback[i], procstack[i]) == 0))
        !            91:                        return 0;
        !            92:        }
        !            93: 
        !            94:        for (i = 0; i < nrvars; i++)
        !            95:                if (at->g_vars[i] != (short) globvars[i])
        !            96:                        return 0;
        !            97: 
        !            98:        return 1;
        !            99: }

unix.superglobalmegacorp.com

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