6 #define malloc __libc_malloc
7 #define calloc __libc_calloc
11 /* Ensure that at least 32 atexit handlers can be registered without malloc */
17 void (*f[COUNT])(void *);
22 static volatile int lock[1];
24 void __funcs_on_exit()
26 void (*func)(void *), *arg;
28 for (; head; head=head->next, slot=COUNT) while(slot-->0) {
37 void __cxa_finalize(void *dso)
41 int __cxa_atexit(void (*func)(void *), void *arg, void *dso)
45 /* Defer initialization of head so it can be in BSS */
46 if (!head) head = &builtin;
48 /* If the current function list is full, add a new one */
50 struct fl *new_fl = calloc(sizeof(struct fl), 1);
60 /* Append function to the list. */
69 static void call(void *p)
71 ((void (*)(void))(uintptr_t)p)();
74 int atexit(void (*func)(void))
76 return __cxa_atexit(call, (void *)(uintptr_t)func, 0);