6 /* Ensure that at least 32 atexit handlers can be registered without malloc */
12 void (*f[COUNT])(void *);
17 static volatile int lock[1];
19 void __funcs_on_exit()
21 void (*func)(void *), *arg;
23 for (; head; head=head->next, slot=COUNT) while(slot-->0) {
32 void __cxa_finalize(void *dso)
36 int __cxa_atexit(void (*func)(void *), void *arg, void *dso)
40 /* Defer initialization of head so it can be in BSS */
41 if (!head) head = &builtin;
43 /* If the current function list is full, add a new one */
45 struct fl *new_fl = calloc(sizeof(struct fl), 1);
55 /* Append function to the list. */
64 static void call(void *p)
66 ((void (*)(void))(uintptr_t)p)();
69 int atexit(void (*func)(void))
71 return __cxa_atexit(call, (void *)(uintptr_t)func, 0);