1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-29 21:50:58 +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

@ -506,6 +506,17 @@ std::optional<N> string2Float(const std::string_view s)
}
/* Convert a little-endian integer to host order. */
template<typename T>
T readLittleEndian(unsigned char * p)
{
T x = 0;
for (size_t i = 0; i < sizeof(x); ++i)
x |= *p++ << (i * 8);
return x;
}
/* Return true iff `s' starts with `prefix'. */
bool hasPrefix(std::string_view s, std::string_view prefix);