X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_hash%2Frte_jhash.h;h=a4bf5a1b38db143d88315e93a376430a7534540c;hb=518b590803b9253cd881fc40f59e61dc768aacd3;hp=c689fbfa748de9118cdfaef3fa8b86028523fb6d;hpb=dada9ef6edc59015b6674b5a95258787c71401b0;p=dpdk.git diff --git a/lib/librte_hash/rte_jhash.h b/lib/librte_hash/rte_jhash.h index c689fbfa74..a4bf5a1b38 100644 --- a/lib/librte_hash/rte_jhash.h +++ b/lib/librte_hash/rte_jhash.h @@ -1,35 +1,34 @@ /*- * BSD LICENSE - * - * Copyright(c) 2010-2012 Intel Corporation. All rights reserved. + * + * Copyright(c) 2010-2014 Intel Corporation. All rights reserved. * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions * are met: - * - * * Redistributions of source code must retain the above copyright + * + * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * */ #ifndef _RTE_JHASH_H @@ -97,24 +96,22 @@ static inline uint32_t rte_jhash(const void *key, uint32_t length, uint32_t initval) { uint32_t a, b, c, len; - const uint8_t *k = (const uint8_t *) key; + const uint8_t *k = (const uint8_t *)key; + const uint32_t *k32 = (const uint32_t *)key; len = length; a = b = RTE_JHASH_GOLDEN_RATIO; c = initval; while (len >= 12) { - a += (k[0] + ((uint32_t)k[1] << 8) + ((uint32_t)k[2] << 16) + - ((uint32_t)k[3] << 24)); - b += (k[4] + ((uint32_t)k[5] << 8) + ((uint32_t)k[6] << 16) + - ((uint32_t)k[7] << 24)); - c += (k[8] + ((uint32_t)k[9] << 8) + ((uint32_t)k[10] << 16) + - ((uint32_t)k[11] << 24)); + a += k32[0]; + b += k32[1]; + c += k32[2]; __rte_jhash_mix(a,b,c); - k += 12; - len -= 12; + k += (3 * sizeof(uint32_t)), k32 += 3; + len -= (3 * sizeof(uint32_t)); } c += length; @@ -152,7 +149,7 @@ rte_jhash(const void *key, uint32_t length, uint32_t initval) * Calculated hash value. */ static inline uint32_t -rte_jhash2(uint32_t *k, uint32_t length, uint32_t initval) +rte_jhash2(const uint32_t *k, uint32_t length, uint32_t initval) { uint32_t a, b, c, len; @@ -217,9 +214,6 @@ rte_jhash_3words(uint32_t a, uint32_t b, uint32_t c, uint32_t initval) * A special ultra-optimized versions that knows it is hashing exactly * 2 words. * - * NOTE: In partilar the "c += length; __rte_jhash_mix(a,b,c);" normally - * done at the end is not done here. - * * @param a * First word to calcuate hash of. * @param b @@ -239,9 +233,6 @@ rte_jhash_2words(uint32_t a, uint32_t b, uint32_t initval) * A special ultra-optimized versions that knows it is hashing exactly * 1 word. * - * NOTE: In partilar the "c += length; __rte_jhash_mix(a,b,c);" normally - * done at the end is not done here. - * * @param a * Word to calcuate hash of. * @param initval