Skip to content

VERY experimental Nintendo Switch 2 emulator

C++

common/alignment: Fix compilation errors (#4303)

Tobiasdec48c55cbc5
diff --git a/src/common/alignment.h b/src/common/alignment.h
index f8c49e0797..b37044bb60 100644
--- a/src/common/alignment.h
+++ b/src/common/alignment.h
@@ -11,7 +11,9 @@ namespace Common {
template <typename T>
constexpr T AlignUp(T value, std::size_t size) {
static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
- return static_cast<T>(value + (size - value % size) % size);
+ auto mod{static_cast<T>(value % size)};
+ value -= mod;
+ return static_cast<T>(mod == T{0} ? value : value + size);
}
template <typename T>