Annotation of coherent/d/bin/as/sym.c, revision 1.1.1.1

1.1       root        1: #include "asm.h"
                      2: 
                      3: /*
                      4:  * This routine is called early in the
                      5:  * game to set up the hashtable. First all
                      6:  * buckets in the table are cleared.
                      7:  * Then a pass is made through the builtin
                      8:  * symbols, linking them into their hash
                      9:  * buckets.
                     10:  */
                     11: syminit()
                     12: {
                     13:        register struct sym  *sp;
                     14:        struct sym **spp;
                     15:        int ht;
                     16:        register char *p1;
                     17:        register nc;
                     18: 
                     19:        spp = &symhash[0];
                     20:        while (spp < &symhash[NHASH])
                     21:                *spp++ = NULL;
                     22:        sp = &sym[0];
                     23:        for (;;) {
                     24:                ht = 0;
                     25:                nc = NCPLN;
                     26:                p1 = sp->s_id;
                     27:                do {
                     28:                        ht += *p1++;
                     29:                } while (--nc);
                     30:                sp->s_total = ht;
                     31:                ht &= HMASK;
                     32:                sp->s_sp = symhash[ht];
                     33:                symhash[ht] = sp;
                     34:                if ((sp->s_flag&S_END) != 0)
                     35:                        break;
                     36:                ++sp;
                     37:        }
                     38: }
                     39: 
                     40: /*
                     41:  * Mark all symbols of type `S_NEW'
                     42:  * global. Called at the end of pass
                     43:  * 0 if `-g'.
                     44:  */
                     45: symglob()
                     46: {
                     47:        register struct sym *sp;
                     48:        register i;
                     49: 
                     50:        for (i=0; i<NHASH; ++i) {
                     51:                sp = symhash[i];
                     52:                while (sp != NULL) {
                     53:                        if (sp->s_kind == S_NEW)
                     54:                                sp->s_flag |= S_GBL;
                     55:                        sp = sp->s_sp;
                     56:                }
                     57:        }
                     58: }
                     59: 
                     60: 
                     61: /*
                     62:  * Allocate a block of space.
                     63:  * Leave if there is no space left
                     64:  * at all.
                     65:  */
                     66: char *
                     67: new(n)
                     68: {
                     69:        register char *p;
                     70: 
                     71:        if ((p = malloc(n)) == NULL) {
                     72:                fprintf(stderr, "Out of space.\n");
                     73:                exit(1);
                     74:        }
                     75:        return (p);
                     76: }
                     77: 
                     78: /*
                     79:  * Copy a name.
                     80:  */
                     81: symcopy(p1, p2)
                     82: register char *p1, *p2;
                     83: {
                     84:        register n;
                     85: 
                     86:        n = NCPLN;
                     87:        do {
                     88:                *p1++ = *p2++;
                     89:        } while (--n);
                     90: }

unix.superglobalmegacorp.com

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