1/* 2 * Taken from http://burtleburtle.net/bob/c/lookup3.c
| 1/* 2 * Taken from http://burtleburtle.net/bob/c/lookup3.c
|
3 * $FreeBSD: head/sys/libkern/jenkins_hash.c 240086 2012-09-04 12:07:33Z glebius $
| 3 * $FreeBSD: head/sys/libkern/jenkins_hash.c 240521 2012-09-14 22:00:03Z eadler $
|
4 */ 5 6#include <sys/hash.h> 7#include <machine/endian.h> 8 9/* 10------------------------------------------------------------------------------- 11lookup3.c, by Bob Jenkins, May 2006, Public Domain. 12 13These are functions for producing 32-bit hashes for hash table lookup. 14hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final() 15are externally useful functions. Routines to test the hash are included 16if SELF_TEST is defined. You can use this free for any purpose. It's in 17the public domain. It has no warranty. 18 19You probably want to use hashlittle(). hashlittle() and hashbig()
| 4 */ 5 6#include <sys/hash.h> 7#include <machine/endian.h> 8 9/* 10------------------------------------------------------------------------------- 11lookup3.c, by Bob Jenkins, May 2006, Public Domain. 12 13These are functions for producing 32-bit hashes for hash table lookup. 14hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final() 15are externally useful functions. Routines to test the hash are included 16if SELF_TEST is defined. You can use this free for any purpose. It's in 17the public domain. It has no warranty. 18 19You probably want to use hashlittle(). hashlittle() and hashbig()
|
20hash byte arrays. hashlittle() is is faster than hashbig() on
| 20hash byte arrays. hashlittle() is faster than hashbig() on
|
21little-endian machines. Intel and AMD are little-endian machines. 22On second thought, you probably want hashlittle2(), which is identical to 23hashlittle() except it returns two 32-bit hashes for the price of one. 24You could implement hashbig2() if you wanted but I haven't bothered here. 25 26If you want to find a hash of, say, exactly 7 integers, do 27 a = i1; b = i2; c = i3; 28 mix(a,b,c);
--- 435 unchanged lines hidden --- | 21little-endian machines. Intel and AMD are little-endian machines. 22On second thought, you probably want hashlittle2(), which is identical to 23hashlittle() except it returns two 32-bit hashes for the price of one. 24You could implement hashbig2() if you wanted but I haven't bothered here. 25 26If you want to find a hash of, say, exactly 7 integers, do 27 a = i1; b = i2; c = i3; 28 mix(a,b,c);
--- 435 unchanged lines hidden --- |