Skip to content
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

Add additional space to store 64-bit hash codes on 32-bit machines #3359

Merged
merged 2 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
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
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
2 changes: 1 addition & 1 deletion M2/Macaulay2/m2/basictests/hashcodes.m2
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ assert( (hash true) === 444777 )
assert( (hash false) === 777333 )

-- these might change if our floating point implementation changes, but let's check anyway:
assert( hash 1.23p200 === 18446744072207201388 -* big endian *- or hash 1.23p200 == -640232547 -* little endian *- )
assert( hash 1.23p200 === 18446744072207201388 -* 64-bit *- or hash 1.23p200 == 18446744073069319069 -* 32-bit *- )

-- Local Variables:
-- compile-command: "make -C $M2BUILDDIR/Macaulay2/packages/Macaulay2Doc/basictests hashcodes.okay"
Expand Down