Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: third_party/grpc/src/core/support/murmur_hash.c

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/grpc/src/core/support/murmur_hash.h ('k') | third_party/grpc/src/core/support/slice.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/grpc/src/core/support/murmur_hash.c
diff --git a/third_party/WebKit/Source/bindings/core/v8/custom/V8MediaQueryListCustom.cpp b/third_party/grpc/src/core/support/murmur_hash.c
similarity index 53%
copy from third_party/WebKit/Source/bindings/core/v8/custom/V8MediaQueryListCustom.cpp
copy to third_party/grpc/src/core/support/murmur_hash.c
index 69823d633e864f0309cd4851c71ace7cb80d0b25..a5261c0cc04360ca57095e3c2379cdb82ae0c090 100644
--- a/third_party/WebKit/Source/bindings/core/v8/custom/V8MediaQueryListCustom.cpp
+++ b/third_party/grpc/src/core/support/murmur_hash.c
@@ -1,5 +1,7 @@
/*
- * Copyright (C) 2015 Google Inc. All rights reserved.
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -26,22 +28,69 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
*/
-#include "bindings/core/v8/V8MediaQueryList.h"
+#include "src/core/support/murmur_hash.h"
-namespace blink {
+#define ROTL32(x, r) ((x) << (r)) | ((x) >> (32 - (r)))
-void V8MediaQueryList::addListenerMethodEpilogueCustom(const v8::FunctionCallbackInfo<v8::Value>& info, MediaQueryList* impl)
-{
- if (info.Length() >= 1 && info[0]->IsObject() && !impl->toNode())
- addHiddenValueToArray(info.GetIsolate(), info.Holder(), info[0], V8EventTarget::eventListenerCacheIndex);
-}
+#define FMIX32(h) \
+ (h) ^= (h) >> 16; \
+ (h) *= 0x85ebca6b; \
+ (h) ^= (h) >> 13; \
+ (h) *= 0xc2b2ae35; \
+ (h) ^= (h) >> 16;
-void V8MediaQueryList::removeListenerMethodEpilogueCustom(const v8::FunctionCallbackInfo<v8::Value>& info, MediaQueryList* impl)
-{
- if (info.Length() >= 1 && info[0]->IsObject() && !impl->toNode())
- removeHiddenValueFromArray(info.GetIsolate(), info.Holder(), info[0], V8EventTarget::eventListenerCacheIndex);
-}
+/* Block read - if your platform needs to do endian-swapping or can only
+ handle aligned reads, do the conversion here */
+#define GETBLOCK32(p, i) (p)[(i)]
+
+uint32_t gpr_murmur_hash3(const void *key, size_t len, uint32_t seed) {
+ const uint8_t *data = (const uint8_t *)key;
+ const size_t nblocks = len / 4;
+ int i;
+
+ uint32_t h1 = seed;
+ uint32_t k1;
+
+ const uint32_t c1 = 0xcc9e2d51;
+ const uint32_t c2 = 0x1b873593;
-} // namespace blink
+ const uint32_t *blocks = ((const uint32_t *)key) + nblocks;
+ const uint8_t *tail = (const uint8_t *)(data + nblocks * 4);
+
+ /* body */
+ for (i = -(int)nblocks; i; i++) {
+ k1 = GETBLOCK32(blocks, i);
+
+ k1 *= c1;
+ k1 = ROTL32(k1, 15);
+ k1 *= c2;
+
+ h1 ^= k1;
+ h1 = ROTL32(h1, 13);
+ h1 = h1 * 5 + 0xe6546b64;
+ }
+
+ k1 = 0;
+
+ /* tail */
+ switch (len & 3) {
+ case 3:
+ k1 ^= ((uint32_t)tail[2]) << 16;
+ case 2:
+ k1 ^= ((uint32_t)tail[1]) << 8;
+ case 1:
+ k1 ^= tail[0];
+ k1 *= c1;
+ k1 = ROTL32(k1, 15);
+ k1 *= c2;
+ h1 ^= k1;
+ };
+
+ /* finalization */
+ h1 ^= (uint32_t)len;
+ FMIX32(h1);
+ return h1;
+}
« no previous file with comments | « third_party/grpc/src/core/support/murmur_hash.h ('k') | third_party/grpc/src/core/support/slice.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698