[mod-xhtml-neg-cvs] mod_xhtml_neg-2.0 lookupa.c,1.1,1.2 Doxyfile,1.3,1.4
Brought to you by:
run2000
From: <ru...@us...> - 2004-03-31 09:45:43
|
Update of /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24086 Modified Files: lookupa.c Doxyfile Log Message: Doxygenise lookupa.c. Index: lookupa.c =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/lookupa.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** lookupa.c 30 Mar 2004 10:37:54 -0000 1.1 --- lookupa.c 31 Mar 2004 09:33:57 -0000 1.2 *************** *** 1,8 **** ! /* ! -------------------------------------------------------------------- lookupa.c, by Bob Jenkins, December 1996. Same as lookup2.c Use this code however you wish. Public Domain. No warranty. Source is http://burtleburtle.net/bob/c/lookupa.c ! -------------------------------------------------------------------- */ --- 1,8 ---- ! /** @file ! lookupa.c, by Bob Jenkins, December 1996. Same as lookup2.c Use this code however you wish. Public Domain. No warranty. Source is http://burtleburtle.net/bob/c/lookupa.c ! */ *************** *** 11,39 **** #endif ! /* ! -------------------------------------------------------------------- ! mix -- mix 3 32-bit values reversibly. For every delta with one or two bit set, and the deltas of all three ! high bits or all three low bits, whether the original value of a,b,c ! is almost all zero or is uniformly distributed, ! * If mix() is run forward or backward, at least 32 bits in a,b,c have at least 1/4 probability of changing. ! * If mix() is run forward, every bit of c will change between 1/3 and 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) ! mix() was built out of 36 single-cycle latency instructions in a ! structure that could supported 2x parallelism, like so: ! a -= b; ! a -= c; x = (c>>13); ! b -= c; a ^= x; ! b -= a; x = (a<<8); ! c -= a; b ^= x; ! c -= b; x = (b>>13); ! ... ! Unfortunately, superscalar Pentiums and Sparcs can't take advantage ! of that parallelism. They've also turned some of those single-cycle ! latency instructions into multi-cycle latency instructions. Still, ! this is the fastest good hash I could find. There were about 2^^68 ! to choose from. I only looked at a billion or so. ! -------------------------------------------------------------------- */ #define mix(a,b,c) \ --- 11,43 ---- #endif ! /** ! ! @brief mix -- mix 3 32-bit values reversibly. ! For every delta with one or two bit set, and the deltas of all three ! high bits or all three low bits, whether the original value of a,b,c ! is almost all zero or is uniformly distributed, ! - If mix() is run forward or backward, at least 32 bits in a,b,c have at least 1/4 probability of changing. ! - If mix() is run forward, every bit of c will change between 1/3 and 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) ! ! mix() was built out of 36 single-cycle latency instructions in a ! structure that could supported 2x parallelism, like so: ! @verbatim ! a -= b; ! a -= c; x = (c>>13); ! b -= c; a ^= x; ! b -= a; x = (a<<8); ! c -= a; b ^= x; ! c -= b; x = (b>>13); ! ... ! @endverbatim ! Unfortunately, superscalar Pentiums and Sparcs can't take advantage ! of that parallelism. They've also turned some of those single-cycle ! latency instructions into multi-cycle latency instructions. Still, ! this is the fastest good hash I could find. There were about 2^^68 ! to choose from. I only looked at a billion or so. ! */ #define mix(a,b,c) \ *************** *** 50,59 **** } ! /* ! -------------------------------------------------------------------- ! lookup() -- hash a variable-length key into a 32-bit value ! k : the key (the unaligned variable-length array of bytes) ! len : the length of the key, counting by bytes ! level : can be any 4-byte value Returns a 32-bit value. Every bit of the key affects every bit of the return value. Every 1-bit and 2-bit delta achieves avalanche. --- 54,65 ---- } ! /** ! ! @brief lookup() -- hash a variable-length key into a 32-bit value ! ! @param k the key (the unaligned variable-length array of bytes) ! @param len the length of the key, counting by bytes ! @param level can be any 4-byte value ! Returns a 32-bit value. Every bit of the key affects every bit of the return value. Every 1-bit and 2-bit delta achieves avalanche. *************** *** 63,71 **** --- 69,81 ---- mod a prime (mod is sooo slow!). If you need less than 32 bits, use a bitmask. For example, if you need only 10 bits, do + @verbatim h = (h & hashmask(10)); + @endverbatim In which case, the hash table should have hashsize(10) elements. If you are hashing n strings (ub1 **)k, do it like this: + @verbatim for (i=0, h=0; i<n; ++i) h = lookup( k[i], len[i], h); + @endverbatim By Bob Jenkins, 1996. bob...@bu.... You may use this *************** *** 75,79 **** Use for hash table lookup, or anything where one collision in 2^32 is acceptable. Do NOT use for cryptographic purposes. ! -------------------------------------------------------------------- */ --- 85,89 ---- Use for hash table lookup, or anything where one collision in 2^32 is acceptable. Do NOT use for cryptographic purposes. ! */ *************** *** 121,131 **** ! /* ! -------------------------------------------------------------------- ! mixc -- mixc 8 4-bit values as quickly and thoroughly as possible. ! Repeating mix() three times achieves avalanche. Repeating mix() four times eliminates all funnels and all characteristics stronger than 2^{-11}. ! -------------------------------------------------------------------- */ #define mixc(a,b,c,d,e,f,g,h) \ --- 131,142 ---- ! /** ! ! @brief mixc -- mixc 8 4-bit values as quickly and thoroughly as possible. ! ! Repeating mix() three times achieves avalanche. \n Repeating mix() four times eliminates all funnels and all characteristics stronger than 2^{-11}. ! */ #define mixc(a,b,c,d,e,f,g,h) \ *************** *** 141,156 **** } ! /* ! -------------------------------------------------------------------- ! checksum() -- hash a variable-length key into a 256-bit value ! k : the key (the unaligned variable-length array of bytes) ! len : the length of the key, counting by bytes ! state : an array of CHECKSTATE 4-byte values (256 bits) The state is the checksum. Every bit of the key affects every bit of the state. There are no funnels. About 112+6.875len instructions. If you are hashing n strings (ub1 **)k, do it like this: for (i=0; i<8; ++i) state[i] = 0x9e3779b9; for (i=0, h=0; i<n; ++i) checksum( k[i], len[i], state); (c) Bob Jenkins, 1996. bob...@bu.... You may use this --- 152,170 ---- } ! /** ! ! @brief checksum() -- hash a variable-length key into a 256-bit value ! @param k the key (the unaligned variable-length array of bytes) ! @param len the length of the key, counting by bytes ! @param state an array of CHECKSTATE 4-byte values (256 bits) ! The state is the checksum. Every bit of the key affects every bit of the state. There are no funnels. About 112+6.875len instructions. If you are hashing n strings (ub1 **)k, do it like this: + @verbatim for (i=0; i<8; ++i) state[i] = 0x9e3779b9; for (i=0, h=0; i<n; ++i) checksum( k[i], len[i], state); + @endverbatim (c) Bob Jenkins, 1996. bob...@bu.... You may use this *************** *** 161,165 **** Use to detect changes between revisions of documents, assuming nobody is trying to cause collisions. Do NOT use for cryptography. ! -------------------------------------------------------------------- */ void checksum( register ub1 *k, register ub4 len, register ub4 *state ) --- 175,179 ---- Use to detect changes between revisions of documents, assuming nobody is trying to cause collisions. Do NOT use for cryptography. ! */ void checksum( register ub1 *k, register ub4 len, register ub4 *state ) Index: Doxyfile =================================================================== RCS file: /cvsroot/mod-xhtml-neg/mod_xhtml_neg-2.0/Doxyfile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Doxyfile 30 Mar 2004 10:37:04 -0000 1.3 --- Doxyfile 31 Mar 2004 09:33:57 -0000 1.4 *************** *** 310,314 **** # with spaces. ! INPUT = mod_xhtml_neg.c # If the value of the INPUT tag contains directories, you can use the --- 310,314 ---- # with spaces. ! INPUT = mod_xhtml_neg.c lookupa.c # If the value of the INPUT tag contains directories, you can use the |