Remove __mmap() and __munmap()

This commit is contained in:
Justine Tunney 2024-07-05 12:55:46 -07:00
parent 01587de761
commit fc65422660
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
5 changed files with 11 additions and 16 deletions

View file

@ -148,8 +148,8 @@ textstartup void __enable_tls(void) {
// if a binary needs this much thread_local storage, then it
// surely must have linked the mmap() function at some point
// we can't call mmap() because it's too early for sig block
mem = _weaken(__mmap)(0, siz, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
mem = _weaken(mmap)(0, siz, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
}
struct CosmoTib *tib = (struct CosmoTib *)(mem + siz - sizeof(*tib));
@ -176,8 +176,8 @@ textstartup void __enable_tls(void) {
// if a binary needs this much thread_local storage, then it
// surely must have linked the mmap() function at some point
// we can't call mmap() because it's too early for sig block
mem = _weaken(__mmap)(0, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
mem = _weaken(mmap)(0, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
}
struct CosmoTib *tib =

View file

@ -77,7 +77,7 @@ void *__zipos_mmap(void *addr, size_t size, int prot, int flags,
flags |= MAP_PRIVATE | MAP_ANONYMOUS;
const int tempProt = !IsXnu() ? prot | PROT_WRITE : PROT_WRITE;
void *outAddr = __mmap(addr, size, tempProt, flags, -1, 0);
void *outAddr = mmap(addr, size, tempProt, flags, -1, 0);
if (outAddr == MAP_FAILED) {
return MAP_FAILED;
}

View file

@ -48,18 +48,15 @@ void __zipos_drop(struct ZiposHandle *h) {
if (atomic_fetch_sub_explicit(&h->refs, 1, memory_order_release))
return;
atomic_thread_fence(memory_order_acquire);
__munmap((char *)h, h->mapsize, false);
munmap((char *)h, h->mapsize);
}
static struct ZiposHandle *__zipos_alloc(struct Zipos *zipos, size_t size) {
size_t mapsize;
int granularity;
struct ZiposHandle *h;
granularity = __granularity();
mapsize = sizeof(struct ZiposHandle) + size;
mapsize = (mapsize + granularity - 1) & -granularity;
if ((h = __mmap(0, mapsize, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)) != MAP_FAILED) {
if ((h = mmap(0, mapsize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS,
-1, 0)) != MAP_FAILED) {
h->size = size;
h->zipos = zipos;
h->mapsize = mapsize;