aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-24 16:49:57 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-24 16:49:57 +0100
commitefd981202a374cc75b2d5d1e61b518267e8527d8 (patch)
treeb93d28a00c28eb70a5deda98b2707d082fe590a8 /src/libutil
parente1659e40db3f5da8492bf75a3e270146ce6cca32 (diff)
downloadrspamd-efd981202a374cc75b2d5d1e61b518267e8527d8.tar.gz
rspamd-efd981202a374cc75b2d5d1e61b518267e8527d8.zip
Replace murmur with xxhash32.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.c171
-rw-r--r--src/libutil/util.h35
2 files changed, 0 insertions, 206 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c
index 3ca0c1aca..f06b7a62d 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -1798,177 +1798,6 @@ rspamd_create_thread (const gchar *name,
return new;
}
-guint32
-murmur32_hash (const guint8 *in, gsize len)
-{
-
-
- const guint32 c1 = 0xcc9e2d51;
- const guint32 c2 = 0x1b873593;
-
- const int nblocks = len / 4;
- const guint32 *blocks = (const guint32 *)(in);
- const guint8 *tail;
- guint32 h = 0;
- gint i;
- guint32 k;
-
- if (in == NULL || len == 0) {
- return 0;
- }
-
- tail = (const guint8 *)(in + (nblocks * 4));
-
- for (i = 0; i < nblocks; i++) {
- k = blocks[i];
-
- k *= c1;
- k = (k << 15) | (k >> (32 - 15));
- k *= c2;
-
- h ^= k;
- h = (h << 13) | (h >> (32 - 13));
- h = (h * 5) + 0xe6546b64;
- }
-
- k = 0;
- switch (len & 3) {
- case 3:
- k ^= tail[2] << 16;
- case 2:
- k ^= tail[1] << 8;
- case 1:
- k ^= tail[0];
- k *= c1;
- k = (k << 13) | (k >> (32 - 15));
- k *= c2;
- h ^= k;
- };
-
- h ^= len;
-
- h ^= h >> 16;
- h *= 0x85ebca6b;
- h ^= h >> 13;
- h *= 0xc2b2ae35;
- h ^= h >> 16;
-
- return h;
-}
-
-void
-murmur128_hash (const guint8 *in, gsize len, guint64 out[])
-{
- const guint64 c1 = 0x87c37b91114253d5ULL;
- const guint64 c2 = 0x4cf5ad432745937fULL;
- const gint nblocks = len / 16;
- const guint64 *blocks = (const guint64 *)(in);
- const guint8 *tail;
- guint64 h1 = 0;
- guint64 h2 = 0;
- int i;
- guint64 k1, k2;
-
- if (in == NULL || len == 0 || out == NULL) {
- return;
- }
-
- tail = (const guint8 *)(in + (nblocks * 16));
-
- for (i = 0; i < nblocks; i++) {
- k1 = blocks[i * 2 + 0];
- k2 = blocks[i * 2 + 1];
-
- k1 *= c1;
- k1 = (k1 << 31) | (k1 >> (64 - 31));
- k1 *= c2;
- h1 ^= k1;
-
- h1 = (h1 << 27) | (h1 >> (64 - 27));
- h1 += h2;
- h1 = h1 * 5 + 0x52dce729;
-
- k2 *= c2;
- k2 = (k2 << 33) | (k2 >> (64 - 33));
- k2 *= c1;
- h2 ^= k2;
-
- h2 = (h2 << 31) | (h2 >> (64 - 31));
- h2 += h1;
- h2 = h2 * 5 + 0x38495ab5;
- }
-
- k1 = k2 = 0;
- switch (len & 15) {
- case 15:
- k2 ^= (guint64)(tail[14]) << 48;
- case 14:
- k2 ^= (guint64)(tail[13]) << 40;
- case 13:
- k2 ^= (guint64)(tail[12]) << 32;
- case 12:
- k2 ^= (guint64)(tail[11]) << 24;
- case 11:
- k2 ^= (guint64)(tail[10]) << 16;
- case 10:
- k2 ^= (guint64)(tail[ 9]) << 8;
- case 9:
- k2 ^= (guint64)(tail[ 8]) << 0;
- k2 *= c2;
- k2 = (k2 << 33) | (k2 >> (64 - 33));
- k2 *= c1;
- h2 ^= k2;
-
- case 8:
- k1 ^= (guint64)(tail[ 7]) << 56;
- case 7:
- k1 ^= (guint64)(tail[ 6]) << 48;
- case 6:
- k1 ^= (guint64)(tail[ 5]) << 40;
- case 5:
- k1 ^= (guint64)(tail[ 4]) << 32;
- case 4:
- k1 ^= (guint64)(tail[ 3]) << 24;
- case 3:
- k1 ^= (guint64)(tail[ 2]) << 16;
- case 2:
- k1 ^= (guint64)(tail[ 1]) << 8;
- case 1:
- k1 ^= (guint64)(tail[ 0]) << 0;
- k1 *= c1;
- k1 = (k1 << 31) | (k1 >> (64 - 31));
- k1 *= c2;
- h1 ^= k1;
- };
-
- //----------
- // finalization
-
- h1 ^= len;
- h2 ^= len;
-
- h1 += h2;
- h2 += h1;
-
- h1 ^= h1 >> 33;
- h1 *= 0xff51afd7ed558ccdULL;
- h1 ^= h1 >> 33;
- h1 *= 0xc4ceb9fe1a85ec53ULL;
- h1 ^= h1 >> 33;
-
- h2 ^= h2 >> 33;
- h2 *= 0xff51afd7ed558ccdULL;
- h2 ^= h2 >> 33;
- h2 *= 0xc4ceb9fe1a85ec53ULL;
- h2 ^= h2 >> 33;
-
- h1 += h2;
- h2 += h1;
-
- out[0] = h1;
- out[1] = h2;
-}
-
struct hash_copy_callback_data {
gpointer (*key_copy_func)(gconstpointer data, gpointer ud);
gpointer (*value_copy_func)(gconstpointer data, gpointer ud);
diff --git a/src/libutil/util.h b/src/libutil/util.h
index 9bef49a7e..3a44cb1d8 100644
--- a/src/libutil/util.h
+++ b/src/libutil/util.h
@@ -387,41 +387,6 @@ GThread * rspamd_create_thread (const gchar *name,
GError **err);
/**
- * Return 32bit murmur hash value for specified input
- * @param in input data
- * @param len length of the input data
- * @code
- * MurmurHash3 was created by Austin Appleby in 2008. The cannonical
- * implementations are in C++ and placed in the public.
- *
- * https://sites.google.com/site/murmurhash/
- *
- * Seungyoung Kim has ported it's cannonical implementation to C language
- * in 2012 and published it as a part of qLibc component.
- * @endcode
- * @return
- */
-guint32 murmur32_hash (const guint8 *in, gsize len);
-
-/**
- * Return 32bit murmur hash value for specified input
- * @param in input data
- * @param len length of the input data
- * @param out array of 2 guint64 variables
- * @code
- * MurmurHash3 was created by Austin Appleby in 2008. The cannonical
- * implementations are in C++ and placed in the public.
- *
- * https://sites.google.com/site/murmurhash/
- *
- * Seungyoung Kim has ported it's cannonical implementation to C language
- * in 2012 and published it as a part of qLibc component.
- * @endcode
- * @return
- */
-void murmur128_hash (const guint8 *in, gsize len, guint64 out[]);
-
-/**
* Deep copy of one hash table to another
* @param src source hash
* @param dst destination hash