t: avoid perl's pack/unpack "Q" specifier
commit4815c3c4b26a91301c51360297ebfdef3b96a4ce
authorJeff King <peff@peff.net>
Fri, 3 Nov 2023 16:20:19 +0000 (3 12:20 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sat, 4 Nov 2023 06:54:25 +0000 (4 15:54 +0900)
tree4dbca860958d9f3a96cff3b79c22e1f3063af664
parent7538f9d89b001be33a1b682b5cf207c4ba8fd8c5
t: avoid perl's pack/unpack "Q" specifier

The perl script introduced by 86b008ee61 (t: add library for munging
chunk-format files, 2023-10-09) uses pack("Q") and unpack("Q") to read
and write 64-bit values ("quadwords" in perl parlance) from the on-disk
chunk files. However, some builds of perl may not support 64-bit
integers at all, and throw an exception here. While some 32-bit
platforms may still support 64-bit integers in perl (such as our linux32
CI environment), others reportedly don't (the NonStop 32-bit builds).

We can work around this by treating the 64-bit values as two 32-bit
values. We can't ever combine them into a single 64-bit value, but in
practice this is OK. These are representing file offsets, and our files
are much smaller than 4GB. So the upper half of the 64-bit value will
always be 0.

We can just introduce a few helper functions which perform the
translation and double-check our assumptions.

Reported-by: Randall S. Becker <randall.becker@nexbridge.ca>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/lib-chunk/corrupt-chunk-file.pl