From d27f4a4928f493f9e7a2987ad93e6be918b70f6c Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 18 Oct 2018 12:55:27 -0400 Subject: 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. --- src/common/alignment.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/common') diff --git a/src/common/alignment.h b/src/common/alignment.h index 225770fab..b3f103c07 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(value - value % size); } +template +constexpr bool Is4KBAligned(T value) { + static_assert(std::is_unsigned_v, "T must be an unsigned value."); + return (value & 0xFFF) == 0; +} + } // namespace Common -- cgit v1.2.3