summaryrefslogtreecommitdiff
path: root/src/common/alignment.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-04-17 16:33:08 -0400
committerGitHub <noreply@github.com>2020-04-17 16:33:08 -0400
commitb8f5c71f2d7f819821acf036175cce65ab1ae12c (patch)
tree151d7ed4e47536dc0e149a7117387b6a502d7da6 /src/common/alignment.h
parentca3af2961c5fcda9d3ef4938505bd148856e8176 (diff)
parent8bbe74a8dc62cd3933fd08237e707b0059fe8a78 (diff)
Merge pull request #3666 from bunnei/new-vmm
Implement a new virtual memory manager
Diffstat (limited to 'src/common/alignment.h')
-rw-r--r--src/common/alignment.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h
index cdd4833f8..f8c49e079 100644
--- a/src/common/alignment.h
+++ b/src/common/alignment.h
@@ -38,6 +38,13 @@ constexpr bool IsWordAligned(T value) {
return (value & 0b11) == 0;
}
+template <typename T>
+constexpr bool IsAligned(T value, std::size_t alignment) {
+ using U = typename std::make_unsigned<T>::type;
+ const U mask = static_cast<U>(alignment - 1);
+ return (value & mask) == 0;
+}
+
template <typename T, std::size_t Align = 16>
class AlignmentAllocator {
public: