mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-07-27 09:05:21 -04:00
split out code for managing page spans
This commit is contained in:
parent
e93d039214
commit
e4648192c0
4 changed files with 104 additions and 83 deletions
16
pages.h
Normal file
16
pages.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef PAGES_H
|
||||
#define PAGES_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define PAGE_SHIFT 12
|
||||
#define PAGE_SIZE ((size_t)1 << PAGE_SHIFT)
|
||||
#define PAGE_MASK ((size_t)(PAGE_SIZE - 1))
|
||||
#define PAGE_CEILING(s) (((s) + PAGE_MASK) & ~PAGE_MASK)
|
||||
|
||||
void *allocate_pages(size_t usable_size, size_t guard_size, bool unprotect);
|
||||
void deallocate_pages(void *usable, size_t usable_size, size_t guard_size);
|
||||
void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_size);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue