Returns 'value' rounded up to the nearest multiple of 'factor' when factor is a power of two. The result is undefined on overflow, i.e. if `value > 2**64 - factor`, since we cannot return the correct result which would be 2**64.
| 102 | // The result is undefined on overflow, i.e. if `value > 2**64 - factor`, |
| 103 | // since we cannot return the correct result which would be 2**64. |
| 104 | constexpr int64_t RoundUpToPowerOf2(int64_t value, int64_t factor) { |
| 105 | return (value + (factor - 1)) & ~(factor - 1); |
| 106 | } |
| 107 | |
| 108 | constexpr uint64_t RoundUpToPowerOf2(uint64_t value, uint64_t factor) { |
| 109 | return (value + (factor - 1)) & ~(factor - 1); |
no outgoing calls