Mercurial > hg > orthanc
comparison Core/Endianness.h @ 2708:83c991aeb611 jobs
integration mainline->jobs
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Jul 2018 08:18:22 +0200 |
parents | 38a3054b22ff |
children | 6356e2ceb493 |
comparison
equal
deleted
inserted
replaced
2701:33de4a82c466 | 2708:83c991aeb611 |
---|---|
143 | 143 |
144 #include <stdint.h> | 144 #include <stdint.h> |
145 | 145 |
146 static inline uint16_t __orthanc_bswap16(uint16_t a) | 146 static inline uint16_t __orthanc_bswap16(uint16_t a) |
147 { | 147 { |
148 return (a << 8) | (a >> 8); | 148 const uint8_t* p = reinterpret_cast<const uint8_t*>(&a); |
149 return (static_cast<uint16_t>(p[0]) << 8 | | |
150 static_cast<uint16_t>(p[1])); | |
151 | |
152 // WARNING: The implementation below makes LSB (Linux Standard | |
153 // Base) segfault in release builds. Don't use it!!! | |
154 // return (a << 8) | (a >> 8); | |
149 } | 155 } |
150 | 156 |
151 static inline uint32_t __orthanc_bswap32(uint32_t a) | 157 static inline uint32_t __orthanc_bswap32(uint32_t a) |
152 { | 158 { |
153 const uint8_t* p = reinterpret_cast<const uint8_t*>(&a); | 159 const uint8_t* p = reinterpret_cast<const uint8_t*>(&a); |