]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/util/murmurhash.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / rocksdb / util / murmurhash.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
5 //
6 /*
7 Murmurhash from http://sites.google.com/site/murmurhash/
8
9 All code is released to the public domain. For business purposes, Murmurhash is
10 under the MIT license.
11 */
12 #pragma once
13 #include <stdint.h>
14 #include "rocksdb/slice.h"
15
16 #if defined(__x86_64__)
17 #define MURMUR_HASH MurmurHash64A
18 uint64_t MurmurHash64A ( const void * key, int len, unsigned int seed );
19 #define MurmurHash MurmurHash64A
20 typedef uint64_t murmur_t;
21
22 #elif defined(__i386__)
23 #define MURMUR_HASH MurmurHash2
24 unsigned int MurmurHash2 ( const void * key, int len, unsigned int seed );
25 #define MurmurHash MurmurHash2
26 typedef unsigned int murmur_t;
27
28 #else
29 #define MURMUR_HASH MurmurHashNeutral2
30 unsigned int MurmurHashNeutral2 ( const void * key, int len, unsigned int seed );
31 #define MurmurHash MurmurHashNeutral2
32 typedef unsigned int murmur_t;
33 #endif
34
35 // Allow slice to be hashable by murmur hash.
36 namespace rocksdb {
37 struct murmur_hash {
38 size_t operator()(const Slice& slice) const {
39 return MurmurHash(slice.data(), static_cast<int>(slice.size()), 0);
40 }
41 };
42 } // rocksdb