diff --git a/src/WireDecoder.cpp b/src/WireDecoder.cpp index c4d4bfcf10..1e7d32a7f4 100644 --- a/src/WireDecoder.cpp +++ b/src/WireDecoder.cpp @@ -12,6 +12,7 @@ #include #include +#include "llvm/MathExtras.h" #include "leb128.h" using namespace nt; @@ -41,7 +42,7 @@ static double ReadDouble(const char*& buf) { val <<= 8; val |= (*((unsigned char*)buf)) & 0xff; ++buf; - return reinterpret_cast(val); + return llvm::BitsToDouble(val); } WireDecoder::WireDecoder(raw_istream& is, unsigned int proto_rev) : m_is(is) { diff --git a/src/WireEncoder.cpp b/src/WireEncoder.cpp index 3066a6aaa7..102c6ae88f 100644 --- a/src/WireEncoder.cpp +++ b/src/WireEncoder.cpp @@ -12,6 +12,7 @@ #include #include +#include "llvm/MathExtras.h" #include "leb128.h" using namespace nt; @@ -30,7 +31,7 @@ WireEncoder::~WireEncoder() { std::free(m_start); } void WireEncoder::WriteDouble(double val) { Reserve(8); // The highest performance way to do this, albeit non-portable. - std::uint64_t v = reinterpret_cast(val); + std::uint64_t v = llvm::DoubleToBits(val); m_cur[7] = (char)(v & 0xff); v >>= 8; m_cur[6] = (char)(v & 0xff); v >>= 8; m_cur[5] = (char)(v & 0xff); v >>= 8;