mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 06:43:01 +00:00
Create a branch for header work.
svn path=/branches/header-work/; revision=45691
This commit is contained in:
parent
14fe274b1c
commit
9ea495ba33
19538 changed files with 0 additions and 1063950 deletions
72
lib/3rdparty/mingw/gccmain.c
vendored
Normal file
72
lib/3rdparty/mingw/gccmain.c
vendored
Normal file
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* 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 ();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue