]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
memory-util: Add PAGE_ALIGN_DOWN
authorChris Down <chris@chrisdown.name>
Thu, 3 Oct 2019 13:41:06 +0000 (14:41 +0100)
committerChris Down <chris@chrisdown.name>
Thu, 3 Oct 2019 13:43:30 +0000 (14:43 +0100)
For example, cgroup v2 rounds down to the previous page when returning
memory limits.

src/basic/memory-util.h

index 9cb8ac3c10fcac861a76bd67262120d8eeaa804e..46a6907a0cf96baf6832e52080d75eee8144e573 100644 (file)
@@ -11,6 +11,7 @@
 
 size_t page_size(void) _pure_;
 #define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
+#define PAGE_ALIGN_DOWN(l) (l & ~(page_size() - 1))
 
 /* Normal memcpy requires src to be nonnull. We do nothing if n is 0. */
 static inline void memcpy_safe(void *dst, const void *src, size_t n) {