Simplify memory manager

This commit is contained in:
Justine Tunney 2024-07-04 10:52:16 -07:00
parent 5a9a08d1cf
commit 01587de761
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
40 changed files with 451 additions and 311 deletions

View file

@ -497,18 +497,18 @@ static void *NewBoard(size_t *out_size) {
char *p;
size_t s, n, k;
s = (byn * bxn) >> 3;
k = getauxval(AT_PAGESZ) + ROUNDUP(s, getauxval(AT_PAGESZ));
n = ROUNDUP(k + getauxval(AT_PAGESZ), sysconf(_SC_PAGESIZE));
k = getpagesize() + ROUNDUP(s, getpagesize());
n = ROUNDUP(k + getpagesize(), sysconf(_SC_PAGESIZE));
p = _mapanon(n);
mprotect(p, getauxval(AT_PAGESZ), 0);
mprotect(p, getpagesize(), 0);
mprotect(p + k, n - k, 0);
if (out_size)
*out_size = n;
return p + getauxval(AT_PAGESZ);
return p + getpagesize();
}
static void FreeBoard(void *p, size_t n) {
munmap((char *)p - getauxval(AT_PAGESZ), n);
munmap((char *)p - getpagesize(), n);
}
static void AllocateBoardsWithHardwareAcceleratedMemorySafety(void) {