summaryrefslogtreecommitdiffstats
path: root/src/common/alignment.h
diff options
context:
space:
mode:
authorameerj <52414509+ameerj@users.noreply.github.com>2021-09-24 07:21:07 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-09-24 21:52:05 +0200
commit73666fb2622a5f6a7ab9f92c9a46ce2e215c4e83 (patch)
tree31ecba073091bae2a424f3d0b6215591408edca3 /src/common/alignment.h
parentci: Update clang format version (diff)
downloadyuzu-73666fb2622a5f6a7ab9f92c9a46ce2e215c4e83.tar
yuzu-73666fb2622a5f6a7ab9f92c9a46ce2e215c4e83.tar.gz
yuzu-73666fb2622a5f6a7ab9f92c9a46ce2e215c4e83.tar.bz2
yuzu-73666fb2622a5f6a7ab9f92c9a46ce2e215c4e83.tar.lz
yuzu-73666fb2622a5f6a7ab9f92c9a46ce2e215c4e83.tar.xz
yuzu-73666fb2622a5f6a7ab9f92c9a46ce2e215c4e83.tar.zst
yuzu-73666fb2622a5f6a7ab9f92c9a46ce2e215c4e83.zip
Diffstat (limited to '')
-rw-r--r--src/common/alignment.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h
index 32d796ffa..1b56569d1 100644
--- a/src/common/alignment.h
+++ b/src/common/alignment.h
@@ -9,41 +9,48 @@
namespace Common {
template <typename T>
-requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignUp(T value, size_t size) {
+requires std::is_unsigned_v<T>
+[[nodiscard]] constexpr T AlignUp(T value, size_t size) {
auto mod{static_cast<T>(value % size)};
value -= mod;
return static_cast<T>(mod == T{0} ? value : value + size);
}
template <typename T>
-requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignUpLog2(T value, size_t align_log2) {
+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>
-requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignDown(T value, size_t size) {
+requires std::is_unsigned_v<T>
+[[nodiscard]] constexpr T AlignDown(T value, size_t size) {
return static_cast<T>(value - value % size);
}
template <typename T>
-requires std::is_unsigned_v<T>[[nodiscard]] constexpr bool Is4KBAligned(T value) {
+requires std::is_unsigned_v<T>
+[[nodiscard]] constexpr bool Is4KBAligned(T value) {
return (value & 0xFFF) == 0;
}
template <typename T>
-requires std::is_unsigned_v<T>[[nodiscard]] constexpr bool IsWordAligned(T value) {
+requires std::is_unsigned_v<T>
+[[nodiscard]] constexpr bool IsWordAligned(T value) {
return (value & 0b11) == 0;
}
template <typename T>
-requires std::is_integral_v<T>[[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) {
+requires std::is_integral_v<T>
+[[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) {
using U = typename std::make_unsigned_t<T>;
const U mask = static_cast<U>(alignment - 1);
return (value & mask) == 0;
}
template <typename T, typename U>
-requires std::is_integral_v<T>[[nodiscard]] constexpr T DivideUp(T x, U y) {
+requires std::is_integral_v<T>
+[[nodiscard]] constexpr T DivideUp(T x, U y) {
return (x + (y - 1)) / y;
}