From: Pablo de Lara Date: Wed, 10 Jun 2015 15:25:26 +0000 (+0100) Subject: hash: rename a jhash function X-Git-Tag: spdx-start~9068 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7530c9eea7d9;p=dpdk.git hash: rename a jhash function Changed name to something more meaningful, and mark rte_jhash2 as deprecated. Signed-off-by: Pablo de Lara Acked-by: Bruce Richardson --- diff --git a/app/test/test_func_reentrancy.c b/app/test/test_func_reentrancy.c index dc070af967..85504c09bf 100644 --- a/app/test/test_func_reentrancy.c +++ b/app/test/test_func_reentrancy.c @@ -228,7 +228,7 @@ hash_create_free(__attribute__((unused)) void *arg) .entries = 16, .bucket_entries = 4, .key_len = 4, - .hash_func = (rte_hash_function)rte_jhash2, + .hash_func = (rte_hash_function)rte_jhash_32b, .hash_func_init_val = 0, .socket_id = 0, }; diff --git a/app/test/test_hash.c b/app/test/test_hash.c index 1da27c57b8..4ecb11bb03 100644 --- a/app/test/test_hash.c +++ b/app/test/test_hash.c @@ -1177,7 +1177,7 @@ test_hash_add_delete_jhash2(void) hash_params_ex.name = "hash_test_jhash2"; hash_params_ex.key_len = 4; - hash_params_ex.hash_func = (rte_hash_function)rte_jhash2; + hash_params_ex.hash_func = (rte_hash_function)rte_jhash_32b; handle = rte_hash_create(&hash_params_ex); if (handle == NULL) { @@ -1216,7 +1216,7 @@ test_hash_add_delete_2_jhash2(void) hash_params_ex.name = "hash_test_2_jhash2"; hash_params_ex.key_len = 8; - hash_params_ex.hash_func = (rte_hash_function)rte_jhash2; + hash_params_ex.hash_func = (rte_hash_function)rte_jhash_32b; handle = rte_hash_create(&hash_params_ex); if (handle == NULL) diff --git a/app/test/test_hash_functions.c b/app/test/test_hash_functions.c index c6cdccf1a4..8af8601d2f 100644 --- a/app/test/test_hash_functions.c +++ b/app/test/test_hash_functions.c @@ -204,7 +204,7 @@ verify_precalculated_hash_func_tests(void) } /* - * Verify that rte_jhash and rte_jhash2 return the same + * Verify that rte_jhash and rte_jhash_32b return the same */ static int verify_jhash_32bits(void) @@ -223,12 +223,12 @@ verify_jhash_32bits(void) hash = rte_jhash(key, hashtest_key_lens[i], hashtest_initvals[j]); /* Divide key length by 4 in rte_jhash for 32 bits */ - hash32 = rte_jhash2((const uint32_t *)key, + hash32 = rte_jhash_32b((const uint32_t *)key, hashtest_key_lens[i] >> 2, hashtest_initvals[j]); if (hash != hash32) { printf("rte_jhash returns different value (0x%x)" - "than rte_jhash2 (0x%x)\n", + "than rte_jhash_32b (0x%x)\n", hash, hash32); return -1; } diff --git a/lib/librte_hash/rte_jhash.h b/lib/librte_hash/rte_jhash.h index 210647ae66..0bc443a586 100644 --- a/lib/librte_hash/rte_jhash.h +++ b/lib/librte_hash/rte_jhash.h @@ -46,6 +46,8 @@ extern "C" { #include #include + +#include #include /* jhash.h: Jenkins hash support. @@ -279,7 +281,7 @@ rte_jhash_2hashes(const void *key, uint32_t length, uint32_t *pc, uint32_t *pb) * IN: second seed OUT: secondary hash value. */ static inline void -rte_jhash2_2hashes(const uint32_t *k, uint32_t length, uint32_t *pc, uint32_t *pb) +rte_jhash_32b_2hashes(const uint32_t *k, uint32_t length, uint32_t *pc, uint32_t *pb) { __rte_jhash_2hashes((const void *) k, (length << 2), pc, pb, 0); } @@ -322,11 +324,22 @@ rte_jhash(const void *key, uint32_t length, uint32_t initval) * Calculated hash value. */ static inline uint32_t +rte_jhash_32b(const uint32_t *k, uint32_t length, uint32_t initval) +{ + uint32_t initval2 = 0; + + rte_jhash_32b_2hashes(k, length, &initval, &initval2); + + return initval; +} + +static inline uint32_t +__attribute__ ((deprecated)) rte_jhash2(const uint32_t *k, uint32_t length, uint32_t initval) { uint32_t initval2 = 0; - rte_jhash2_2hashes(k, length, &initval, &initval2); + rte_jhash_32b_2hashes(k, length, &initval, &initval2); return initval; }