Mail Archives: cygwin-developers/1998/03/08/14:52:56
For the merged cygwin32/win32 that I am experimenting with, I added
__do_global_dtors, __do_global_ctors, and __main to
winsup/mingw/mcrt0.c. cygwin32 defines its own __main et al, and does
not build the gcc version (gcc/libgcc2.c).
Stan
#ifdef __CYGWIN32__
typedef void (*func_ptr) (void);
extern func_ptr __CTOR_LIST__[];
extern func_ptr __DTOR_LIST__[];
void
__do_global_dtors (void)
{
static func_ptr *p = __DTOR_LIST__ + 1;
while (*p)
{
p++;
(*(p-1)) ();
}
}
void
__do_global_ctors (void)
{
unsigned long nptrs = (unsigned long) __CTOR_LIST__[0];
unsigned i;
if (nptrs == -1)
for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++);
for (i = nptrs; i >= 1; i--)
__CTOR_LIST__[i] ();
atexit (__do_global_dtors);
}
void
__main (void)
{
static int initialized;
if (! initialized)
{
initialized = 1;
__do_global_ctors ();
}
}
#endif
- Raw text -