reuse a single size alignment implementation

This commit is contained in:
Daniel Micay 2022-01-16 14:41:46 -05:00
parent e814cf4f5c
commit 536f852538
4 changed files with 20 additions and 13 deletions

View file

@ -5,11 +5,16 @@
#include <stddef.h>
#include <stdint.h>
#include "util.h"
#define PAGE_SHIFT 12
#ifndef PAGE_SIZE
#define PAGE_SIZE ((size_t)1 << PAGE_SHIFT)
#endif
#define PAGE_CEILING(s) (((s) + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
static inline size_t page_align(size_t size) {
return align(size, PAGE_SIZE);
}
void *allocate_pages(size_t usable_size, size_t guard_size, bool unprotect, const char *name);
void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_size, const char *name);