rewrite the endian conversion to fix a big-endian host
Client: py
Change htolell(dub) to htolell(transfer.t) in compact.h, because the
conversion takes a long long, not a double. This matters on a
big-endian host, where the conversion must swap bytes.
The big-endian letohll(n) failed because ntohl(n) is just n, doesn't
swap n. Rewrite ntohll(n) and letohll(n) to use the same code with
both big-endian and little-endian hosts. Expect the compiler to
optimize away one of ntohll(n) or letohll(n) when it doesn't swap n.
diff --git a/lib/py/src/ext/compact.h b/lib/py/src/ext/compact.h
index a78d7a7..8f72b09 100644
--- a/lib/py/src/ext/compact.h
+++ b/lib/py/src/ext/compact.h
@@ -49,7 +49,8 @@
double f;
int64_t t;
} transfer;
- transfer.f = htolell(dub);
+ transfer.f = dub;
+ transfer.t = htolell(transfer.t);
writeBuffer(reinterpret_cast<char*>(&transfer.t), sizeof(int64_t));
}