4 * A separate version of __main, __do_global_ctors and __do_global_dtors for
5 * Mingw32 for use with Cygwin32 b19. Hopefully this object file will only
6 * be linked if the libgcc.a doesn't include __main, __do_global_dtors and
9 * This file is part of the Mingw32 package.
12 * Code supplied by Stan Cox <scox@cygnus.com>
20 /* Needed for the atexit prototype. */
21 #include <msvcrt/stdlib.h>
24 typedef void (*func_ptr
) (void);
25 extern func_ptr __CTOR_LIST__
[];
26 extern func_ptr __DTOR_LIST__
[];
28 void __do_global_dtors(void)
30 static func_ptr
* p
= __DTOR_LIST__
+ 1;
33 * Call each destructor in the destructor list until a null pointer
43 void __do_global_ctors(void)
45 unsigned long nptrs
= (unsigned long)__CTOR_LIST__
[0];
49 * If the first entry in the constructor list is -1 then the list
50 * is terminated with a null entry. Otherwise the first entry was
51 * the number of pointers in the list.
54 for (nptrs
= 0; __CTOR_LIST__
[nptrs
+ 1] != 0; nptrs
++)
59 * Go through the list backwards calling constructors.
61 for (i
= nptrs
; i
>= 1; i
--) {
66 * Register the destructors for processing on exit.
68 atexit(__do_global_dtors
);
71 static int initialized
= 0;