macro: introduce several helper functions for alignment
Some of them are not used in this commit, but will be used later.
This commit is contained in:
@@ -12,9 +12,12 @@
|
||||
#include "memory-util-fundamental.h"
|
||||
|
||||
size_t page_size(void) _pure_;
|
||||
#define PAGE_ALIGN(l) ALIGN_TO((l), page_size())
|
||||
#define PAGE_ALIGN_DOWN(l) ((l) & ~(page_size() - 1))
|
||||
#define PAGE_OFFSET(l) ((l) & (page_size() - 1))
|
||||
#define PAGE_ALIGN(l) ALIGN_TO(l, page_size())
|
||||
#define PAGE_ALIGN_U64(l) ALIGN_TO_U64(l, page_size())
|
||||
#define PAGE_ALIGN_DOWN(l) ALIGN_DOWN(l, page_size())
|
||||
#define PAGE_ALIGN_DOWN_U64(l) ALIGN_DOWN_U64(l, page_size())
|
||||
#define PAGE_OFFSET(l) ALIGN_OFFSET(l, page_size())
|
||||
#define PAGE_OFFSET_U64(l) ALIGN_OFFSET_U64(l, page_size())
|
||||
|
||||
/* 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) {
|
||||
|
||||
Reference in New Issue
Block a user