move hash_page to pages.h

pull/87/head
Daniel Micay 2019-03-25 14:54:22 -04:00
parent 13de480bde
commit 55769496dc
2 changed files with 10 additions and 9 deletions

View File

@ -784,15 +784,6 @@ static void regions_quarantine_deallocate_pages(void *p, size_t size, size_t gua
}
}
static size_t hash_page(const void *p) {
uintptr_t u = (uintptr_t)p >> PAGE_SHIFT;
size_t sum = u;
sum = (sum << 7) - sum + (u >> 16);
sum = (sum << 7) - sum + (u >> 32);
sum = (sum << 7) - sum + (u >> 48);
return sum;
}
static int regions_grow(void) {
struct region_allocator *ra = ro.region_allocator;

10
pages.h
View File

@ -3,6 +3,7 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define PAGE_SHIFT 12
#ifndef PAGE_SIZE
@ -14,4 +15,13 @@ void *allocate_pages(size_t usable_size, size_t guard_size, bool unprotect, cons
void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_size, const char *name);
void deallocate_pages(void *usable, size_t usable_size, size_t guard_size);
static inline size_t hash_page(const void *p) {
uintptr_t u = (uintptr_t)p >> PAGE_SHIFT;
size_t sum = u;
sum = (sum << 7) - sum + (u >> 16);
sum = (sum << 7) - sum + (u >> 32);
sum = (sum << 7) - sum + (u >> 48);
return sum;
}
#endif