Skip to content

Commit

Permalink
Add additional space to store 64-bit hash codes on 32-bit machines
Browse files Browse the repository at this point in the history
On 32-bit machines, thread local variables are stored in arrays of
32-bit chunks of memory.  But now that we use 64-bit hash codes, we
were getting the hash counter by concatenating two adjacent elements
of the array, giving us unexpected results.

We add a new thread local variable to store these extra 32 bits,
fixing this issue.
  • Loading branch information
d-torrance committed Jul 30, 2024
1 parent 4a5007d commit 7db99f9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions M2/Macaulay2/d/expr.d
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ threadCounter := 0;
threadLocal HashCounter := (
threadCounter = threadCounter + 1;
hash_t(1000000 + 3 + (threadCounter-1) * 10000 ));
-- give 32-bit machines enough space to store a 64-bit hash code
-- TODO: instead, allow 64-bit entries in the array of thread local variables
threadLocal HashCounterExtraBits := 0;

export nextHash():hash_t := (
if HashCounter == Ccode(hash_t, "18446744073709551615ull") -- check for integer overflow
Expand Down

0 comments on commit 7db99f9

Please sign in to comment.