summaryrefslogtreecommitdiff
path: root/libartbase/base/bit_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'libartbase/base/bit_utils.h')
-rw-r--r--libartbase/base/bit_utils.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/libartbase/base/bit_utils.h b/libartbase/base/bit_utils.h
index ffaffc3a30..a6986857ff 100644
--- a/libartbase/base/bit_utils.h
+++ b/libartbase/base/bit_utils.h
@@ -175,6 +175,15 @@ constexpr T RoundUp(T x, std::remove_reference_t<T> n) {
return RoundDown(x + n - 1, n);
}
+template<bool kRoundUp, typename T>
+constexpr T CondRoundUp(T x, std::remove_reference_t<T> n) {
+ if (kRoundUp) {
+ return RoundUp(x, n);
+ } else {
+ return x;
+ }
+}
+
// For aligning pointers.
template<typename T>
inline T* AlignDown(T* x, uintptr_t n) WARN_UNUSED;