mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-05-28 10:42:10 -04:00
reuse a single size alignment implementation
This commit is contained in:
parent
e814cf4f5c
commit
536f852538
4 changed files with 20 additions and 13 deletions
7
pages.h
7
pages.h
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue