[CLEANUP] hash: move the avalanche hash code globally available

We'll use this hash at other places, let's make it globally available.
The function has also been renamed because its "chash_hash" name was
not appropriate.
diff --git a/src/lb_chash.c b/src/lb_chash.c
index 58c029a..a2582f0 100644
--- a/src/lb_chash.c
+++ b/src/lb_chash.c
@@ -7,7 +7,7 @@
  * robin because we'll use it to replace the previous map-based implementation
  * which offered both algorithms.
  *
- * Copyright 2000-2009 Willy Tarreau <w@1wt.eu>
+ * Copyright 2000-2010 Willy Tarreau <w@1wt.eu>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -19,6 +19,7 @@
 #include <common/compat.h>
 #include <common/config.h>
 #include <common/debug.h>
+#include <common/standard.h>
 #include <eb32tree.h>
 
 #include <types/global.h>
@@ -27,28 +28,6 @@
 #include <proto/backend.h>
 #include <proto/queue.h>
 
-static inline unsigned int chash_hash(unsigned int a)
-{
-	/* This function is one of Bob Jenkins' full avalanche hashing
-	 * functions, which when provides quite a good distribution for little
-	 * input variations. The result is quite suited to fit over a 32-bit
-	 * space with enough variations so that a randomly picked number falls
-	 * equally before any server position.
-	 * Check http://burtleburtle.net/bob/hash/integer.html for more info.
-	 */
-	a = (a+0x7ed55d16) + (a<<12);
-	a = (a^0xc761c23c) ^ (a>>19);
-	a = (a+0x165667b1) + (a<<5);
-	a = (a+0xd3a2646c) ^ (a<<9);
-	a = (a+0xfd7046c5) + (a<<3);
-	a = (a^0xb55a4f09) ^ (a>>16);
-
-	/* ensure values are better spread all around the tree by multiplying
-	 * by a large prime close to 3/4 of the tree.
-	 */
-	return a * 3221225473U;
-}
-
 /* Return next tree node after <node> which must still be in the tree, or be
  * NULL. Lookup wraps around the end to the beginning. If the next node is the
  * same node, return NULL. This is designed to find a valid next node before
@@ -292,7 +271,7 @@
 	else
 		return NULL;
 
-	hash = chash_hash(hash);
+	hash = full_hash(hash);
 
 	/* find the node after and the node before */
 	next = eb32_lookup_ge(root, hash);
@@ -418,7 +397,7 @@
 
 		for (node = 0; node < srv->lb_nodes_tot; node++) {
 			srv->lb_nodes[node].server = srv;
-			srv->lb_nodes[node].node.key = chash_hash(srv->puid * SRV_EWGHT_RANGE + node);
+			srv->lb_nodes[node].node.key = full_hash(srv->puid * SRV_EWGHT_RANGE + node);
 		}
 
 		if (srv_is_usable(srv->state, srv->eweight))
diff --git a/src/standard.c b/src/standard.c
index 60f5af1..1ab2194 100644
--- a/src/standard.c
+++ b/src/standard.c
@@ -1106,6 +1106,12 @@
 	return ret;
 }
 
+/* hash a 32-bit integer to another 32-bit integer */
+unsigned int full_hash(unsigned int a)
+{
+	return __full_hash(a);
+}
+
 /*
  * Local variables:
  *  c-indent-level: 8