summaryrefslogtreecommitdiff
path: root/src/common/bit_util.h
diff options
context:
space:
mode:
authorGravatar Feng Chen2021-12-18 13:57:14 +0800
committerGravatar GitHub2021-12-18 13:57:14 +0800
commite49184e6069a9d791d2df3c1958f5c4b1187e124 (patch)
treeb776caf722e0be0e680f67b0ad0842628162ef1c /src/common/bit_util.h
parentImplement convert legacy to generic (diff)
parentMerge pull request #7570 from ameerj/favorites-expanded (diff)
downloadyuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.tar.gz
yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.tar.xz
yuzu-e49184e6069a9d791d2df3c1958f5c4b1187e124.zip
Merge branch 'yuzu-emu:master' into convert_legacy
Diffstat (limited to 'src/common/bit_util.h')
-rw-r--r--src/common/bit_util.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common/bit_util.h b/src/common/bit_util.h
index 64520ca4e..eef8c1c5a 100644
--- a/src/common/bit_util.h
+++ b/src/common/bit_util.h
@@ -7,6 +7,7 @@
7#include <bit> 7#include <bit>
8#include <climits> 8#include <climits>
9#include <cstddef> 9#include <cstddef>
10#include <type_traits>
10 11
11#include "common/common_types.h" 12#include "common/common_types.h"
12 13
@@ -44,4 +45,10 @@ template <typename T>
44 return static_cast<u32>(log2_f + static_cast<u64>((value ^ (1ULL << log2_f)) != 0ULL)); 45 return static_cast<u32>(log2_f + static_cast<u64>((value ^ (1ULL << log2_f)) != 0ULL));
45} 46}
46 47
48template <typename T>
49requires std::is_integral_v<T>
50[[nodiscard]] T NextPow2(T value) {
51 return static_cast<T>(1ULL << ((8U * sizeof(T)) - std::countl_zero(value - 1U)));
52}
53
47} // namespace Common 54} // namespace Common