1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-01 22:50:59 +01:00

Fix macOS build, where le32toh is not available

This commit is contained in:
Eelco Dolstra 2022-08-22 14:09:52 +02:00
parent a115c4f4b2
commit 91aea1572e
3 changed files with 15 additions and 12 deletions

View file

@ -331,17 +331,9 @@ T readNum(Source & source)
unsigned char buf[8];
source((char *) buf, sizeof(buf));
uint64_t n =
((uint64_t) buf[0]) |
((uint64_t) buf[1] << 8) |
((uint64_t) buf[2] << 16) |
((uint64_t) buf[3] << 24) |
((uint64_t) buf[4] << 32) |
((uint64_t) buf[5] << 40) |
((uint64_t) buf[6] << 48) |
((uint64_t) buf[7] << 56);
auto n = readLittleEndian<uint64_t>(buf);
if (n > (uint64_t)std::numeric_limits<T>::max())
if (n > (uint64_t) std::numeric_limits<T>::max())
throw SerialisationError("serialised integer %d is too large for type '%s'", n, typeid(T).name());
return (T) n;