diff options
author | lloyd <[email protected]> | 2008-03-09 05:35:48 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-03-09 05:35:48 +0000 |
commit | 478710c5f35dabcb81a4ae2c26052b68606570ed (patch) | |
tree | 9df0bce2f80a245c1d30d364f3e3b419bfb43eaa | |
parent | 9f63fc79701df7e6b659908f5f8ae7efba7c7720 (diff) |
Alas, my definition of the new improved reverse_bytes for 64-bit values was
wrong, and didn't work at all. New corrected (and tested) version.
-rw-r--r-- | include/bit_ops.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/include/bit_ops.h b/include/bit_ops.h index ec46dbf43..7081ee3e5 100644 --- a/include/bit_ops.h +++ b/include/bit_ops.h @@ -39,8 +39,11 @@ inline u32bit reverse_bytes(u32bit input) inline u64bit reverse_bytes(u64bit input) { - return rotate_left(static_cast<u32bit>(input ), 16) | - rotate_left(static_cast<u32bit>(input >> 32), 16); + u32bit hi = ((input >> 40) & 0x00FF00FF) | ((input >> 24) & 0xFF00FF00); + u32bit lo = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8); + hi = (hi << 16) | (hi >> 16); + lo = (lo << 16) | (lo >> 16); + return (static_cast<u64bit>(lo) << 32) | hi; } /************************************************* |