| Index: src/utils.h
|
| ===================================================================
|
| --- src/utils.h (revision 10555)
|
| +++ src/utils.h (working copy)
|
| @@ -153,11 +153,9 @@
|
| }
|
|
|
|
|
| -// Returns the smallest power of two which is >= x. If you pass in a
|
| -// number that is already a power of two, it is returned as is.
|
| -// Implementation is from "Hacker's Delight" by Henry S. Warren, Jr.,
|
| -// figure 3-3, page 48, where the function is called clp2.
|
| -inline uint32_t RoundUpToPowerOf2(uint32_t x) {
|
| +template<typename int_type>
|
| +inline int RoundUpToPowerOf2(int_type x_argument) {
|
| + uintptr_t x = static_cast<uintptr_t>(x_argument);
|
| ASSERT(x <= 0x80000000u);
|
| x = x - 1;
|
| x = x | (x >> 1);
|
| @@ -165,7 +163,7 @@
|
| x = x | (x >> 4);
|
| x = x | (x >> 8);
|
| x = x | (x >> 16);
|
| - return x + 1;
|
| + return static_cast<int_type>(x + 1);
|
| }
|
|
|
|
|
|
|