reactos/lib/3rdparty/mingw/gccmain.c
Cameron Gutman 29fa274d6d - Create another branch for networking fixes
- TSVN choked repeatedly when attempting to merge ~9000 revs into the branch (tried 3 times on 2 different computers)
 - If someone wants to delete aicom-network-fixes, they are welcome to
 - Lesson learned: Letting a branch get thousands of revs out of date is a horrible idea

svn path=/branches/aicom-network-branch/; revision=44353
2009-12-02 03:23:19 +00:00

73 lines
1.3 KiB
C

/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within this package.
*/
#include <windows.h>
#include <stdlib.h>
#include <setjmp.h>
typedef void (*func_ptr) (void);
extern func_ptr __CTOR_LIST__[];
extern func_ptr __DTOR_LIST__[];
static HMODULE hMsvcrt = NULL;
typedef void __cdecl flongjmp(jmp_buf _Buf,int _Value);
flongjmp *fctMsvcrtLongJmp = NULL;
void
__do_global_dtors (void)
{
static func_ptr *p = __DTOR_LIST__ + 1;
while (*p)
{
(*(p)) ();
p++;
}
if (hMsvcrt)
{
FreeLibrary (hMsvcrt);
hMsvcrt = NULL;
}
}
void
__do_global_ctors (void)
{
unsigned long nptrs = (unsigned long) (ptrdiff_t) __CTOR_LIST__[0];
unsigned long i;
if (!hMsvcrt) {
hMsvcrt = LoadLibrary ("msvcrt.dll");
fctMsvcrtLongJmp = (flongjmp *) GetProcAddress( hMsvcrt, "longjmp");
}
if (nptrs == (unsigned long) -1)
{
for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++);
}
for (i = nptrs; i >= 1; i--)
{
__CTOR_LIST__[i] ();
}
atexit (__do_global_dtors);
}
static int initialized = 0;
void
__main (void)
{
if (!initialized)
{
initialized = 1;
__do_global_ctors ();
}
}