/* cleanup.c (emx+gcc) */

#include <stdio.h>

#ifdef ORIGIN_EMX
extern int __crtexit1__;
extern void __ctordtorTerm1 (int *ptr);
#else
typedef void (*FUNC)(void);
extern FUNC _CRT_EXIT_START[];
extern FUNC _CRT_EXIT_END[];
#endif

void _cleanup (void)
{
#ifdef ORIGIN_EMX
  __ctordtorTerm1 (&__crtexit1__);
#else
    int i;

    for (i = 0; i < _CRT_EXIT_END - _CRT_EXIT_START; i++)
      _CRT_EXIT_START[i]();
#endif
}
