1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2009 by Andrew Mahone
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
22 ****************************************************************************/
26 #include <inttypes.h> /* defines uint32_t etc */
27 #include <sys/types.h>
31 hashw() -- hash an array of uint32_t into a 32-bit value
32 k: pointer to the key, an array of uint32_t
33 length: number of elements in the key
34 initval: an initialization value
35 returns the 32-bit hash
37 uint32_t hashw(const uint32_t *k
, size_t length
, uint32_t initval
);
40 hashw() -- hash an array of uint32_t into two 32-bit values
41 (*pc) will be the same as the return value from hashword().
42 k: pointer to the key, an array of uint32_t
43 length: number of elements in the key
44 pc, pb: pointers to primary and secondary initial values, also used to store
47 void hashw2 (const uint32_t *k
, size_t length
, uint32_t *pc
, uint32_t *pb
);
50 hashs() -- hash an array of bytes into a 32-bit value
51 k: pointer to the key, an array of bytes
52 length: number of elements in the key
53 initval: an initialization value
54 returns the 32-bit hash
56 uint32_t hashs( const void *key
, size_t length
, uint32_t initval
);
59 hashs2() -- hash an array of bytes into two 32-bit values
60 k: pointer to the key, an array of bytes
61 length: number of elements in the key
62 pc, pb: pointers to primary and secondary initial values, also used to store
65 void hashs2(const void *key
, size_t length
, uint32_t *pc
, uint32_t *pb
);