X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fhashfunc.c;h=d92b681ee6bbdc667d96d9bc23dd258df6d25063;hb=959566090f98dd31eaa67d3d5959b641e5fe902b;hp=2ea365700b2c2a818c6978d8bab515c5480a05f2;hpb=ad920945145a18895ef391511c92ef42e0e4c3d7;p=libucw.git diff --git a/ucw/hashfunc.c b/ucw/hashfunc.c index 2ea36570..d92b681e 100644 --- a/ucw/hashfunc.c +++ b/ucw/hashfunc.c @@ -11,38 +11,38 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/hashfunc.h" -#include "ucw/chartype.h" +#include +#include +#include /* The number of bits the hash in the function hash_*() is rotated by after * every pass. It should be prime with the word size. */ #define SHIFT_BITS 7 /* A bit-mask which clears higher bytes than a given threshold. */ -static uns mask_higher_bits[sizeof(uns)]; +static uint mask_higher_bits[sizeof(uint)]; static void CONSTRUCTOR hashfunc_init(void) { - uns i, j; + uint i, j; byte *str; - for (i=0; i= sizeof(uns)) + const uint *u = (const uint *) buf; + uint hash = 0; + while (len >= sizeof(uint)) { hash = ROL(hash, SHIFT_BITS) ^ *u++; - len -= sizeof(uns); + len -= sizeof(uint); } hash = ROL(hash, SHIFT_BITS) ^ (*u & mask_higher_bits[len]); return hash; } #ifndef CPU_ALLOW_UNALIGNED -uns +uint str_len(const char *str) { - uns shift = UNALIGNED_PART(str, uns); + uint shift = UNALIGNED_PART(str, uint); if (!shift) return str_len_aligned(str); else { - uns i; - shift = sizeof(uns) - shift; + uint i; + shift = sizeof(uint) - shift; for (i=0; i