Skip to content

Commit 83d72bd

Browse files
authored
Merge pull request #44 from rhpvorderman/windowsdebug
Fix inline error in msvc
2 parents a5c39ad + d3ecbaf commit 83d72bd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/sequali/wanghash.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
// Thomas Wang's integer hash functions and inverse
44
// See https://naml.us/post/inverse-of-a-hash-function/
55

6-
static uint64_t wanghash64(uint64_t key) {
6+
/* MSVC version 2022 makes some critical inline errors for the inverse hash
7+
function */
8+
#ifdef _MSC_VER
9+
#define noinline __declspec(noinline)
10+
#else
11+
#define noinline
12+
#endif
13+
14+
static noinline uint64_t wanghash64(uint64_t key) {
715
key = (~key) + (key << 21); // key = (key << 21) - key - 1;
816
key = key ^ (key >> 24);
917
key = (key + (key << 3)) + (key << 8); // key * 265
@@ -15,7 +23,7 @@ static uint64_t wanghash64(uint64_t key) {
1523
}
1624

1725

18-
static uint64_t wanghash64_inverse(uint64_t key) {
26+
static noinline uint64_t wanghash64_inverse(uint64_t key) {
1927
uint64_t tmp;
2028

2129
// Invert key = key + (key << 31)

0 commit comments

Comments
 (0)