# HG changeset patch # User Sebastien Jodogne # Date 1530888528 -7200 # Node ID 0511feaf0ec2b732b50e57da08b8d5bcbd9612c3 # Parent 5c18a22cb981c4cbe9e8da2e2d3e416c3adf9f48 fix for LSB diff -r 5c18a22cb981 -r 0511feaf0ec2 Core/Endianness.h --- a/Core/Endianness.h Fri Jul 06 16:33:03 2018 +0200 +++ b/Core/Endianness.h Fri Jul 06 16:48:48 2018 +0200 @@ -145,7 +145,13 @@ static inline uint16_t __orthanc_bswap16(uint16_t a) { - return (a << 8) | (a >> 8); + const uint8_t* p = reinterpret_cast(&a); + return (static_cast(p[0]) << 8 | + static_cast(p[1])); + + // WARNING: The implementation below makes LSB (Linux Standard + // Base) segfault in release builds. Don't use it!!! + // return (a << 8) | (a >> 8); } static inline uint32_t __orthanc_bswap32(uint32_t a)