hash: rename a jhash function
authorPablo de Lara <pablo.de.lara.guarch@intel.com>
Wed, 10 Jun 2015 15:25:26 +0000 (16:25 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 16 Jun 2015 10:19:20 +0000 (12:19 +0200)
Changed name to something more meaningful,
and mark rte_jhash2 as deprecated.

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
app/test/test_func_reentrancy.c
app/test/test_hash.c
app/test/test_hash_functions.c
lib/librte_hash/rte_jhash.h

index dc070af..85504c0 100644 (file)
@@ -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,
        };
index 1da27c5..4ecb11b 100644 (file)
@@ -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)
index c6cdccf..8af8601 100644 (file)
@@ -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;
                                }
index 210647a..0bc443a 100644 (file)
@@ -46,6 +46,8 @@ extern "C" {
 
 #include <stdint.h>
 #include <string.h>
+
+#include <rte_log.h>
 #include <rte_byteorder.h>
 
 /* 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;
 }