From: scox AT cygnus DOT com (Stan Cox) Subject: Re: Cygnus b19 gcc and Mingw32 8 Mar 1998 14:52:56 -0800 Message-ID: <199803082234.OAA25497.cygnus.cygwin32.developers@rtl.cygnus.com> References: <000601bd4730$4f828cc0$fa173185 DOT cygnus DOT gnu-win32 AT gbird0 DOT fu DOT is DOT saga-u DOT ac DOT jp> To: colin AT fu DOT is DOT saga-u DOT ac DOT jp 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