1N/A * See the file LICENSE for redistribution information. 1N/A * Copyright (c) 1996, 1997 1N/A * Sleepycat Software. All rights reserved. 1N/A * Copyright (c) 1990, 1993 1N/A * Margo Seltzer. All rights reserved. 1N/A * Copyright (c) 1990, 1993 1N/A * The Regents of the University of California. All rights reserved. 1N/A * This code is derived from software contributed to Berkeley by 1N/A * Redistribution and use in source and binary forms, with or without 1N/A * modification, are permitted provided that the following conditions 1N/A * 1. Redistributions of source code must retain the above copyright 1N/A * notice, this list of conditions and the following disclaimer. 1N/A * 2. Redistributions in binary form must reproduce the above copyright 1N/A * notice, this list of conditions and the following disclaimer in the 1N/A * documentation and/or other materials provided with the distribution. 1N/A * 3. All advertising materials mentioning features or use of this software 1N/A * must display the following acknowledgement: 1N/A * This product includes software developed by the University of 1N/A * California, Berkeley and its contributors. 1N/A * 4. Neither the name of the University nor the names of its contributors 1N/A * may be used to endorse or promote products derived from this software 1N/A * without specific prior written permission. 1N/A * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1N/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1N/A * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 1N/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1N/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 1N/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1N/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 1N/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 1N/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1N/A * Copyright (c) 1998 by Sun Microsystems, Inc. 1N/A * All rights reserved. 1N/A#
pragma ident "%Z%%M% %I% %E% SMI" 1N/A#
endif /* not lint */ 1N/A * Phong Vo's linear congruential hash. 1N/A * PUBLIC: u_int32_t __ham_func2 __P((const void *, u_int32_t)); 1N/A#
define DCHARHASH(h, c) ((h) =
0x63c63cd9*(h) +
0x9c39c33d + (c))
1N/A for (h = 0; k != e;) {
1N/A * Ozan Yigit's original sdbm hash. 1N/A * Ugly, but fast. Break the string up into 8 byte units. On the first time 1N/A * through the loop get the "leftover bytes" (strlen % 8). On every other 1N/A * iteration, perform 8 HASHC's so we handle all 8 bytes. Essentially, this 1N/A * saves us 7 cmp & branch instructions. 1N/A * PUBLIC: u_int32_t __ham_func3 __P((const void *, u_int32_t)); 1N/A * Chris Torek's hash function. Although this function performs only 1N/A * slightly worse than __ham_func5 on strings, it performs horribly on 1N/A * PUBLIC: u_int32_t __ham_func4 __P((const void *, u_int32_t)); 1N/A * The basis of the hash algorithm was taken from an idea sent by email to the 1N/A * IEEE Posix P1003.2 mailing list from Phong Vo (kpv@research.att.com) and 1N/A * Glenn Fowler (gsf@research.att.com). Landon Curt Noll (chongo@toad.com) 1N/A * later improved on their algorithm. 1N/A * The magic is in the interesting relationship between the special prime 1N/A * 16777619 (2^24 + 403) and 2^32 and 2^8. 1N/A * This hash produces the fewest collisions of any function that we've seen so 1N/A * far, and works well on both numbers and strings. 1N/A * PUBLIC: u_int32_t __ham_func5 __P((const void *, u_int32_t)); 1N/A for (h = 0; k < e; ++k) {