2 * fnv - Fowler/Noll/Vo- hash code
10 * Fowler/Noll/Vo- hash
12 * The basis of this hash algorithm was taken from an idea sent
13 * as reviewer comments to the IEEE POSIX P1003.2 committee by:
15 * Phong Vo (http://www.research.att.com/info/kpv/)
16 * Glenn Fowler (http://www.research.att.com/~gsf/)
18 * In a subsequent ballot round:
20 * Landon Curt Noll (http://reality.sgi.com/chongo/)
22 * improved on their algorithm. Some people tried this hash
23 * and found that it worked rather well. In an EMail message
24 * to Landon, they named it the ``Fowler/Noll/Vo'' or FNV hash.
26 * FNV hashes are architected to be fast while maintaining a low
27 * collision rate. The FNV speed allows one to quickly hash lots
28 * of data while maintaining a reasonable collision rate. See:
30 * http://reality.sgi.com/chongo/tech/comp/fnv/
32 * for more details as well as other forms of the FNV hash.
36 * NOTE: The FNV-0 historic hash is not recommended. One should use
37 * the FNV-1 hash instead.
39 * To use the 32 bit FNV-0 historic hash, pass FNV0_32_INIT as the
40 * Fnv32_t hashval argument to fnv_32_buf() or fnv_32_str().
42 * To use the 64 bit FNV-0 historic hash, pass FNV0_64_INIT as the
43 * Fnv64_t hashval argument to fnv_64_buf() or fnv_64_str().
45 * To use the recommended 32 bit FNV-1 hash, pass FNV1_32_INIT as the
46 * Fnv32_t hashval argument to fnv_32_buf() or fnv_32_str().
48 * To use the recommended 64 bit FNV-1 hash, pass FNV1_64_INIT as the
49 * Fnv64_t hashval argument to fnv_64_buf() or fnv_64_str().
53 * Please do not copyright this code. This code is in the public domain.
55 * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
56 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
57 * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
58 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
59 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
60 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
61 * PERFORMANCE OF THIS SOFTWARE.
64 * chongo <Landon Curt Noll> /\oo/\
65 * http://reality.sgi.com/chongo/
66 * EMail: chongo_fnv at prime dot engr dot sgi dot com
68 * Share and Enjoy! :-)
71 #if !defined(__FNV_H__)
76 * 32 bit FNV-0 hash type
78 typedef unsigned long Fnv32_t;
82 * 32 bit FNV-0 zero initial basis
84 * This historic hash is not recommended. One should use
85 * the FNV-1 hash and inital basis instead.
87 #define FNV0_32_INIT ((Fnv32_t)0)
91 * 32 bit FNV-1 non-zero initial basis
93 * The FNV-1 initial basis is the FNV-0 hash of the following 32 octets:
95 * chongo <Landon Curt Noll> /\../\
97 * Note that the \'s above are not back-slashing escape characters.
98 * They are literal ASCII backslash 0x5c characters.
100 #define FNV1_32_INIT ((Fnv32_t)0x811c9dc5)
111 unsigned long FnvHash(
114 #endif /* __FNV_H__ */