From 478710c5f35dabcb81a4ae2c26052b68606570ed Mon Sep 17 00:00:00 2001 From: lloyd Date: Sun, 9 Mar 2008 05:35:48 +0000 Subject: 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. --- include/bit_ops.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include/bit_ops.h') 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(input ), 16) | - rotate_left(static_cast(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(lo) << 32) | hi; } /************************************************* -- cgit v1.2.3