diff options
author | Jack Lloyd <[email protected]> | 2018-12-31 11:19:42 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2018-12-31 11:19:42 -0500 |
commit | 97fc7dcf2c76df21bbd14f06224465fa6820fa69 (patch) | |
tree | 0fa0e2a43c1736118c27df419571c9729754928c /src/lib/utils/bswap.h | |
parent | 089e9887c9730fcb888561e1d63eae610cf0f6b4 (diff) |
Fix generic 32-bit bswap
Was broken by removing inclusion of rotate header
Diffstat (limited to 'src/lib/utils/bswap.h')
-rw-r--r-- | src/lib/utils/bswap.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/utils/bswap.h b/src/lib/utils/bswap.h index 03bebfefa..b6238d1e7 100644 --- a/src/lib/utils/bswap.h +++ b/src/lib/utils/bswap.h @@ -47,10 +47,14 @@ inline uint32_t reverse_bytes(uint32_t val) return val; #else - // Generic implementation - return (rotr<8>(val) & 0xFF00FF00) | (rotl<8>(val) & 0x00FF00FF); + uint16_t hi = static_cast<uint16_t>(val >> 16); + uint16_t lo = static_cast<uint16_t>(val); + + hi = reverse_bytes(hi); + lo = reverse_bytes(lo); + return (static_cast<uint32_t>(lo) << 16) | hi; #endif } |