revert between 56095 -> 55830 in arch
[AROS.git] / compiler / stdc / __exitfunc.c
blob256c1c655f95e81180ea1a219f810ea4d2116b48
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "__stdc_intbase.h"
8 #include <aros/symbolsets.h>
9 #include <exec/lists.h>
10 #include "__exitfunc.h"
12 int __addexitfunc(struct AtExitNode *aen)
14 struct StdCIntBase *StdCBase =
15 (struct StdCIntBase *)__aros_getbase_StdCBase();
17 ADDHEAD((struct List *)&StdCBase->atexit_list, (struct Node *)aen);
19 return 0;
22 int __init_atexit(struct StdCIntBase *StdCBase)
24 NEWLIST((struct List *)&StdCBase->atexit_list);
26 return 1;
29 void __callexitfuncs(void)
31 struct StdCIntBase *StdCBase =
32 (struct StdCIntBase *)__aros_getbase_StdCBase();
33 struct AtExitNode *aen;
35 while (
36 (aen = (struct AtExitNode *) REMHEAD((struct List *) &StdCBase->atexit_list))
39 switch (aen->node.ln_Type)
41 case AEN_VOID:
42 aen->func.fvoid();
43 break;
45 case AEN_PTR:
47 int *errorptr = __stdc_get_errorptr();
48 aen->func.fptr(errorptr != NULL ? *errorptr : 0, aen->ptr);
50 break;
55 ADD2OPENLIB(__init_atexit, 100);