aboutsummaryrefslogtreecommitdiffstats
path: root/include/bit_ops.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/bit_ops.h')
-rw-r--r--include/bit_ops.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/include/bit_ops.h b/include/bit_ops.h
index 3576f8ce1..d0fb03d1f 100644
--- a/include/bit_ops.h
+++ b/include/bit_ops.h
@@ -24,11 +24,24 @@ template<typename T> inline T rotate_right(T input, u32bit rot)
}
/*************************************************
-* Byteswap *
+* Byte Swapping Functions *
*************************************************/
-u16bit reverse_bytes(u16bit);
-u32bit reverse_bytes(u32bit);
-u64bit reverse_bytes(u64bit);
+inline u16bit reverse_bytes(u16bit input)
+ {
+ return rotate_left(input, 8);
+ }
+
+inline u32bit reverse_bytes(u32bit input)
+ {
+ input = ((input & 0xFF00FF00) >> 8) | ((input & 0x00FF00FF) << 8);
+ return rotate_left(input, 16);
+ }
+
+inline u64bit reverse_bytes(u64bit input)
+ {
+ return rotate_left(static_cast<u32bit>(input ), 16) |
+ rotate_left(static_cast<u32bit>(input >> 32), 16);
+ }
/*************************************************
* Array XOR *