diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2021-01-15 08:02:37 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2021-01-15 08:13:33 +0100 |
commit | fe494a0ccdddc8e7a7f54ca93de090100fc3fb8a (patch) | |
tree | a4c0f339d33ec9a90f15b88c4d1fada864f73adc /src/common/alignment.h | |
parent | Merge pull request #5352 from ReinUsesLisp/remove-tester (diff) | |
download | yuzu-fe494a0ccdddc8e7a7f54ca93de090100fc3fb8a.tar yuzu-fe494a0ccdddc8e7a7f54ca93de090100fc3fb8a.tar.gz yuzu-fe494a0ccdddc8e7a7f54ca93de090100fc3fb8a.tar.bz2 yuzu-fe494a0ccdddc8e7a7f54ca93de090100fc3fb8a.tar.lz yuzu-fe494a0ccdddc8e7a7f54ca93de090100fc3fb8a.tar.xz yuzu-fe494a0ccdddc8e7a7f54ca93de090100fc3fb8a.tar.zst yuzu-fe494a0ccdddc8e7a7f54ca93de090100fc3fb8a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/common/alignment.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h index 5040043de..2127dc186 100644 --- a/src/common/alignment.h +++ b/src/common/alignment.h @@ -17,15 +17,14 @@ template <typename T> } template <typename T> -[[nodiscard]] constexpr T AlignDown(T value, std::size_t size) { - static_assert(std::is_unsigned_v<T>, "T must be an unsigned value."); - return static_cast<T>(value - value % size); +requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignUpLog2(T value, size_t align_log2) { + return static_cast<T>((value + ((1ULL << align_log2) - 1)) >> align_log2 << align_log2); } template <typename T> -[[nodiscard]] constexpr T AlignBits(T value, std::size_t align) { +[[nodiscard]] constexpr T AlignDown(T value, std::size_t size) { static_assert(std::is_unsigned_v<T>, "T must be an unsigned value."); - return static_cast<T>((value + ((1ULL << align) - 1)) >> align << align); + return static_cast<T>(value - value % size); } template <typename T> |