summaryrefslogtreecommitdiffstats
path: root/src/common/alignment.h
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-08-12 21:18:55 +0200
committerLiam <byteslice@airmail.cc>2023-08-15 23:47:40 +0200
commit50eee9b2185c59c32fb82cf464230a058edd10ea (patch)
treebeebc2d0da1fa0678a067de9c12cb7d11c775748 /src/common/alignment.h
parentfssystem: reduce overalignment of unbuffered storage operations (diff)
downloadyuzu-50eee9b2185c59c32fb82cf464230a058edd10ea.tar
yuzu-50eee9b2185c59c32fb82cf464230a058edd10ea.tar.gz
yuzu-50eee9b2185c59c32fb82cf464230a058edd10ea.tar.bz2
yuzu-50eee9b2185c59c32fb82cf464230a058edd10ea.tar.lz
yuzu-50eee9b2185c59c32fb82cf464230a058edd10ea.tar.xz
yuzu-50eee9b2185c59c32fb82cf464230a058edd10ea.tar.zst
yuzu-50eee9b2185c59c32fb82cf464230a058edd10ea.zip
Diffstat (limited to 'src/common/alignment.h')
-rw-r--r--src/common/alignment.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h
index 0057052af..fc5c26898 100644
--- a/src/common/alignment.h
+++ b/src/common/alignment.h
@@ -12,7 +12,9 @@ namespace Common {
template <typename T>
requires std::is_integral_v<T>
-[[nodiscard]] constexpr T AlignUp(T value, size_t size) {
+[[nodiscard]] constexpr T AlignUp(T value_, size_t size) {
+ using U = typename std::make_unsigned_t<T>;
+ auto value{static_cast<U>(value_)};
auto mod{static_cast<T>(value % size)};
value -= mod;
return static_cast<T>(mod == T{0} ? value : value + size);
@@ -26,7 +28,9 @@ template <typename T>
template <typename T>
requires std::is_integral_v<T>
-[[nodiscard]] constexpr T AlignDown(T value, size_t size) {
+[[nodiscard]] constexpr T AlignDown(T value_, size_t size) {
+ using U = typename std::make_unsigned_t<T>;
+ const auto value{static_cast<U>(value_)};
return static_cast<T>(value - value % size);
}