diff options
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/Align.h | 7 | ||||
| -rw-r--r-- | Source/Core/Common/LazyMemoryRegionBitSet.cpp | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/Source/Core/Common/Align.h b/Source/Core/Common/Align.h index 994e505617..c5a4de4ccd 100644 --- a/Source/Core/Common/Align.h +++ b/Source/Core/Common/Align.h @@ -22,4 +22,11 @@ constexpr T AlignUp(T value, size_t size) return AlignDown<T>(static_cast<T>(value + (size - 1)), size); } +template <typename T> +constexpr T DivideRoundingUp(T numerator, size_t denominator) +{ + static_assert(std::is_unsigned<T>(), "T must be an unsigned value."); + return static_cast<T>((numerator + (denominator - 1)) / denominator); +} + } // namespace Common diff --git a/Source/Core/Common/LazyMemoryRegionBitSet.cpp b/Source/Core/Common/LazyMemoryRegionBitSet.cpp index af9d79c8df..89f707daa0 100644 --- a/Source/Core/Common/LazyMemoryRegionBitSet.cpp +++ b/Source/Core/Common/LazyMemoryRegionBitSet.cpp @@ -58,7 +58,7 @@ void LazyMemoryRegionBitSet::SetBits(size_t bits_start, size_t bits_end) if (bits_start % 32 != 0) m_pointer[bits_start / 32] |= extra_first_word; - const size_t start_index = Common::AlignUp(bits_start, 32) / 32; + const size_t start_index = Common::DivideRoundingUp(bits_start, 32); const size_t end_index = bits_end / 32; std::memset(m_pointer + start_index, 0xFF, (end_index - start_index) * 4); @@ -85,7 +85,7 @@ void LazyMemoryRegionBitSet::ClearBits(size_t bits_start, size_t bits_end) if (bits_start % 32 != 0) m_pointer[bits_start / 32] &= extra_first_word; - const size_t start_index = Common::AlignUp(bits_start, 32) / 32; + const size_t start_index = Common::DivideRoundingUp(bits_start, 32); const size_t end_index = bits_end / 32; std::memset(m_pointer + start_index, 0x00, (end_index - start_index) * sizeof(u32)); |
