Signed-off-by: Timmons C. Player <[email protected]>
---
include/osv/align.hh | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/include/osv/align.hh b/include/osv/align.hh
index 9292ff8..05bff5c 100644
--- a/include/osv/align.hh
+++ b/include/osv/align.hh
@@ -25,6 +25,13 @@ T align_up(T n, T alignment)
return align_down(n + alignment - 1, alignment);
}
+template <typename T>
+inline
+bool align_check(T n, T alignment)
+{
+ return align_down(n, alignment) == n;
+}
+
template <class T>
inline
T* align_down(T* ptr, size_t alignment)
@@ -43,4 +50,11 @@ T* align_up(T* ptr, size_t alignment)
return reinterpret_cast<T*>(n);
}
+template <class T>
+inline
+bool align_check(T* ptr, size_t alignment)
+{
+ auto n = reinterpret_cast<uintptr_t>(ptr);
+ return align_down(n, alignment) == n;
+}
#endif
--
2.7.4
--
You received this message because you are subscribed to the Google Groups "OSv
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.