Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2011-04-15 14:59:24 +0400
committerIgor Sysoev <igor@sysoev.ru>2011-04-15 14:59:24 +0400
commit42f1e1cb96b510d1fa1abad99a5294a37b750d99 (patch)
tree1726743418ae2546c84419f7bd22f603557f2409 /src/core/ngx_murmurhash.c
parent0bd0b2894c6f2514e53b940f6d64cbe5198a4d6c (diff)
ngx_murmur_hash2()
Diffstat (limited to 'src/core/ngx_murmurhash.c')
-rw-r--r--src/core/ngx_murmurhash.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/core/ngx_murmurhash.c b/src/core/ngx_murmurhash.c
new file mode 100644
index 000000000..c31e0e035
--- /dev/null
+++ b/src/core/ngx_murmurhash.c
@@ -0,0 +1,50 @@
+
+/*
+ * Copyright (C) Austin Appleby
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+
+uint32_t
+ngx_murmur_hash2(u_char *data, size_t len)
+{
+ uint32_t h, k;
+
+ h = 0 ^ len;
+
+ while (len >= 4) {
+ k = data[0];
+ k |= data[1] << 8;
+ k |= data[2] << 16;
+ k |= data[3] << 24;
+
+ k *= 0x5bd1e995;
+ k ^= k >> 24;
+ k *= 0x5bd1e995;
+
+ h *= 0x5bd1e995;
+ h ^= k;
+
+ data += 4;
+ len -= 4;
+ }
+
+ switch (len) {
+ case 3:
+ h ^= data[2] << 16;
+ case 2:
+ h ^= data[1] << 8;
+ case 1:
+ h ^= data[0];
+ h *= 0x5bd1e995;
+ }
+
+ h ^= h >> 13;
+ h *= 0x5bd1e995;
+ h ^= h >> 15;
+
+ return h;
+}