1 /***********************************************************************
3 * This software is part of the ast package *
4 * Copyright (c) 1985-2010 AT&T Intellectual Property *
5 * and is licensed under the *
6 * Common Public License, Version 1.0 *
7 * by AT&T Intellectual Property *
9 * A copy of the License is available at *
10 * http://www.opensource.org/licenses/cpl1.0.txt *
11 * (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
13 * Information and Software Systems Research *
17 * Glenn Fowler <gsf@research.att.com> *
18 * David Korn <dgk@research.att.com> *
19 * Phong Vo <kpv@research.att.com> *
21 ***********************************************************************/
28 * FNV-1 linear congruent checksum/hash/PRNG
29 * see http://www.isthe.com/chongo/tech/comp/fnv/
35 #include <ast_common.h>
37 #define FNV_INIT 0x811c9dc5L
38 #define FNV_MULT 0x01000193L
40 #define FNVINIT(h) (h = FNV_INIT)
41 #define FNVPART(h,c) (h = (h) * FNV_MULT ^ (c))
42 #define FNVSUM(h,s,n) do { \
43 register size_t _i_ = 0; \
45 FNVPART(h, ((unsigned char*)s)[_i_++]); \
52 #define FNV_INIT64 0xcbf29ce484222325LL
53 #define FNV_MULT64 0x00000100000001b3LL
57 #define FNV_INIT64 ((int64_t)0xcbf29ce484222325)
58 #define FNV_MULT64 ((int64_t)0x00000100000001b3)
62 #define FNVINIT64(h) (h = FNV_INIT64)
63 #define FNVPART64(h,c) (h = (h) * FNV_MULT64 ^ (c))
64 #define FNVSUM64(h,s,n) do { \
65 register int _i_ = 0; \
67 FNVPART64(h, ((unsigned char*)s)[_i_++]); \