Index: src/base/bits.h |
diff --git a/src/base/bits.h b/src/base/bits.h |
index 0f4d4c712becc540dd767291b1766b12c526a09e..5c7cd74c610d5f8f59b21214d888d2b284825935 100644 |
--- a/src/base/bits.h |
+++ b/src/base/bits.h |
@@ -148,17 +148,30 @@ inline uint32_t RoundDownToPowerOfTwo32(uint32_t value) { |
} |
+// Precondition: 0 <= shift < 32 |
hans
2015/03/04 06:02:51
Any reason the preconditions are not some kind of
Nico
2015/03/04 06:21:10
I was worried that this might be performance-criti
|
inline uint32_t RotateRight32(uint32_t value, uint32_t shift) { |
if (shift == 0) return value; |
return (value >> shift) | (value << (32 - shift)); |
} |
+// Precondition: 0 <= shift < 32 |
+inline uint32_t RotateLeft32(uint32_t value, uint32_t shift) { |
+ if (shift == 0) return value; |
+ return (value << shift) | (value >> (32 - shift)); |
+} |
+// Precondition: 0 <= shift < 64 |
inline uint64_t RotateRight64(uint64_t value, uint64_t shift) { |
if (shift == 0) return value; |
return (value >> shift) | (value << (64 - shift)); |
} |
+// Precondition: 0 <= shift < 64 |
+inline uint64_t RotateLeft64(uint64_t value, uint64_t shift) { |
+ if (shift == 0) return value; |
+ return (value << shift) | (value >> (64 - shift)); |
+} |
+ |
// SignedAddOverflow32(lhs,rhs,val) performs a signed summation of |lhs| and |
// |rhs| and stores the result into the variable pointed to by |val| and |