1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-06 02:23:03 +00:00

Fix NaNboxing bug that cause flaky builds.

The macro janet_checktype(x, JANET_NUMBER) was incorrect when
x was NaN. This caused the initial unmarshalling dictionary to be missing
entries in certain cases.
This commit is contained in:
Calvin Rose
2020-09-06 14:58:30 -05:00
parent 321a758ab9
commit 24b8b0e382
6 changed files with 73 additions and 67 deletions

View File

@@ -274,9 +274,9 @@ int32_t janet_hash(Janet x) {
if (sizeof(double) == sizeof(void *)) {
/* Assuming 8 byte pointer */
uint64_t i = janet_u64(x);
uint32_t lo = (uint32_t) (i & 0xFFFFFFFF);
uint32_t hi = (uint32_t) (i >> 32);
hash = (int32_t) (hi ^ (lo >> 3));
uint32_t lo = (uint32_t)(i & 0xFFFFFFFF);
uint32_t hi = (uint32_t)(i >> 32);
hash = (int32_t)(hi ^ (lo >> 3));
} else {
/* Assuming 4 byte pointer (or smaller) */
hash = (int32_t)((char *)janet_unwrap_pointer(x) - (char *)0);