source: asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/thread/__unmapself.c@ 352

Last change on this file since 352 was 352, checked in by coas-nagasima, 6 years ago

arm向けASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 667 bytes
Line 
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
7static volatile int lock;
8static void *unmap_base;
9static size_t unmap_size;
10static char shared_stack[256];
11
12static void do_unmap()
13{
14 __syscall(SYS_munmap, unmap_base, unmap_size);
15 __syscall(SYS_exit);
16}
17
18void __unmapself(void *base, size_t size)
19{
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))
24 a_spin();
25 __syscall(SYS_set_tid_address, &lock);
26 unmap_base = base;
27 unmap_size = size;
28 CRTJMP(do_unmap, stack);
29}
Note: See TracBrowser for help on using the repository browser.