1 //===-- sanitizer_common.h --------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements a simple hash function.
10 //===----------------------------------------------------------------------===//
12 #ifndef SANITIZER_HASH_H
13 #define SANITIZER_HASH_H
15 #include "sanitizer_internal_defs.h"
17 namespace __sanitizer
{
18 class MurMur2HashBuilder
{
19 static const u32 m
= 0x5bd1e995;
20 static const u32 seed
= 0x9747b28c;
21 static const u32 r
= 24;
25 explicit MurMur2HashBuilder(u32 init
= 0) { h
= seed
^ init
; }
42 class MurMur2Hash64Builder
{
43 static const u64 m
= 0xc6a4a7935bd1e995ull
;
44 static const u64 seed
= 0x9747b28c9747b28cull
;
45 static const u64 r
= 47;
49 explicit MurMur2Hash64Builder(u64 init
= 0) { h
= seed
^ (init
* m
); }
65 } // namespace __sanitizer
67 #endif // SANITIZER_HASH_H