lhash.c

sima/lhash/lhash.c · 749 B

From the archive 970706-sima.tgz

Download the archive   « Back to the archive contents

#include <sys/types.h>

short hash(char *start, int len) {
    int *p;
    int o;
    int a,b,c,d,x,m;
    auto i;

#if 0
&i;
#endif
    p = (int *)((size_t)start+3 & ~3);
    o = len >> 3;
    m = (unsigned)-1 << (((size_t)start & 3) << 3);
    m = ~m;
#define X 1
#if 1
        b = p[1];
	c = p[2];
	d = p[3];
#if X
	x = p[0];
	x ^= p[4];
	x &= m;
	x ^= p[4];
	a = x;
#else
	a ^= ((p[0] ^ p[4]) & m) ^ p[4];
#endif
#else
	a = b = c = d = 0;
#endif
	p = (int *)((char*)p + o) + 4;
    i = 7;
    do {
        b ^= p[-3];
	c ^= p[-2];
	d ^= p[-1];
#if X
	x = p[-4];
	x ^= p[0];
	x &= m;
	x ^= p[0];
	a ^= x;
#else
	a ^= ((p[-4] ^ p[0]) & m) ^ p[1];
#endif
	a++,b++,c++,d++;
	p = (int *)((char*)p + o);
    } while (--i);
    return a + b + c + d;
}

Site Stats

Snippets: 1791
Codebases: 571