< prev index next >
src/hotspot/share/utilities/powerOfTwo.hpp
Print this page
rev 58322 : 8240615: is_power_of_2() has Undefined Behaviour and is inconsistent
Reviewed-by: duke
*** 34,44 ****
// Power of two convenience library.
template <typename T>
bool is_power_of_2(T x) {
! return (x != T(0)) && ((x & (x - 1)) == T(0));
}
// Log2 of a power of 2
inline int exact_log2(intptr_t x) {
assert(is_power_of_2(x), "x must be a power of 2: " INTPTR_FORMAT, x);
--- 34,44 ----
// Power of two convenience library.
template <typename T>
bool is_power_of_2(T x) {
! return (x > T(0)) && ((x & (x - 1)) == T(0));
}
// Log2 of a power of 2
inline int exact_log2(intptr_t x) {
assert(is_power_of_2(x), "x must be a power of 2: " INTPTR_FORMAT, x);
< prev index next >