aboutsummaryrefslogtreecommitdiff
path: root/src/common/alignment.h
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-10-18 12:55:27 -0400
committerLioncash <mathew1800@gmail.com>2018-10-18 12:57:02 -0400
commit7784a1ca448e2c2f24e3c3af4d9eed44c3ed030d (patch)
tree9b5c2faf236744707520c788dc4cdfde68c7e045 /src/common/alignment.h
parentc08893660f1218695edb5483b914b40316aba856 (diff)
common: Move Is4KBAligned() to alignment.h
Aligning on 4KB pages isn't a Switch-specific thing, so this can be moved to common so it can be used with other things as well.
Diffstat (limited to 'src/common/alignment.h')
-rw-r--r--src/common/alignment.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h
index 225770fab3..b3f103c079 100644
--- a/src/common/alignment.h
+++ b/src/common/alignment.h
@@ -19,4 +19,10 @@ constexpr T AlignDown(T value, std::size_t size) {
return static_cast<T>(value - value % size);
}
+template <typename T>
+constexpr bool Is4KBAligned(T value) {
+ static_assert(std::is_unsigned_v<T>, "T must be an unsigned value.");
+ return (value & 0xFFF) == 0;
+}
+
} // namespace Common