xref: /titanic_50/usr/src/lib/libast/sparcv9/include/ast/fnv.h (revision b494511a9cf72b1fc4eb13a0e593f55c624ab829)
1 
2 /* : : generated by proto : : */
3 /***********************************************************************
4 *                                                                      *
5 *               This software is part of the ast package               *
6 *          Copyright (c) 1985-2010 AT&T Intellectual Property          *
7 *                      and is licensed under the                       *
8 *                  Common Public License, Version 1.0                  *
9 *                    by AT&T Intellectual Property                     *
10 *                                                                      *
11 *                A copy of the License is available at                 *
12 *            http://www.opensource.org/licenses/cpl1.0.txt             *
13 *         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
14 *                                                                      *
15 *              Information and Software Systems Research               *
16 *                            AT&T Research                             *
17 *                           Florham Park NJ                            *
18 *                                                                      *
19 *                 Glenn Fowler <gsf@research.att.com>                  *
20 *                  David Korn <dgk@research.att.com>                   *
21 *                   Phong Vo <kpv@research.att.com>                    *
22 *                                                                      *
23 ***********************************************************************/
24 
25 /*
26  * Glenn Fowler
27  * Landon Kurt Knoll
28  * Phong Vo
29  *
30  * FNV-1 linear congruent checksum/hash/PRNG
31  * see http://www.isthe.com/chongo/tech/comp/fnv/
32  */
33 
34 #ifndef _FNV_H
35 #if !defined(__PROTO__)
36 #include <prototyped.h>
37 #endif
38 #if !defined(__LINKAGE__)
39 #define __LINKAGE__		/* 2004-08-11 transition */
40 #endif
41 
42 #define _FNV_H
43 
44 #include <ast_common.h>
45 
46 #define FNV_INIT	0x811c9dc5L
47 #define FNV_MULT	0x01000193L
48 
49 #define FNVINIT(h)	(h = FNV_INIT)
50 #define FNVPART(h,c)	(h = (h) * FNV_MULT ^ (c))
51 #define FNVSUM(h,s,n)	do { \
52 			register size_t _i_ = 0; \
53 			while (_i_ < n) \
54 				FNVPART(h, ((unsigned char*)s)[_i_++]); \
55 			} while (0)
56 
57 #if _typ_int64_t
58 
59 #ifdef _ast_LL
60 
61 #define FNV_INIT64	0xcbf29ce484222325LL
62 #define FNV_MULT64	0x00000100000001b3LL
63 
64 #else
65 
66 #define FNV_INIT64	((int64_t)0xcbf29ce484222325)
67 #define FNV_MULT64	((int64_t)0x00000100000001b3)
68 
69 #endif
70 
71 #define FNVINIT64(h)	(h = FNV_INIT64)
72 #define FNVPART64(h,c)	(h = (h) * FNV_MULT64 ^ (c))
73 #define FNVSUM64(h,s,n)	do { \
74 			register int _i_ = 0; \
75 			while (_i_ < n) \
76 				FNVPART64(h, ((unsigned char*)s)[_i_++]); \
77 			} while (0)
78 
79 #endif
80 
81 #endif
82