Skip to content

Fix inline error in msvc #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/sequali/wanghash.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
// Thomas Wang's integer hash functions and inverse
// See https://naml.us/post/inverse-of-a-hash-function/

static uint64_t wanghash64(uint64_t key) {
/* MSVC version 2022 makes some critical inline errors for the inverse hash
function */
#ifdef _MSC_VER
#define noinline __declspec(noinline)
#else
#define noinline
#endif

static noinline uint64_t wanghash64(uint64_t key) {
key = (~key) + (key << 21); // key = (key << 21) - key - 1;
key = key ^ (key >> 24);
key = (key + (key << 3)) + (key << 8); // key * 265
Expand All @@ -15,7 +23,7 @@ static uint64_t wanghash64(uint64_t key) {
}


static uint64_t wanghash64_inverse(uint64_t key) {
static noinline uint64_t wanghash64_inverse(uint64_t key) {
uint64_t tmp;

// Invert key = key + (key << 31)
Expand Down