3 * This file has no copyright assigned and is placed in the Public Domain.
4 * This file is a part of the mingw-runtime package.
5 * No warranty is given; refer to the file DISCLAIMER within the package.
7 * A separate version of __main, __do_global_ctors and __do_global_dtors for
8 * Mingw32 for use with Cygwin32 b19. Hopefully this object file will only
9 * be linked if the libgcc.a doesn't include __main, __do_global_dtors and
14 /* Needed for the atexit prototype. */
18 typedef void (*func_ptr
) (void);
19 extern func_ptr __CTOR_LIST__
[];
20 extern func_ptr __DTOR_LIST__
[];
23 __do_global_dtors (void)
25 static func_ptr
*p
= __DTOR_LIST__
+ 1;
28 * Call each destructor in the destructor list until a null pointer
39 __do_global_ctors (void)
41 unsigned long nptrs
= (unsigned long) (ptrdiff_t) __CTOR_LIST__
[0];
45 * If the first entry in the constructor list is -1 then the list
46 * is terminated with a null entry. Otherwise the first entry was
47 * the number of pointers in the list.
51 for (nptrs
= 0; __CTOR_LIST__
[nptrs
+ 1] != 0; nptrs
++);
55 * Go through the list backwards calling constructors.
57 for (i
= nptrs
; i
>= 1; i
--)
63 * Register the destructors for processing on exit.
65 atexit (__do_global_dtors
);
68 static int initialized
= 0;