Annotation of coherent/b/bin/as/hash.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Read a string return the hash value computed using CRC-16 methods.
        !             3:  */
        !             4: unsigned short
        !             5: hash(p)
        !             6: register char *p;
        !             7: {
        !             8:        register unsigned char tmp, c; /* warning types are carefully chosen */
        !             9:        register unsigned short h;
        !            10: 
        !            11:        /*
        !            12:         * Tables for the table-driven CRC16 algorithm.
        !            13:         * This should be relatively uniform statistically.
        !            14:         */
        !            15:        static  unsigned short crctab1[] = {
        !            16:                0000000,        0140301,        0140601,        0000500,
        !            17:                0141401,        0001700,        0001200,        0141101,
        !            18:                0143001,        0003300,        0003600,        0143501,
        !            19:                0002400,        0142701,        0142201,        0002100
        !            20:        };
        !            21: 
        !            22:        static  unsigned short crctab2[] = {
        !            23:                0000000,        0146001,        0154001,        0012000,
        !            24:                0170001,        0036000,        0024000,        0162001,
        !            25:                0120001,        0066000,        0074000,        0132001,
        !            26:                0050000,        0116001,        0104001,        0043000
        !            27:        };
        !            28: 
        !            29:        for(h = 0; c = *p; p++) {
        !            30:                tmp = c ^ h;
        !            31:                h = (h >> 8) ^ crctab1[tmp & 15] ^ crctab2[tmp >> 4];
        !            32:        }
        !            33:        return(h);
        !            34: }

unix.superglobalmegacorp.com

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