Index: runtime/platform/utils.h |
=================================================================== |
--- runtime/platform/utils.h (revision 3410) |
+++ runtime/platform/utils.h (working copy) |
@@ -86,22 +86,25 @@ |
static uint32_t WordHash(word key); |
// Check whether an N-bit two's-complement representation can hold value. |
- static inline bool IsInt(int N, word value) { |
- ASSERT((0 < N) && (N < kBitsPerWord)); |
+ template<typename T> |
+ static inline bool IsInt(int N, T value) { |
+ ASSERT((0 < N) && (N < (kBitsPerByte * sizeof(T)))); |
Ivan Posva
2012/01/18 20:05:22
sizeof(value) is closer to the style guide: http:/
regis
2012/01/18 21:50:12
Done.
|
word limit = static_cast<word>(1) << (N - 1); |
Ivan Posva
2012/01/18 20:05:22
You need to cast the 1 to T instead of word here.
regis
2012/01/18 21:50:12
The cast is fixed in patch 5.
I have added a test.
|
return (-limit <= value) && (value < limit); |
} |
- static inline bool IsUint(int N, word value) { |
- ASSERT((0 < N) && (N < kBitsPerWord)); |
+ template<typename T> |
Ivan Posva
2012/01/18 20:05:22
ditto
regis
2012/01/18 21:50:12
Done.
|
+ static inline bool IsUint(int N, T value) { |
+ ASSERT((0 < N) && (N < (kBitsPerByte * sizeof(T)))); |
word limit = static_cast<word>(1) << N; |
return (0 <= value) && (value < limit); |
} |
// Check whether the magnitude of value fits in N bits, i.e., whether an |
// (N+1)-bit sign-magnitude representation can hold value. |
- static inline bool IsAbsoluteUint(int N, word value) { |
- ASSERT((0 < N) && (N < kBitsPerWord)); |
+ template<typename T> |
Ivan Posva
2012/01/18 20:05:22
ditto
regis
2012/01/18 21:50:12
Done.
|
+ static inline bool IsAbsoluteUint(int N, T value) { |
+ ASSERT((0 < N) && (N < (kBitsPerByte * sizeof(T)))); |
if (value < 0) value = -value; |
return IsUint(N, value); |
} |