blob: e76a0e8c30a5a15a3199a3c33722b42580aafae7 [file] [log] [blame]
#include <stdlib.h>
extern int main(void);
extern void (**__CTOR_LIST__)(void);
extern void (**__DTOR_LIST__)(void);
void Fini_Handler(void) {
// Destructors are called in forward order.
// The first element can have a few different meanings (always zero, always
// one, number of constructors) depending upon the compiler, but the list is
// guaranteed to be null terminated. So let's just ignore the first element
// and take advantage of the null termination.
// int dtor_count = 1;
// while (__DTOR_LIST__[dtor_count] != NULL) {
// __DTOR_LIST__[dtor_count]();
// dtor_count++;
// }
}
int Reset_Handler(void) {
// Constructors are called in reverse order
// The first element in the constructor has the same weird meaning as the
// destructor list, so best to just ignore it, too.
// int ctor_count = 0;
// while (__CTOR_LIST__[ctor_count+1] != NULL) {
// ctor_count++;
// }
// while (ctor_count > 0) {
// __CTOR_LIST__[ctor_count]();
// ctor_count--;
// }
// Call any other C-friendly initialization routines here.
int retval = main();
Fini_Handler();
return retval;
}