memdisk: Force ld output format to 32-bits
[syslinux.git] / com32 / lib / onexit.c
blob272f8f1c01ce359b0b4224aa4a08fcab7d2b4dcf
1 /*
2 * onexit.c
3 */
5 #include <stdlib.h>
6 #include <unistd.h>
7 #include "atexit.h"
9 static struct atexit *__atexit_list;
11 static __noreturn on_exit_exit(int rv)
13 struct atexit *ap;
15 for (ap = __atexit_list; ap; ap = ap->next) {
16 ap->fctn(rv, ap->arg); /* This assumes extra args are harmless */
19 _exit(rv);
22 int on_exit(void (*fctn) (int, void *), void *arg)
24 struct atexit *as = malloc(sizeof(struct atexit));
26 if (!as)
27 return -1;
29 as->fctn = fctn;
30 as->arg = arg;
32 as->next = __atexit_list;
33 __atexit_list = as;
35 return 0;