-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
919 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
zlib License | ||
|
||
(C) Copyright 2018 Molly Rocket, Inc. | ||
|
||
This software is provided 'as-is', without any express or implied | ||
warranty. In no event will the authors be held liable for any damages | ||
arising from the use of this software. | ||
|
||
Permission is granted to anyone to use this software for any purpose, | ||
including commercial applications, and to alter it and redistribute it | ||
freely, subject to the following restrictions: | ||
|
||
1. The origin of this software must not be misrepresented; you must not | ||
claim that you wrote the original software. If you use this software | ||
in a product, an acknowledgment in the product documentation would be | ||
appreciated but is not required. | ||
2. Altered source versions must be plainly marked as such, and must not be | ||
misrepresented as being the original software. | ||
3. This notice may not be removed or altered from any source distribution. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "hash-impl.hpp" | ||
#if FM_HASH_HAVE_MEOWHASH | ||
#include "meow_hash_x64_aesni.h" | ||
#include "compat/assert.hpp" | ||
|
||
#ifdef __GNUG__ | ||
#pragma GCC diagnostic ignored "-Wsign-conversion" | ||
#pragma GCC diagnostic ignored "-Wunused-macros" | ||
#endif | ||
|
||
#define fm_MeowU64From(A, I) (*(meow_u64 *)&(A) + (I)) | ||
|
||
namespace floormat::meow_hash { | ||
namespace { | ||
|
||
CORRADE_ALWAYS_INLINE size_t hash(void* __restrict buf, size_t size) | ||
{ | ||
#ifndef fm_NO_DEBUG | ||
if (size % 16 != 0) [[unlikely]] | ||
fm_abort("size %zu %% 16 == %zu", size, size % 16); | ||
#endif | ||
meow_u128 hash = MeowHash(MeowDefaultSeed, size, buf); | ||
if constexpr(sizeof nullptr > 4) | ||
return fm_MeowU64From(hash, 0); | ||
else | ||
return MeowU32From(hash, 0); | ||
} | ||
|
||
} // namespace | ||
|
||
size_t hash_buf(const void* __restrict buf, size_t size) noexcept | ||
{ | ||
return hash(const_cast<void*>(buf), size); | ||
} | ||
|
||
size_t hash_int(uint32_t x) noexcept | ||
{ | ||
return hash(&x, sizeof x); | ||
} | ||
|
||
size_t hash_int(uint64_t x) noexcept | ||
{ | ||
return hash(&x, sizeof x); | ||
} | ||
|
||
} // namespace floormat::meow_hash | ||
|
||
#endif |
Oops, something went wrong.