5 /* Ensure that at least 32 atexit handlers can be registered without malloc */
11 void (*f[COUNT])(void *);
16 static volatile int lock[2];
18 void __funcs_on_exit()
20 void (*func)(void *), *arg;
22 for (; head; head=head->next, slot=COUNT) while(slot-->0) {
31 void __cxa_finalize(void *dso)
35 int __cxa_atexit(void (*func)(void *), void *arg, void *dso)
39 /* Defer initialization of head so it can be in BSS */
40 if (!head) head = &builtin;
42 /* If the current function list is full, add a new one */
44 struct fl *new_fl = calloc(sizeof(struct fl), 1);
54 /* Append function to the list. */
63 static void call(void *p)
65 ((void (*)(void))(uintptr_t)p)();
68 int atexit(void (*func)(void))
70 return __cxa_atexit(call, (void *)(uintptr_t)func, 0);