1/*
2 * fnv - Fowler/Noll/Vo- hash code
3 *
4 * @(#) $Revision: 5.4 $
5 * @(#) $Id: fnv.h,v 5.4 2009/07/30 22:49:13 chongo Exp $
6 * @(#) $Source: /usr/local/src/cmd/fnv/RCS/fnv.h,v $
7 *
8 ***
9 *
10 * Fowler/Noll/Vo- hash
11 *
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:
14 *
15 *      Phong Vo (http://www.research.att.com/info/kpv/)
16 *      Glenn Fowler (http://www.research.att.com/~gsf/)
17 *
18 * In a subsequent ballot round:
19 *
20 *      Landon Curt Noll (http://www.isthe.com/chongo/)
21 *
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.
25 *
26 * FNV hashes are designed 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:
29 *
30 *      http://www.isthe.com/chongo/tech/comp/fnv/index.html
31 *
32 * for more details as well as other forms of the FNV hash.
33 *
34 ***
35 *
36 * NOTE: The FNV-0 historic hash is not recommended.  One should use
37 *	 the FNV-1 hash instead.
38 *
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().
41 *
42 * To use the 64 bit FNV-0 historic hash, pass FNV0_64_INIT as the
43 * uint64_t hashval argument to fnv_64_buf() or fnv_64_str().
44 *
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().
47 *
48 * To use the recommended 64 bit FNV-1 hash, pass FNV1_64_INIT as the
49 * uint64_t hashval argument to fnv_64_buf() or fnv_64_str().
50 *
51 * To use the recommended 32 bit FNV-1a hash, pass FNV1_32A_INIT as the
52 * Fnv32_t hashval argument to fnv_32a_buf() or fnv_32a_str().
53 *
54 * To use the recommended 64 bit FNV-1a hash, pass FNV1A_64_INIT as the
55 * uint64_t hashval argument to fnv_64a_buf() or fnv_64a_str().
56 *
57 ***
58 *
59 * Please do not copyright this code.  This code is in the public domain.
60 *
61 * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
62 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
63 * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
64 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
65 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
66 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
67 * PERFORMANCE OF THIS SOFTWARE.
68 *
69 * By:
70 *	chongo <Landon Curt Noll> /\oo/\
71 *      http://www.isthe.com/chongo/
72 *
73 * Share and Enjoy!	:-)
74 */
75
76#if !defined(__FNV_H__)
77#define __FNV_H__
78
79#include <sys/types.h>
80
81#define FNV_VERSION "5.0.2"	/* @(#) FNV Version */
82#include <inttypes.h>
83
84#define HAVE_64BIT_LONG_LONG
85
86#if defined(HAVE_64BIT_LONG_LONG)
87#define FNV1_64_INIT ((uint64_t)0xcbf29ce484222325ULL)
88#define FNV1A_64_INIT FNV1_64_INIT
89#else /* HAVE_64BIT_LONG_LONG */
90extern const fnv1_64_init;
91extern const uint64_t fnv1a_64_init;
92#define FNV1_64_INIT (fnv1_64_init)
93#define FNV1A_64_INIT (fnv1a_64_init)
94#endif /* HAVE_64BIT_LONG_LONG */
95
96extern uint64_t fnv_64a_str(char *buf, uint64_t hashval);
97#endif /* __FNV_H__ */
98