12 /* __toread.c, __towrite.c, and atexit.c override these */
13 weak_alias(dummy, __funcs_on_exit);
14 weak_alias(dummy, __flush_on_exit);
15 weak_alias(dummy, __seek_on_exit);
18 weak_alias(dummy, _fini);
19 extern void (*const __fini_array_start)() __attribute__((weak));
20 extern void (*const __fini_array_end)() __attribute__((weak));
23 _Noreturn void exit(int code)
27 /* If more than one thread calls exit, hang until _Exit ends it all */
28 while (a_swap(&lock, 1)) __syscall(SYS_pause);
33 uintptr_t a = (uintptr_t)&__fini_array_end;
34 for (; a>(uintptr_t)&__fini_array_start; a-=sizeof(void(*)()))
35 (*(void (**)())(a-sizeof(void(*)())))();