]> git.proxmox.com Git - wasi-libc.git/blame - 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
CommitLineData
320054e8
DG
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
320054e8
DG
7static void *unmap_base;
8static size_t unmap_size;
9static char shared_stack[256];
10
11static void do_unmap()
12{
13 __syscall(SYS_munmap, unmap_base, unmap_size);
14 __syscall(SYS_exit);
15}
16
17void __unmapself(void *base, size_t size)
18{
320054e8
DG
19 char *stack = shared_stack + sizeof shared_stack;
20 stack -= (uintptr_t)stack % 16;
320054e8
DG
21 unmap_base = base;
22 unmap_size = size;
23 CRTJMP(do_unmap, stack);
24}