1 #include "pthread_impl.h"
4 /* cheat and reuse CRTJMP macro from dynlink code */
7 static volatile int lock;
8 static void *unmap_base;
9 static size_t unmap_size;
10 static char shared_stack[256];
12 static void do_unmap()
14 __syscall(SYS_munmap, unmap_base, unmap_size);
18 void __unmapself(void *base, size_t size)
20 int tid=__pthread_self()->tid;
21 char *stack = shared_stack + sizeof shared_stack;
22 stack -= (uintptr_t)stack % 16;
23 while (lock || a_cas(&lock, 0, tid))
25 __syscall(SYS_set_tid_address, &lock);
28 CRTJMP(do_unmap, stack);