]> git.proxmox.com Git - wasi-libc.git/blob - libc-top-half/musl/src/thread/__unmapself.c
Update to musl 1.1.22.
[wasi-libc.git] / libc-top-half / musl / src / thread / __unmapself.c
1 #include "pthread_impl.h"
2 #include "atomic.h"
3 #include "syscall.h"
4 /* cheat and reuse CRTJMP macro from dynlink code */
5 #include "dynlink.h"
6
7 static void *unmap_base;
8 static size_t unmap_size;
9 static char shared_stack[256];
10
11 static void do_unmap()
12 {
13 __syscall(SYS_munmap, unmap_base, unmap_size);
14 __syscall(SYS_exit);
15 }
16
17 void __unmapself(void *base, size_t size)
18 {
19 char *stack = shared_stack + sizeof shared_stack;
20 stack -= (uintptr_t)stack % 16;
21 unmap_base = base;
22 unmap_size = size;
23 CRTJMP(do_unmap, stack);
24 }