The technique here feels a bit hacky, but it's the common way to do it.
We exploit the fact that ints are 16bits and chars are 8bits to grab the
first byte in a systems int representation, which is indicative of its
endianness.
The binary module implements functions for interpreting byte sequences
as int16, int32, or int64 values depending on a given endianess (the
Byte module implements support for interpreting bytes as int8 values).
It'd be nice if we could implement these functions in pure Carp, using
the Bytes module--but unfortunately we need to rely on some type
conversions in C, which are only possible by registering C functions for
performing the necessary conversions.
At the moment, all of these functions are unsafe (they access byte
arrays using unsafe-nth).