/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#pragma prototyped22/*23* Glenn Fowler24* Landon Kurt Knoll25* Phong Vo26*27* FNV-1 linear congruent checksum/hash/PRNG28* see http://www.isthe.com/chongo/tech/comp/fnv/29*/3031#ifndef _FNV_H32#define _FNV_H3334#include <ast_common.h>3536#define FNV_INIT 0x811c9dc5L37#define FNV_MULT 0x01000193L3839#define FNVINIT(h) (h = FNV_INIT)40#define FNVPART(h,c) (h = (h) * FNV_MULT ^ (c))41#define FNVSUM(h,s,n) do { \42register size_t _i_ = 0; \43while (_i_ < n) \44FNVPART(h, ((unsigned char*)s)[_i_++]); \45} while (0)4647#if _typ_int64_t4849#ifdef _ast_LL5051#define FNV_INIT64 0xcbf29ce484222325LL52#define FNV_MULT64 0x00000100000001b3LL5354#else5556#define FNV_INIT64 ((int64_t)0xcbf29ce484222325)57#define FNV_MULT64 ((int64_t)0x00000100000001b3)5859#endif6061#define FNVINIT64(h) (h = FNV_INIT64)62#define FNVPART64(h,c) (h = (h) * FNV_MULT64 ^ (c))63#define FNVSUM64(h,s,n) do { \64register int _i_ = 0; \65while (_i_ < n) \66FNVPART64(h, ((unsigned char*)s)[_i_++]); \67} while (0)6869#endif7071#endif727374