Merge from amd64 branch:

46478
[CRT]
- define _CRTBLD
- rename float_t/double_t/long_double_t to float_s/double_s/long_double_s to avoid name conflicts

46511
[FREELDR]
snprintf -> _snprintf

46534
[CRT]
- Set crt="static" in freeldr, rtl, bmfs, ftfd, rtl, mini_hal
- define "CRTDLL" in ntdll, crtdll, msvcrt, msvcrt20, msvcrt40

46535
[CRT HEADERS]
- add _mingw_mac.h from ming-w64 and include it into _mingw.h
- Update _CRTIMP definition
- Fix definition of _wctype
- onexit is not _CRTIMP

46537
[MINGW]
Update mingw library to mingw-w64 trunk (mingw-w64-src_20100325)

46538
Apply MSVC compilation fix.

46539
[MINGW]
Apply MSVC compilation fixes

svn path=/trunk/; revision=46597
This commit is contained in:
Timo Kreuzer 2010-03-30 13:30:36 +00:00
commit 794e740131
82 changed files with 1700 additions and 629 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE directory SYSTEM "../../../tools/rbuild/project.dtd">
<module name="freeldr_arch" type="objectlibrary">
<module name="freeldr_arch" type="objectlibrary" crt="static">
<include base="freeldr_base">include</include>
<include base="freeldr_base">cache</include>
<include base="ntoskrnl">include</include>

View file

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="freeldr_base" type="objectlibrary">
<module name="freeldr_base" type="objectlibrary" crt="static">
<include base="freeldr_base">include</include>
<include base="freeldr_base">cache</include>
<include base="cmlib">.</include>

View file

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="freeldr_main" type="objectlibrary">
<module name="freeldr_main" type="objectlibrary" crt="static">
<include base="freeldr_main">include</include>
<include base="ntoskrnl">include</include>
<define name="_NTHAL_" />

View file

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<module name="setupldr_main" type="objectlibrary">
<module name="setupldr_main" type="objectlibrary" crt="static">
<include base="setupldr_main">include</include>
<include base="ntoskrnl">include</include>
<define name="_NTHAL_" />

View file

@ -232,7 +232,7 @@ WinLdrLoadDeviceDriver(PLOADER_PARAMETER_BLOCK LoaderBlock,
PVOID DriverBase;
// Separate the path to file name and directory path
snprintf(DriverPath, sizeof(DriverPath), "%wZ", FilePath);
_snprintf(DriverPath, sizeof(DriverPath), "%wZ", FilePath);
DriverNamePos = strrchr(DriverPath, '\\');
if (DriverNamePos != NULL)
{
@ -261,7 +261,7 @@ WinLdrLoadDeviceDriver(PLOADER_PARAMETER_BLOCK LoaderBlock,
}
// It's not loaded, we have to load it
snprintf(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath);
_snprintf(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath);
Status = WinLdrLoadImage(FullPath, LoaderBootDriver, &DriverBase);
if (!Status)
return FALSE;

View file

@ -12,6 +12,7 @@
<include base="ReactOS">include/reactos/subsys</include>
<define name="__NTDLL__" />
<define name="_NTOSKRNL_" />
<define name="CRTDLL" />
<library>rtl</library>
<library>ntdllsys</library>
<library>libcntpr</library>

View file

@ -5,6 +5,7 @@
<define name="USE_MSVCRT_PREFIX" />
<define name="_MSVCRT_LIB_" />
<define name="_MSVCRT_" />
<define name="CRTDLL" />
<define name="_CTYPE_DISABLE_MACROS" />
<define name="_NO_INLINING" />

View file

@ -8,6 +8,7 @@
<define name="_MT" />
<define name="_CTYPE_DISABLE_MACROS" />
<define name="_NO_INLINING" />
<define name="CRTDLL" />
<linkerflag linkerset="ld">-enable-stdcall-fixup</linkerflag>
<!-- __MINGW_IMPORT needs to be defined differently because it's defined

View file

@ -6,6 +6,7 @@
<include base="msvcrt20">.</include>
<include base="ReactOS">include/reactos/wine</include>
<define name="__WINESRC__" />
<define name="CRTDLL" />
<file>msvcrt20.c</file>
<library>wine</library>
<library>msvcrt</library>

View file

@ -6,6 +6,7 @@
<include base="msvcrt40">.</include>
<include base="ReactOS">include/reactos/wine</include>
<define name="__WINESRC__" />
<define name="CRTDLL" />
<file>msvcrt40.c</file>
<library>wine</library>
</module>

View file

@ -93,7 +93,7 @@
</directory>
</module>
<module name="mini_hal" type="objectlibrary">
<module name="mini_hal" type="objectlibrary" crt="static">
<include>include</include>
<include base="ntoskrnl">include</include>
<define name="_NTHALDLL_" />

View file

@ -184,7 +184,7 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case. */
#define USE_MINGW_SETJMP_TWO_ARGS
#endif
/* Diable deprecation for now! */
/* Disable deprecation for now! */
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE_CORE
#ifdef __WINESRC__
@ -197,5 +197,7 @@ allow GCC to optimize away some EH unwind code, at least in DW2 case. */
#define _CRT_UNUSED(x) (void)x
#endif
#include "_mingw_mac.h"
#endif /* !_INC_MINGW */

View file

@ -0,0 +1,134 @@
/**
* 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.PD within this package.
*/
#ifndef _INC_CRTDEFS_MACRO
#define _INC_CRTDEFS_MACRO
#define __STRINGIFY(x) #x
#define __MINGW64_STRINGIFY(x) __STRINGIFY(x)
#define __MINGW64_VERSION_MAJOR 1
#define __MINGW64_VERSION_MINOR 1
#define __MINGW64_VERSION_STR __MINGW64_STRINGIFY(__MINGW64_VERSION_MAJOR) "." __MINGW64_STRINGIFY(__MINGW64_VERSION_MINOR)
#define __MINGW64_VERSION_STATE "alpha"
/* mingw.org's version macros: these make gcc to define
MINGW32_SUPPORTS_MT_EH and to use the _CRT_MT global
and the __mingwthr_key_dtor() function from the MinGW
CRT in its private gthr-win32.h header. */
#define __MINGW32_MAJOR_VERSION 3
#define __MINGW32_MINOR_VERSION 11
#ifdef _WIN64
/* MS does not prefix symbols by underscores for 64-bit. */
#ifndef __MINGW_USE_UNDERSCORE_PREFIX
/* As we have to support older gcc version, which are using underscores
as symbol prefix for x64, we have to check here for the user label
prefix defined by gcc. */
#ifdef __USER_LABEL_PREFIX__
#pragma push_macro ("_")
#undef _
#define _ 1
#if (__USER_LABEL_PREFIX__ + 0) != 0
#define __MINGW_USE_UNDERSCORE_PREFIX 1
#else
#define __MINGW_USE_UNDERSCORE_PREFIX 0
#endif
#undef _
#pragma pop_macro ("_")
#else
#define __MINGW_USE_UNDERSCORE_PREFIX 0
#endif
#endif
#else
/* For 32-bits we have always to prefix by underscore. */
#undef __MINGW_USE_UNDERSCORE_PREFIX
#define __MINGW_USE_UNDERSCORE_PREFIX 1
#endif
#if __MINGW_USE_UNDERSCORE_PREFIX == 0
#define __MINGW_IMP_SYMBOL(sym) __imp_##sym
#define __MINGW_USYMBOL(sym) sym
#define __MINGW_LSYMBOL(sym) _##sym
#else
#define __MINGW_IMP_SYMBOL(sym) _imp__##sym
#define __MINGW_USYMBOL(sym) _##sym
#define __MINGW_LSYMBOL(sym) sym
#endif
/* Use alias for msvcr80 export of get/set_output_format. */
#ifndef __USE_MINGW_OUTPUT_FORMAT_EMU
#define __USE_MINGW_OUTPUT_FORMAT_EMU 1
#endif
/* Set VC specific compiler target macros. */
#if defined(__x86_64) && defined(_X86_)
#undef _X86_ /* _X86_ is not for __x86_64 */
#endif
#if defined(_X86_) && !defined(_M_IX86) && !defined(_M_IA64) \
&& !defined(_M_AMD64) && !defined(__x86_64)
#if defined(__i486__)
#define _M_IX86 400
#elif defined(__i586__)
#define _M_IX86 500
#else
/* This gives wrong (600 instead of 300) value if -march=i386 is specified
but we cannot check for__i386__ as it is defined for all 32-bit CPUs. */
#define _M_IX86 600
#endif
#endif
#if defined(__x86_64) && !defined(_M_IX86) && !defined(_M_IA64) \
&& !defined(_M_AMD64)
#define _M_AMD64 100
#define _M_X64 100
#endif
#if defined(__ia64__) && !defined(_M_IX86) && !defined(_M_IA64) \
&& !defined(_M_AMD64) && !defined(_X86_) && !defined(__x86_64)
#define _M_IA64 100
#endif
#ifndef __PTRDIFF_TYPE__
#ifdef _WIN64
#define __PTRDIFF_TYPE__ long long int
#else
#define __PTRDIFF_TYPE__ long int
#endif
#endif
#ifndef __SIZE_TYPE__
#ifdef _WIN64
#define __SIZE_TYPE__ long long unsigned int
#else
#define __SIZE_TYPE__ long unsigned int
#endif
#endif
#ifndef __WCHAR_TYPE__
#define __WCHAR_TYPE__ unsigned short
#endif
#ifndef __WINT_TYPE__
#define __WINT_TYPE__ unsigned short
#endif
#if defined(__GNUC__) || defined(__GNUG__)
#define __MINGW_EXTENSION __extension__
#else
#define __MINGW_EXTENSION
#endif
#ifdef UNICODE
# define __MINGW_NAME_AW(func) func##W
#else
# define __MINGW_NAME_AW(func) func##A
#endif
#define __MINGW_TYPEDEF_AW(type) \
typedef __MINGW_NAME_AW(type) type;
#endif /* _INC_CRTDEFS_MACRO */

View file

@ -25,6 +25,7 @@
//#define NO_OLDNAMES
//#endif
/** Properties ***************************************************************/
#undef _CRT_PACKING
@ -50,12 +51,14 @@
#endif
#ifndef _CRTIMP
#ifdef _DLL
#ifdef CRTDLL /* Defined for ntdll, crtdll, msvcrt, etc */
#define _CRTIMP __declspec(dllexport)
#elif defined(_DLL)
#define _CRTIMP __declspec(dllimport)
#else
#else /* !CRTDLL && !_DLL */
#define _CRTIMP
#endif
#endif
#endif /* CRTDLL || _DLL */
#endif /* !_CRTIMP */
//#define _CRT_ALTERNATIVE_INLINES
@ -218,6 +221,7 @@
#define _CRT_OBSOLETE(_NewItem)
#endif
/** Constants ****************************************************************/
#define _ARGMAX 100
@ -231,7 +235,6 @@
#define _SECURECRT_FILL_BUFFER_PATTERN 0xFD
/** Type definitions *********************************************************/
#ifdef __cplusplus

View file

@ -535,7 +535,7 @@ extern "C" {
_CRTIMP int __cdecl putenv(const char *_EnvString);
_CRTIMP void __cdecl swab(char *_Buf1,char *_Buf2,int _SizeInBytes);
_CRTIMP char *__cdecl ultoa(unsigned long _Val,char *_Dstbuf,int _Radix);
_CRTIMP onexit_t __cdecl onexit(onexit_t _Func);
onexit_t __cdecl onexit(onexit_t _Func);
#endif
#endif

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifndef _INC_INTERNAL
@ -18,11 +18,14 @@ extern "C" {
#pragma pack(push,_CRT_PACKING)
#ifndef __INTERNAL_FUNC_DEFINED
#define __INTERNAL_FUNC_DEFINED
typedef void (__cdecl *_PVFV)(void);
typedef int (__cdecl *_PIFV)(void);
typedef void (__cdecl *_PVFI)(int);
#endif
#if defined (SPECIAL_CRTEXE) && defined (_DLL)
#if defined (SPECIAL_CRTEXE) && (defined (_DLL) || defined (__GNUC__))
extern int _commode;
#else
_CRTIMP extern int _commode;
@ -69,13 +72,13 @@ extern "C" {
#define _tm_unicode_safe(i) (_pioinfo_safe(i)->unicode)
#ifndef __badioinfo
extern ioinfo ** _imp____badioinfo[];
#define __badioinfo (*_imp____badioinfo)
extern ioinfo ** __MINGW_IMP_SYMBOL(__badioinfo)[];
#define __badioinfo (* __MINGW_IMP_SYMBOL(__badioinfo))
#endif
#ifndef __pioinfo
extern ioinfo ** _imp____pioinfo[];
#define __pioinfo (*_imp____pioinfo)
extern ioinfo ** __MINGW_IMP_SYMBOL(__pioinfo)[];
#define __pioinfo (* __MINGW_IMP_SYMBOL(__pioinfo))
#endif
#define _NO_CONSOLE_FILENO (intptr_t)-2
@ -107,24 +110,24 @@ extern "C" {
extern int _newmode;
#ifndef __winitenv
extern wchar_t ***_imp____winitenv;
#define __winitenv (*_imp____winitenv)
extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
#define __winitenv (* __MINGW_IMP_SYMBOL(__winitenv))
#endif
#ifndef __initenv
extern char ***_imp____initenv;
#define __initenv (*_imp____initenv)
extern char *** __MINGW_IMP_SYMBOL(__initenv);
#define __initenv (* __MINGW_IMP_SYMBOL(__initenv))
#endif
#ifndef _acmdln
extern char **_imp___acmdln;
#define _acmdln (*_imp___acmdln)
extern char ** __MINGW_IMP_SYMBOL(_acmdln);
#define _acmdln (* __MINGW_IMP_SYMBOL(_acmdln))
/* _CRTIMP extern char *_acmdln; */
#endif
#ifndef _wcmdln
extern char **_imp___wcmdln;
#define _wcmdln (*_imp___wcmdln)
extern char ** __MINGW_IMP_SYMBOL(_wcmdln);
#define _wcmdln (* __MINGW_IMP_SYMBOL(_wcmdln))
/* __CRTIMP extern wchar_t *_wcmdln; */
#endif
@ -169,7 +172,7 @@ extern char **_imp___wcmdln;
#include <errno.h>
void * __cdecl _encode_pointer(void *);
void * __cdecl _encoded_null(void);
void * __cdecl _encoded_null();
void * __cdecl _decode_pointer(void *);
BOOL __cdecl _ValidateImageBase (PBYTE pImageBase);

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifndef _INC_OSCALLS

View file

@ -0,0 +1,83 @@
Index: internal.h
===================================================================
--- internal.h (Revision 46537)
+++ internal.h (Arbeitskopie)
@@ -35,6 +35,12 @@
#define __IOINFO_TM_UTF8 1
#define __IOINFO_TM_UTF16LE 2
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4214)
+#pragma warning(disable:4820)
+#endif
+
typedef struct {
intptr_t osfhnd;
char osfile;
@@ -46,6 +52,10 @@
char pipech2[2];
} ioinfo;
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
#define IOINFO_ARRAY_ELTS (1 << 5)
#define _pioinfo(i) (__pioinfo[(i) >> 5] + ((i) & (IOINFO_ARRAY_ELTS - 1)))
Index: oscalls.h
===================================================================
--- oscalls.h (Revision 46537)
+++ oscalls.h (Arbeitskopie)
@@ -30,6 +30,11 @@
#endif
#endif
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4214)
+#endif
+
typedef struct _FTIME
{
unsigned short twosecs : 5;
@@ -46,6 +51,10 @@
unsigned short year : 7;
} FDATE;
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
typedef FDATE *PFDATE;
#endif
Index: sect_attribs.h
===================================================================
--- sect_attribs.h (Revision 46537)
+++ sect_attribs.h (Arbeitskopie)
@@ -10,7 +10,7 @@
#define _ATTRIBUTES shared
#endif
-#if 0
+#if defined(_MSC_VER)
/* Reference list of existing section for msvcrt. */
#pragma section(".CRTMP$XCA",long,_ATTRIBUTES)
#pragma section(".CRTMP$XCZ",long,_ATTRIBUTES)
@@ -55,6 +55,14 @@
#pragma section(".rtc$IZZ",long,read)
#pragma section(".rtc$TAA",long,read)
#pragma section(".rtc$TZZ",long,read)
+#pragma section(".tls",long,read,write)
+#pragma section(".tls$ZZZ",long,read,write)
#endif
+#if defined(_MSC_VER)
+#define _CRTALLOC(x) __declspec(allocate(x))
+#elif defined(__GNUC__)
#define _CRTALLOC(x) __attribute__ ((section (x) ))
+#else
+#error
+#endif

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#if defined (__ia64__) || defined (__x86_64)

View file

@ -1,9 +1,11 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
void _fpreset (void);
void _fpreset (void)
{
#ifdef __GNUC__

View file

@ -1,12 +1,18 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
extern void (*_imp___fpreset)(void) ;
#include <_mingw.h>
extern void (* __MINGW_IMP_SYMBOL(_fpreset))(void);
void _fpreset (void);
void _fpreset (void)
{ (*_imp___fpreset)(); }
{
(* __MINGW_IMP_SYMBOL(_fpreset))();
}
#ifdef __GNUC__
void __attribute__ ((alias ("_fpreset"))) fpreset(void);

17
reactos/lib/3rdparty/mingw/CRT_glob.c vendored Normal file
View file

@ -0,0 +1,17 @@
/*
* CRT_glob.c
* This file has no copyright is 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.PD within the package.
*
* Include this object file to set _dowildcard to a state that will turn on
* command line globbing by default. (wildcard.o which goes into libmingw32.a
* has a default state of off.)
*
* To use this object include the object file in your link command:
* gcc -o foo.exe foo.o CRT_glob.o
*
*/
int _dowildcard = -1;

17
reactos/lib/3rdparty/mingw/CRT_noglob.c vendored Normal file
View file

@ -0,0 +1,17 @@
/*
* CRT_noglob.c
* This file has no copyright is 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.PD within the package.
*
* Include this object file to set _dowildcard to a state that will turn off
* command line globbing by default. (wildcard.o which goes into libmingw32.a
* has a default state of off if not configured with --enable-wildcard.)
*
* To use this object include the object file in your link command:
* gcc -o foo.exe foo.o CRT_noglob.o
*
*/
int _dowildcard = 0;

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int _newmode = 0;

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#undef CRTDLL
@ -25,9 +25,11 @@ _PVFV *__onexitbegin;
_PVFV *__onexitend;
extern _CRTIMP _onexit_t __dllonexit (_onexit_t, _PVFV**, _PVFV**);
extern _onexit_t (__cdecl *_imp___onexit) (_onexit_t func);
extern _onexit_t (__cdecl * __MINGW_IMP_SYMBOL(_onexit)) (_onexit_t func);
/* Choose a different name to prevent name conflicts. The CRT one works fine. */
_onexit_t __cdecl mingw_onexit(_onexit_t func);
_onexit_t __cdecl mingw_onexit(_onexit_t func)
{
_PVFV *onexitbegin;
@ -37,7 +39,7 @@ _onexit_t __cdecl mingw_onexit(_onexit_t func)
onexitbegin = (_PVFV *) _decode_pointer (__onexitbegin);
if (onexitbegin == (_PVFV *) -1)
return (*_imp___onexit) (func);
return (* __MINGW_IMP_SYMBOL(_onexit)) (func);
_lock (_EXIT_LOCK1);
onexitbegin = (_PVFV *) _decode_pointer (__onexitbegin);
onexitend = (_PVFV *) _decode_pointer (__onexitend);

10
reactos/lib/3rdparty/mingw/binmode.c vendored Normal file
View file

@ -0,0 +1,10 @@
/**
* 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.PD within this package.
*/
#define SPECIAL_CRTEXE
#include <fcntl.h>
#include <stdlib.h>

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <sect_attribs.h>

View file

@ -1,12 +1,20 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
int main (int flags, char **cmdline, char **inst)
extern HINSTANCE __mingw_winmain_hInstance;
extern LPSTR __mingw_winmain_lpCmdLine;
extern DWORD __mingw_winmain_nShowCmd;
/*ARGSUSED*/
int main (int flags __attribute__ ((__unused__)),
char **cmdline __attribute__ ((__unused__)),
char **inst __attribute__ ((__unused__)))
{
return (int) WinMain ((HINSTANCE) inst, NULL, (LPSTR) cmdline,(DWORD) flags);
return (int) WinMain (__mingw_winmain_hInstance, NULL,
__mingw_winmain_lpCmdLine, __mingw_winmain_nShowCmd);
}

View file

@ -1,16 +1,25 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
extern void __main(void);
/* Do the UNICODE prototyping of WinMain. Be aware that in winbase.h WinMain is a macro
defined to wWinMain. */
int WINAPI wWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPWSTR lpCmdLine,int nShowCmd);
int wmain (int flags, wchar_t **cmdline, wchar_t **inst)
extern HINSTANCE __mingw_winmain_hInstance;
extern LPWSTR __mingw_winmain_lpCmdLine;
extern DWORD __mingw_winmain_nShowCmd;
int wmain (int, wchar_t **, wchar_t **);
/*ARGSUSED*/
int wmain (int flags __attribute__ ((__unused__)),
wchar_t **cmdline __attribute__ ((__unused__)),
wchar_t **inst __attribute__ ((__unused__)))
{
return (int) wWinMain ((HINSTANCE) inst, NULL, (LPWSTR) cmdline,(DWORD) flags);
return (int) wWinMain (__mingw_winmain_hInstance, NULL,
__mingw_winmain_lpCmdLine, __mingw_winmain_nShowCmd);
}

181
reactos/lib/3rdparty/mingw/crt_handler.c vendored Normal file
View file

@ -0,0 +1,181 @@
/**
* 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.PD within this package.
*/
#include <windows.h>
#include <excpt.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <signal.h>
#include <stdio.h>
#if defined (_WIN64) && defined (__ia64__)
#error FIXME: Unsupported __ImageBase implementation.
#else
#define __ImageBase __MINGW_LSYMBOL(_image_base__)
/* This symbol is defined by the linker. */
extern IMAGE_DOS_HEADER __ImageBase;
#endif
#pragma pack(push,1)
typedef struct _UNWIND_INFO {
BYTE VersionAndFlags;
BYTE PrologSize;
BYTE CountOfUnwindCodes;
BYTE FrameRegisterAndOffset;
ULONG AddressOfExceptionHandler;
} UNWIND_INFO,*PUNWIND_INFO;
#pragma pack(pop)
PIMAGE_SECTION_HEADER _FindPESectionByName (const char *);
PIMAGE_SECTION_HEADER _FindPESectionExec (size_t);
PBYTE _GetPEImageBase (void);
int __mingw_init_ehandler (void);
#ifdef _WIN64
EXCEPTION_DISPOSITION __mingw_SEH_error_handler(struct _EXCEPTION_RECORD *, void *, struct _CONTEXT *, void *);
#define MAX_PDATA_ENTRIES 32
static RUNTIME_FUNCTION emu_pdata[MAX_PDATA_ENTRIES];
static UNWIND_INFO emu_xdata[MAX_PDATA_ENTRIES];
int
__mingw_init_ehandler (void)
{
static int was_here = 0;
size_t e = 0;
PIMAGE_SECTION_HEADER pSec;
PBYTE _ImageBase = _GetPEImageBase ();
if (was_here || !_ImageBase)
return was_here;
was_here = 1;
if (_FindPESectionByName (".pdata") != NULL)
return 1;
/* Allocate # of e tables and entries. */
memset (emu_pdata, 0, sizeof (RUNTIME_FUNCTION) * MAX_PDATA_ENTRIES);
memset (emu_xdata, 0, sizeof (UNWIND_INFO) * MAX_PDATA_ENTRIES);
e = 0;
/* Fill tables and entries. */
while (e < MAX_PDATA_ENTRIES && (pSec = _FindPESectionExec (e)) != NULL)
{
emu_xdata[e].VersionAndFlags = 9; /* UNW_FLAG_EHANDLER | UNW_VERSION */
emu_xdata[e].AddressOfExceptionHandler =
(DWORD)(size_t) ((LPBYTE)__mingw_SEH_error_handler - _ImageBase);
emu_pdata[e].BeginAddress = pSec->VirtualAddress;
emu_pdata[e].EndAddress = pSec->VirtualAddress + pSec->Misc.VirtualSize;
emu_pdata[e].UnwindData =
(DWORD)(size_t)((LPBYTE)&emu_xdata[e] - _ImageBase);
++e;
}
#ifdef _DEBUG_CRT
if (!e || e > MAX_PDATA_ENTRIES)
abort ();
#endif
/* RtlAddFunctionTable. */
if (e != 0)
RtlAddFunctionTable (emu_pdata, e, (DWORD64)_ImageBase);
return 1;
}
extern void _fpreset (void);
EXCEPTION_DISPOSITION
__mingw_SEH_error_handler (struct _EXCEPTION_RECORD* ExceptionRecord,
void *EstablisherFrame __attribute__ ((unused)),
struct _CONTEXT* ContextRecord __attribute__ ((unused)),
void *DispatcherContext __attribute__ ((unused)))
{
EXCEPTION_DISPOSITION action = EXCEPTION_CONTINUE_SEARCH;
void (*old_handler) (int);
int reset_fpu = 0;
switch (ExceptionRecord->ExceptionCode)
{
case EXCEPTION_ACCESS_VIOLATION:
/* test if the user has set SIGSEGV */
old_handler = signal (SIGSEGV, SIG_DFL);
if (old_handler == SIG_IGN)
{
/* this is undefined if the signal was raised by anything other
than raise (). */
signal (SIGSEGV, SIG_IGN);
action = EXCEPTION_CONTINUE_EXECUTION;
}
else if (old_handler != SIG_DFL)
{
/* This means 'old' is a user defined function. Call it */
(*old_handler) (SIGSEGV);
action = EXCEPTION_CONTINUE_EXECUTION;
}
else
action = EXCEPTION_EXECUTE_HANDLER;
break;
case EXCEPTION_ILLEGAL_INSTRUCTION:
case EXCEPTION_PRIV_INSTRUCTION:
/* test if the user has set SIGILL */
old_handler = signal (SIGILL, SIG_DFL);
if (old_handler == SIG_IGN)
{
/* this is undefined if the signal was raised by anything other
than raise (). */
signal (SIGILL, SIG_IGN);
action = EXCEPTION_CONTINUE_EXECUTION;
}
else if (old_handler != SIG_DFL)
{
/* This means 'old' is a user defined function. Call it */
(*old_handler) (SIGILL);
action = EXCEPTION_CONTINUE_EXECUTION;
}
else
action = EXCEPTION_EXECUTE_HANDLER;
break;
case EXCEPTION_FLT_INVALID_OPERATION:
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
case EXCEPTION_FLT_DENORMAL_OPERAND:
case EXCEPTION_FLT_OVERFLOW:
case EXCEPTION_FLT_UNDERFLOW:
case EXCEPTION_FLT_INEXACT_RESULT:
reset_fpu = 1;
/* fall through. */
case EXCEPTION_INT_DIVIDE_BY_ZERO:
/* test if the user has set SIGFPE */
old_handler = signal (SIGFPE, SIG_DFL);
if (old_handler == SIG_IGN)
{
signal (SIGFPE, SIG_IGN);
if (reset_fpu)
_fpreset ();
action = EXCEPTION_CONTINUE_EXECUTION;
}
else if (old_handler != SIG_DFL)
{
/* This means 'old' is a user defined function. Call it */
(*old_handler) (SIGFPE);
action = EXCEPTION_CONTINUE_EXECUTION;
}
break;
case EXCEPTION_DATATYPE_MISALIGNMENT:
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
case EXCEPTION_FLT_STACK_CHECK:
case EXCEPTION_INT_OVERFLOW:
case EXCEPTION_INVALID_HANDLE:
/*case EXCEPTION_POSSIBLE_DEADLOCK: */
action = EXCEPTION_CONTINUE_EXECUTION;
break;
default:
break;
}
return action;
}
#endif

6
reactos/lib/3rdparty/mingw/crtbegin.c vendored Normal file
View file

@ -0,0 +1,6 @@
/**
* 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.PD within this package.
*/

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifdef CRTDLL
@ -40,6 +40,7 @@ extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
/* TLS initialization hook. */
extern const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback;
static int __proc_attached = 0;
@ -49,9 +50,9 @@ extern _PVFV *__onexitend;
extern int mingw_app_type;
extern BOOL WINAPI DllMain (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved);
extern WINBOOL WINAPI DllMain (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved);
extern BOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID);
extern WINBOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID);
static int pre_c_init (void);
@ -71,7 +72,7 @@ pre_c_init (void)
return 0;
}
BOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
if (dwReason == DLL_PROCESS_DETACH)
{
@ -110,10 +111,9 @@ BOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
}
if (! nested)
{
InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
(void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
}
if (__dyn_tls_init_callback != NULL &&
_IsNonwritableInCurrentImage ((PBYTE) &__dyn_tls_init_callback))
if (__dyn_tls_init_callback != NULL)
{
__dyn_tls_init_callback (hDllHandle, DLL_THREAD_ATTACH, lpreserved);
}
@ -143,29 +143,35 @@ BOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
__onexitbegin = __onexitend = (_PVFV *) NULL;
}
__native_startup_state = __uninitialized;
InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
(void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
}
}
return TRUE;
}
static BOOL __DllMainCRTStartup (HANDLE, DWORD, LPVOID);
static WINBOOL __DllMainCRTStartup (HANDLE, DWORD, LPVOID);
BOOL WINAPI
WINBOOL WINAPI DllMainCRTStartup (HANDLE, DWORD, LPVOID);
int __mingw_init_ehandler (void);
WINBOOL WINAPI
DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
mingw_app_type = 0;
if (dwReason == DLL_PROCESS_ATTACH)
{
__security_init_cookie ();
#ifdef _WIN64
__mingw_init_ehandler ();
#endif
}
return __DllMainCRTStartup (hDllHandle, dwReason, lpreserved);
}
__declspec(noinline) BOOL
__declspec(noinline) WINBOOL
__DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
BOOL retcode = TRUE;
WINBOOL retcode = TRUE;
__native_dllmain_reason = dwReason;
if (dwReason == DLL_PROCESS_DETACH && __proc_attached == 0)

6
reactos/lib/3rdparty/mingw/crtend.c vendored Normal file
View file

@ -0,0 +1,6 @@
/**
* 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.PD within this package.
*/

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#undef CRTDLL
@ -23,17 +23,17 @@
#include <intrin.h>
#ifndef __winitenv
extern wchar_t ***_imp____winitenv;
#define __winitenv (*_imp____winitenv)
extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
#define __winitenv (* __MINGW_IMP_SYMBOL(__winitenv))
#endif
#ifndef __initenv
extern char ***_imp____initenv;
#define __initenv (*_imp____initenv)
extern char *** __MINGW_IMP_SYMBOL(__initenv);
#define __initenv (* __MINGW_IMP_SYMBOL(__initenv))
#endif
/* Hack, for bug in ld. Will be removed soon. */
#define __ImageBase _image_base__
#define __ImageBase __MINGW_LSYMBOL(_image_base__)
/* This symbol is defined by ld. */
extern IMAGE_DOS_HEADER __ImageBase;
@ -43,13 +43,13 @@ extern void _fpreset (void);
__declspec(dllimport) void __setusermatherr(int (__cdecl *)(struct _exception *));
extern int *_imp___fmode;
extern int *_imp___commode;
extern int * __MINGW_IMP_SYMBOL(_fmode);
extern int * __MINGW_IMP_SYMBOL(_commode);
#undef _fmode
extern int _fmode;
extern int *_imp___commode;
#define _commode (*_imp___commode)
extern int * __MINGW_IMP_SYMBOL(_commode);
#define _commode (* __MINGW_IMP_SYMBOL(_commode))
extern int _dowildcard;
#if defined(__GNUC__)
@ -67,6 +67,7 @@ extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
/* TLS initialization hook. */
extern const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback;
extern _PVFV *__onexitbegin;
@ -74,6 +75,10 @@ extern _PVFV *__onexitend;
extern int mingw_app_type;
HINSTANCE __mingw_winmain_hInstance;
_TCHAR *__mingw_winmain_lpCmdLine;
DWORD __mingw_winmain_nShowCmd;
static int argc;
#ifdef WPRFLAG
extern void __main(void);
@ -89,10 +94,10 @@ static int mainret=0;
static int managedapp;
static int has_cctor = 0;
static _startupinfo startinfo;
static LPTOP_LEVEL_EXCEPTION_FILTER __mingw_oldexcpt_handler = NULL;
extern void _pei386_runtime_relocator (void);
static long CALLBACK _gnu_exception_handler (EXCEPTION_POINTERS * exception_data);
//static LONG __mingw_vex(EXCEPTION_POINTERS * exception_data);
#ifdef WPRFLAG
static void duplicate_ppstrings (int ac, wchar_t ***av);
#else
@ -101,7 +106,7 @@ static void duplicate_ppstrings (int ac, char ***av);
static int __cdecl pre_c_init (void);
static void __cdecl pre_cpp_init (void);
static void __cdecl __mingw_prepare_except_for_msvcr80_and_higher (void);
_CRTALLOC(".CRT$XIAA") _PIFV mingw_pcinit = pre_c_init;
_CRTALLOC(".CRT$XCAA") _PVFV mingw_pcppinit = pre_cpp_init;
@ -115,8 +120,8 @@ pre_c_init (void)
__set_app_type (_CONSOLE_APP);
__onexitbegin = __onexitend = (_PVFV *) _encode_pointer ((_PVFV *)(-1));
*_imp___fmode = _fmode;
*_imp___commode = _commode;
* __MINGW_IMP_SYMBOL(_fmode) = _fmode;
* __MINGW_IMP_SYMBOL(_commode) = _commode;
#ifdef WPRFLAG
_wsetargv();
@ -152,6 +157,8 @@ pre_cpp_init (void)
static int __tmainCRTStartup (void);
int WinMainCRTStartup (void);
int WinMainCRTStartup (void)
{
mingw_app_type = 1;
@ -159,6 +166,12 @@ int WinMainCRTStartup (void)
return __tmainCRTStartup ();
}
int mainCRTStartup (void);
#ifdef _WIN64
int __mingw_init_ehandler (void);
#endif
int mainCRTStartup (void)
{
mingw_app_type = 0;
@ -166,13 +179,13 @@ int mainCRTStartup (void)
return __tmainCRTStartup ();
}
static
__declspec(noinline) int
__tmainCRTStartup (void)
{
_TCHAR *lpszCommandLine = NULL;
STARTUPINFO StartupInfo;
BOOL inDoubleQuote = FALSE;
WINBOOL inDoubleQuote = FALSE;
memset (&StartupInfo, 0, sizeof (STARTUPINFO));
if (mingw_app_type)
@ -212,16 +225,15 @@ __tmainCRTStartup (void)
if (! nested)
(VOID)InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
if (__dyn_tls_init_callback != NULL && _IsNonwritableInCurrentImage ((PBYTE) &__dyn_tls_init_callback))
if (__dyn_tls_init_callback != NULL)
__dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL);
_pei386_runtime_relocator ();
#if defined(__i386__) || defined(_M_IX86)
__writefsdword(0, 0xffffffff);
__mingw_oldexcpt_handler = SetUnhandledExceptionFilter (_gnu_exception_handler);
#ifdef _WIN64
__mingw_init_ehandler ();
#endif
//AddVectoredExceptionHandler (0, (PVECTORED_EXCEPTION_HANDLER)__mingw_vex);
SetUnhandledExceptionFilter (_gnu_exception_handler);
__mingw_prepare_except_for_msvcr80_and_higher ();
_fpreset ();
@ -239,7 +251,7 @@ __tmainCRTStartup (void)
#ifdef _MBCS
if (_ismbblead (*lpszCommandLine))
{
if (lpszCommandLine)
if (*lpszCommandLine)
lpszCommandLine++;
}
#endif
@ -248,21 +260,11 @@ __tmainCRTStartup (void)
while (*lpszCommandLine && (*lpszCommandLine <= SPACECHAR))
lpszCommandLine++;
#ifdef WPRFLAG
/* C++ initialization.
gcc inserts this call automatically for a function called main, but not for wmain. */
__main ();
mainret = wmain (
(int) (StartupInfo.dwFlags & STARTF_USESHOWWINDOW ? StartupInfo.wShowWindow : SW_SHOWDEFAULT),
(wchar_t **) lpszCommandLine, (wchar_t **) (HINSTANCE) &__ImageBase);
#else
mainret = main (
(int) (StartupInfo.dwFlags & STARTF_USESHOWWINDOW ? StartupInfo.wShowWindow : SW_SHOWDEFAULT),
(char **) lpszCommandLine, (char **) (HINSTANCE) &__ImageBase);
#endif
__mingw_winmain_hInstance = (HINSTANCE) &__ImageBase;
__mingw_winmain_lpCmdLine = lpszCommandLine;
__mingw_winmain_nShowCmd = StartupInfo.dwFlags & STARTF_USESHOWWINDOW ?
StartupInfo.wShowWindow : SW_SHOWDEFAULT;
}
else
{
duplicate_ppstrings (argc, &argv);
#ifdef WPRFLAG
__winitenv = envp;
@ -274,7 +276,6 @@ __tmainCRTStartup (void)
__initenv = envp;
mainret = main (argc, argv, envp);
#endif
}
if (!managedapp)
exit (mainret);
@ -399,42 +400,26 @@ _gnu_exception_handler (EXCEPTION_POINTERS * exception_data)
action = EXCEPTION_CONTINUE_EXECUTION;
}
break;
#ifdef _WIN64
case EXCEPTION_DATATYPE_MISALIGNMENT:
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
case EXCEPTION_FLT_STACK_CHECK:
case EXCEPTION_INT_OVERFLOW:
case EXCEPTION_INVALID_HANDLE:
/*case EXCEPTION_POSSIBLE_DEADLOCK: */
action = EXCEPTION_CONTINUE_EXECUTION;
break;
#endif
default:
break;
}
if (action == EXCEPTION_CONTINUE_SEARCH && __mingw_oldexcpt_handler)
action = (*__mingw_oldexcpt_handler)(exception_data);
return action;
}
#if 0
static LONG __mingw_vex(EXCEPTION_POINTERS * exception_data)
{
/* TODO this is not chainablem, therefore need rewrite. Disabled the ill code. */
#if 0
#ifdef _WIN64
__asm__ __volatile__ (
"movq %gs:0,%rax" "\n\t"
"orq %rax,%rax\n\t"
"jz l1\n\t"
"jmp *8(%rax)\n\r"
"l1:\n\t"
"nop\n");
#else
__asm__ __volatile__ (
"movl %fs:0,%eax" "\n\t"
"orl %eax,%eax\n\t"
"jz l1\n\t"
"jmp *4(%eax)\n\r"
"l1:\n\t"
"nop\n");
#endif
#endif
return _gnu_exception_handler(exception_data);
}
#endif
#ifdef WPRFLAG
static size_t wbytelen(const wchar_t *p)
{
size_t ret = 1;
@ -477,3 +462,35 @@ static void duplicate_ppstrings (int ac, char ***av)
*av = n;
}
#endif
static void
__mingw_invalidParameterHandler (const wchar_t *expression __attribute__ ((__unused__)),
const wchar_t *function __attribute__ ((__unused__)),
const wchar_t *file __attribute__ ((__unused__)),
unsigned int line __attribute__ ((__unused__)),
uintptr_t pReserved __attribute__ ((__unused__)))
{
#ifdef __MINGW_SHOW_INVALID_PARAMETER_EXCEPTION
wprintf(L"Invalid parameter detected in function %s. File: %s Line: %d\n", function, file, line);
wprintf(L"Expression: %s\n", expression);
#endif
}
static void __cdecl
__mingw_prepare_except_for_msvcr80_and_higher (void)
{
_invalid_parameter_handler (*fIPH)(_invalid_parameter_handler) = NULL;
HMODULE hmsv = GetModuleHandleA ("msvcr80.dll");
if(!hmsv)
hmsv = GetModuleHandleA ("msvcr70.dll");
if (!hmsv)
hmsv = GetModuleHandleA ("msvcrt.dll");
if (!hmsv)
hmsv = LoadLibraryA ("msvcrt.dll");
if (!hmsv)
return;
fIPH = (_invalid_parameter_handler (*)(_invalid_parameter_handler))
GetProcAddress (hmsv, "_set_invalid_parameter_handler");
if (fIPH)
(*fIPH)(__mingw_invalidParameterHandler);
}

25
reactos/lib/3rdparty/mingw/dll_argv.c vendored Normal file
View file

@ -0,0 +1,25 @@
/**
* 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.PD within this package.
*/
#ifdef CRTDLL
#undef CRTDLL
#endif
#include <internal.h>
extern int _dowildcard;
#ifdef WPRFLAG
int __CRTDECL
__wsetargv (void)
#else
int __CRTDECL
__setargv (void)
#endif
{
_dowildcard = 1;
return 0;
}

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#ifdef CRTDLL

View file

@ -1,14 +1,18 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <oscalls.h>
#define _DECL_DLLMAIN
#include <process.h>
BOOL WINAPI DllEntryPoint(HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
BOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID);
BOOL WINAPI DllEntryPoint (HANDLE hDllHandle __attribute__ ((__unused__)),
DWORD dwReason __attribute__ ((__unused__)),
LPVOID lpreserved __attribute__ ((__unused__)))
{
return TRUE;
}

View file

@ -2,7 +2,9 @@
#define _DECL_DLLMAIN
#include <process.h>
BOOL WINAPI DllMain(HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
BOOL WINAPI DllMain (HANDLE hDllHandle __attribute__ ((__unused__)),
DWORD dwReason __attribute__ ((__unused__)),
LPVOID lpreserved __attribute__ ((__unused__)))
{
return TRUE;
}

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
@ -13,11 +13,16 @@ extern func_ptr __CTOR_LIST__[];
extern func_ptr __DTOR_LIST__[];
static HMODULE hMsvcrt = NULL;
static int free_Msvcrt = 0;
typedef void __cdecl flongjmp(jmp_buf _Buf,int _Value);
flongjmp *fctMsvcrtLongJmp = NULL;
void __do_global_dtors (void);
void __do_global_ctors (void);
void __main (void);
void
__do_global_dtors (void)
{
@ -28,8 +33,9 @@ __do_global_dtors (void)
(*(p)) ();
p++;
}
if (hMsvcrt)
if (free_Msvcrt && hMsvcrt)
{
free_Msvcrt = 0;
FreeLibrary (hMsvcrt);
hMsvcrt = NULL;
}
@ -42,7 +48,15 @@ __do_global_ctors (void)
unsigned long i;
if (!hMsvcrt) {
hMsvcrt = LoadLibrary ("msvcrt.dll");
hMsvcrt = GetModuleHandleA ("msvcr80.dll");
if (!hMsvcrt)
hMsvcrt = GetModuleHandleA ("msvcr70.dll");
if (!hMsvcrt)
hMsvcrt = GetModuleHandleA ("msvcrt.dll");
if (!hMsvcrt) {
hMsvcrt = LoadLibraryA ("msvcrt.dll");
free_Msvcrt = 1;
}
fctMsvcrtLongJmp = (flongjmp *) GetProcAddress( hMsvcrt, "longjmp");
}

View file

@ -1,394 +0,0 @@
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include <stdarg.h>
#include <stdio.h>
#define REPLACE_GETOPT
#define _DIAGASSERT(x) do {} while (0)
#ifdef REPLACE_GETOPT
#ifdef __weak_alias
__weak_alias(getopt,_getopt)
#endif
int opterr = 1;
int optind = 1;
int optopt = '?';
int optreset;
char *optarg;
#endif
#ifdef __weak_alias
__weak_alias(getopt_long,_getopt_long)
#endif
#ifndef __CYGWIN__
#define __progname __argv[0]
#else
extern char __declspec(dllimport) *__progname;
#endif
#define IGNORE_FIRST (*options == '-' || *options == '+')
#define PRINT_ERROR ((opterr) && ((*options != ':') || (IGNORE_FIRST && options[1] != ':')))
#ifndef IS_POSIXLY_CORRECT
#define IS_POSIXLY_CORRECT (getenv("POSIXLY_CORRECT") != NULL)
#endif
#define PERMUTE (!IS_POSIXLY_CORRECT && !IGNORE_FIRST)
#define IN_ORDER (!IS_POSIXLY_CORRECT && *options == '-')
#define BADCH (int)'?'
#define BADARG ((IGNORE_FIRST && options[1] == ':') || (*options == ':') ? (int)':' : (int)'?')
#define INORDER (int)1
static char EMSG[1];
static int getopt_internal (int,char * const *,const char *);
static int gcd (int,int);
static void permute_args (int,int,int,char * const *);
static char *place = EMSG;
static int nonopt_start = -1;
static int nonopt_end = -1;
static const char recargchar[] = "option requires an argument -- %c";
static const char recargstring[] = "option requires an argument -- %s";
static const char ambig[] = "ambiguous option -- %.*s";
static const char noarg[] = "option doesn't take an argument -- %.*s";
static const char illoptchar[] = "unknown option -- %c";
static const char illoptstring[] = "unknown option -- %s";
static void
_vwarnx(const char *fmt,va_list ap)
{
(void)fprintf(stderr,"%s: ",__progname);
if (fmt != NULL)
(void)vfprintf(stderr,fmt,ap);
(void)fprintf(stderr,"\n");
}
static void
warnx(const char *fmt,...)
{
va_list ap;
va_start(ap,fmt);
_vwarnx(fmt,ap);
va_end(ap);
}
static int
gcd(a,b)
int a;
int b;
{
int c;
c = a % b;
while (c != 0) {
a = b;
b = c;
c = a % b;
}
return b;
}
static void
permute_args(panonopt_start,panonopt_end,opt_end,nargv)
int panonopt_start;
int panonopt_end;
int opt_end;
char * const *nargv;
{
int cstart,cyclelen,i,j,ncycle,nnonopts,nopts,pos;
char *swap;
_DIAGASSERT(nargv != NULL);
nnonopts = panonopt_end - panonopt_start;
nopts = opt_end - panonopt_end;
ncycle = gcd(nnonopts,nopts);
cyclelen = (opt_end - panonopt_start) / ncycle;
for (i = 0; i < ncycle; i++) {
cstart = panonopt_end+i;
pos = cstart;
for (j = 0; j < cyclelen; j++) {
if (pos >= panonopt_end)
pos -= nnonopts;
else
pos += nopts;
swap = nargv[pos];
((char **) nargv)[pos] = nargv[cstart];
((char **)nargv)[cstart] = swap;
}
}
}
static int
getopt_internal(nargc,nargv,options)
int nargc;
char * const *nargv;
const char *options;
{
char *oli;
int optchar;
_DIAGASSERT(nargv != NULL);
_DIAGASSERT(options != NULL);
optarg = NULL;
if (optind == 0)
optind = 1;
if (optreset)
nonopt_start = nonopt_end = -1;
start:
if (optreset || !*place) {
optreset = 0;
if (optind >= nargc) {
place = EMSG;
if (nonopt_end != -1) {
permute_args(nonopt_start,nonopt_end,optind,nargv);
optind -= nonopt_end - nonopt_start;
}
else if (nonopt_start != -1) {
optind = nonopt_start;
}
nonopt_start = nonopt_end = -1;
return -1;
}
if ((*(place = nargv[optind]) != '-')
|| (place[1] == '\0')) {
place = EMSG;
if (IN_ORDER) {
optarg = nargv[optind++];
return INORDER;
}
if (!PERMUTE) {
return -1;
}
if (nonopt_start == -1)
nonopt_start = optind;
else if (nonopt_end != -1) {
permute_args(nonopt_start,nonopt_end,optind,nargv);
nonopt_start = optind -
(nonopt_end - nonopt_start);
nonopt_end = -1;
}
optind++;
goto start;
}
if (nonopt_start != -1 && nonopt_end == -1)
nonopt_end = optind;
if (place[1] && *++place == '-') {
place++;
return -2;
}
}
if ((optchar = (int)*place++) == (int)':' ||
(oli = strchr(options + (IGNORE_FIRST ? 1 : 0),optchar)) == NULL) {
if (!*place)
++optind;
if (PRINT_ERROR)
warnx(illoptchar,optchar);
optopt = optchar;
return BADCH;
}
if (optchar == 'W' && oli[1] == ';') {
if (*place)
return -2;
if (++optind >= nargc) {
place = EMSG;
if (PRINT_ERROR)
warnx(recargchar,optchar);
optopt = optchar;
return BADARG;
} else
place = nargv[optind];
return -2;
}
if (*++oli != ':') {
if (!*place)
++optind;
} else {
optarg = NULL;
if (*place)
optarg = place;
else if (oli[1] != ':') {
if (++optind >= nargc) {
place = EMSG;
if (PRINT_ERROR)
warnx(recargchar,optchar);
optopt = optchar;
return BADARG;
} else
optarg = nargv[optind];
}
place = EMSG;
++optind;
}
return optchar;
}
#ifdef REPLACE_GETOPT
int
getopt(nargc,nargv,options)
int nargc;
char * const *nargv;
const char *options;
{
int retval;
_DIAGASSERT(nargv != NULL);
_DIAGASSERT(options != NULL);
if ((retval = getopt_internal(nargc,nargv,options)) == -2) {
++optind;
if (nonopt_end != -1) {
permute_args(nonopt_start,nonopt_end,optind,nargv);
optind -= nonopt_end - nonopt_start;
}
nonopt_start = nonopt_end = -1;
retval = -1;
}
return retval;
}
#endif
int
getopt_long(nargc,nargv,options,long_options,idx)
int nargc;
char * const *nargv;
const char *options;
const struct option *long_options;
int *idx;
{
int retval;
_DIAGASSERT(nargv != NULL);
_DIAGASSERT(options != NULL);
_DIAGASSERT(long_options != NULL);
if ((retval = getopt_internal(nargc,nargv,options)) == -2) {
char *current_argv,*has_equal;
size_t current_argv_len;
int i,match;
current_argv = place;
match = -1;
optind++;
place = EMSG;
if (*current_argv == '\0') {
if (nonopt_end != -1) {
permute_args(nonopt_start,nonopt_end,optind,nargv);
optind -= nonopt_end - nonopt_start;
}
nonopt_start = nonopt_end = -1;
return -1;
}
if ((has_equal = strchr(current_argv,'=')) != NULL) {
current_argv_len = has_equal - current_argv;
has_equal++;
} else
current_argv_len = strlen(current_argv);
for (i = 0; long_options[i].name; i++) {
if (strncmp(current_argv,long_options[i].name,current_argv_len))
continue;
if (strlen(long_options[i].name) ==
(unsigned)current_argv_len) {
match = i;
break;
}
if (match == -1)
match = i;
else {
if (PRINT_ERROR)
warnx(ambig,(int)current_argv_len,current_argv);
optopt = 0;
return BADCH;
}
}
if (match != -1) {
if (long_options[match].has_arg == no_argument
&& has_equal) {
if (PRINT_ERROR)
warnx(noarg,(int)current_argv_len,current_argv);
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
return BADARG;
}
if (long_options[match].has_arg == required_argument ||
long_options[match].has_arg == optional_argument) {
if (has_equal)
optarg = has_equal;
else if (long_options[match].has_arg ==
required_argument) {
optarg = nargv[optind++];
}
}
if ((long_options[match].has_arg == required_argument)
&& (optarg == NULL)) {
if (PRINT_ERROR)
warnx(recargstring,current_argv);
if (long_options[match].flag == NULL)
optopt = long_options[match].val;
else
optopt = 0;
--optind;
return BADARG;
}
} else {
if (PRINT_ERROR)
warnx(illoptstring,current_argv);
optopt = 0;
return BADCH;
}
if (long_options[match].flag) {
*long_options[match].flag = long_options[match].val;
retval = 0;
} else
retval = long_options[match].val;
if (idx)
*idx = match;
}
return retval;
}

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
@ -43,6 +43,8 @@ static const EXCEPTION_POINTERS GS_ExceptionPointers = {
DECLSPEC_SELECTANY UINT_PTR __security_cookie = DEFAULT_SECURITY_COOKIE;
DECLSPEC_SELECTANY UINT_PTR __security_cookie_complement = ~(DEFAULT_SECURITY_COOKIE);
void __cdecl __security_init_cookie (void);
void __cdecl
__security_init_cookie (void)
{
@ -86,6 +88,8 @@ __security_init_cookie (void)
__security_cookie_complement = ~cookie;
}
__declspec(noreturn) void __cdecl __report_gsfailure (ULONGLONG);
__declspec(noreturn) void __cdecl
__report_gsfailure (ULONGLONG StackCookie)
{

16
reactos/lib/3rdparty/mingw/isascii.c vendored Normal file
View file

@ -0,0 +1,16 @@
/**
* 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.PD within this package.
*/
#include <ctype.h>
#undef isascii
int isascii (int);
int
isascii (int c)
{
return __isascii(c);
}

16
reactos/lib/3rdparty/mingw/iscsym.c vendored Normal file
View file

@ -0,0 +1,16 @@
/**
* 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.PD within this package.
*/
#include <ctype.h>
#undef iscsym
int iscsym (int);
int
iscsym (int c)
{
return __iscsym(c);
}

16
reactos/lib/3rdparty/mingw/iscsymf.c vendored Normal file
View file

@ -0,0 +1,16 @@
/**
* 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.PD within this package.
*/
#include <ctype.h>
#undef iscsymf
int iscsymf (int);
int
iscsymf (int c)
{
return __iscsymf(c);
}

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <internal.h>

View file

@ -11,13 +11,15 @@
<library>kernel32</library>
<file>_newmode.c</file>
<file>atonexit.c</file>
<file>binmode.c</file>
<file>charmax.c</file>
<file>cinitexe.c</file>
<file>CRT_fp10.c</file>
<file>CRT_fp8.c</file>
<file>CRT_glob.c</file>
<file>crt_handler.c</file>
<file>dllentry.c</file>
<file>gccmain.c</file>
<file>getopt.c</file>
<file>gs_support.c</file>
<file>merr.c</file>
<file>mingw_helpers.c</file>
@ -25,7 +27,10 @@
<file>pesect.c</file>
<file>pseudo-reloc.c</file>
<file>pseudo-reloc-list.c</file>
<file>tlsmcrt.c</file>
<file>tlssup.c</file>
<file>tlsthrd.c</file>
<file>txtmode.c</file>
<file>wildcard.c</file>
<file>xncommod.c</file>
<file>xthdloc.c</file>

View file

@ -0,0 +1,16 @@
/**
* 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.PD within this package.
*/
#include <_mingw.h>
#include "../revstamp.h"
const char *__mingw_get_crt_info (void)
{
return "MinGW-W64 Runtime " __MINGW64_VERSION_STR " ("
__MINGW64_VERSION_STATE " - "
"rev. " __MINGW_W64_REV ") " __MINGW_W64_REV_STAMP;
}

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <oscalls.h>

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <crtdefs.h>

View file

@ -1,21 +1,24 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#include <windows.h>
#include <string.h>
#if defined (_WIN64) && defined (__ia64__)
#error FIXME: Unsupported __ImageBase implementation.
#else
/* Hack, for bug in ld. Will be removed soon. */
#define __ImageBase _image_base__
#define __ImageBase __MINGW_LSYMBOL(_image_base__)
/* This symbol is defined by the linker. */
extern IMAGE_DOS_HEADER __ImageBase;
#endif
BOOL
WINBOOL _ValidateImageBase (PBYTE);
WINBOOL
_ValidateImageBase (PBYTE pImageBase)
{
PIMAGE_DOS_HEADER pDOSHeader;
@ -34,6 +37,8 @@ _ValidateImageBase (PBYTE pImageBase)
return TRUE;
}
PIMAGE_SECTION_HEADER _FindPESection (PBYTE, DWORD_PTR);
PIMAGE_SECTION_HEADER
_FindPESection (PBYTE pImageBase, DWORD_PTR rva)
{
@ -54,7 +59,81 @@ _FindPESection (PBYTE pImageBase, DWORD_PTR rva)
return NULL;
}
BOOL
PIMAGE_SECTION_HEADER _FindPESectionByName (const char *);
PIMAGE_SECTION_HEADER
_FindPESectionByName (const char *pName)
{
PBYTE pImageBase;
PIMAGE_NT_HEADERS pNTHeader;
PIMAGE_SECTION_HEADER pSection;
unsigned int iSection;
/* Long names aren't supported. */
if (strlen (pName) > IMAGE_SIZEOF_SHORT_NAME)
return NULL;
pImageBase = (PBYTE) &__ImageBase;
if (! _ValidateImageBase (pImageBase))
return NULL;
pNTHeader = (PIMAGE_NT_HEADERS) (pImageBase + ((PIMAGE_DOS_HEADER) pImageBase)->e_lfanew);
for (iSection = 0, pSection = IMAGE_FIRST_SECTION (pNTHeader);
iSection < pNTHeader->FileHeader.NumberOfSections;
++iSection,++pSection)
{
if (!strncmp ((char *) &pSection->Name[0], pName, IMAGE_SIZEOF_SHORT_NAME))
return pSection;
}
return NULL;
}
PIMAGE_SECTION_HEADER _FindPESectionExec (size_t);
PIMAGE_SECTION_HEADER
_FindPESectionExec (size_t eNo)
{
PBYTE pImageBase;
PIMAGE_NT_HEADERS pNTHeader;
PIMAGE_SECTION_HEADER pSection;
unsigned int iSection;
pImageBase = (PBYTE) &__ImageBase;
if (! _ValidateImageBase (pImageBase))
return NULL;
pNTHeader = (PIMAGE_NT_HEADERS) (pImageBase + ((PIMAGE_DOS_HEADER) pImageBase)->e_lfanew);
for (iSection = 0, pSection = IMAGE_FIRST_SECTION (pNTHeader);
iSection < pNTHeader->FileHeader.NumberOfSections;
++iSection,++pSection)
{
if ((pSection->Characteristics & IMAGE_SCN_MEM_EXECUTE) != 0)
{
if (!eNo)
return pSection;
--eNo;
}
}
return NULL;
}
PBYTE _GetPEImageBase (void);
PBYTE
_GetPEImageBase (void)
{
PBYTE pImageBase;
pImageBase = (PBYTE) &__ImageBase;
if (! _ValidateImageBase (pImageBase))
return NULL;
return pImageBase;
}
WINBOOL _IsNonwritableInCurrentImage (PBYTE);
WINBOOL
_IsNonwritableInCurrentImage (PBYTE pTarget)
{
PBYTE pImageBase;

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
char __RUNTIME_PSEUDO_RELOC_LIST_END__ = 0;

View file

@ -1,23 +1,71 @@
/**
* 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.
/* pseudo-reloc.c
Contributed by Egor Duda <deo@logos-m.ru>
Modified by addition of runtime_pseudo_reloc version 2
by Kai Tietz <kai.tietz@onevision.com>
THIS SOFTWARE IS NOT COPYRIGHTED
This source code is offered for use in the public domain. You may
use, modify or distribute it freely.
This code is distributed in the hope that it will be useful but
WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY
DISCLAMED. This includes but is not limited to warrenties of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <memory.h>
#if defined(__CYGWIN__)
#include <wchar.h>
#include <ntdef.h>
#include <sys/cygwin.h>
/* copied from winsup.h */
# define NO_COPY __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy")))
/* custom status code: */
#define STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION ((NTSTATUS) 0xe0000269)
#define SHORT_MSG_BUF_SZ 128
#else
# define NO_COPY
#endif
#ifdef __GNUC__
#define ATTRIBUTE_NORETURN __attribute__ ((noreturn))
#else
#define ATTRIBUTE_NORETURN
#endif
#ifndef __MINGW_LSYMBOL
#define __MINGW_LSYMBOL(sym) sym
#endif
extern char __RUNTIME_PSEUDO_RELOC_LIST__;
extern char __RUNTIME_PSEUDO_RELOC_LIST_END__;
extern char _image_base__;
extern char __MINGW_LSYMBOL(_image_base__);
void _pei386_runtime_relocator (void);
/* v1 relocation is basically:
* *(base + .target) += .addend
* where (base + .target) is always assumed to point
* to a DWORD (4 bytes).
*/
typedef struct {
DWORD addend;
DWORD target;
} runtime_pseudo_reloc_item_v1;
/* v2 relocation is more complex. In effect, it is
* *(base + .target) += *(base + .sym) - (base + .sym)
* with care taken in both reading, sign extension, and writing
* because .flags may indicate that (base + .target) may point
* to a BYTE, WORD, DWORD, or QWORD (w64).
*/
typedef struct {
DWORD sym;
DWORD target;
@ -30,20 +78,118 @@ typedef struct {
DWORD version;
} runtime_pseudo_reloc_v2;
static void ATTRIBUTE_NORETURN
__report_error (const char *msg, ...)
{
#ifdef __CYGWIN__
/* This function is used to print short error messages
* to stderr, which may occur during DLL initialization
* while fixing up 'pseudo' relocations. This early, we
* may not be able to use cygwin stdio functions, so we
* use the win32 WriteFile api. This should work with both
* normal win32 console IO handles, redirected ones, and
* cygwin ptys.
*/
char buf[SHORT_MSG_BUF_SZ];
wchar_t module[MAX_PATH];
char * posix_module = NULL;
static const char UNKNOWN_MODULE[] = "<unknown module>: ";
static const size_t UNKNOWN_MODULE_LEN = sizeof (UNKNOWN_MODULE) - 1;
static const char CYGWIN_FAILURE_MSG[] = "Cygwin runtime failure: ";
static const size_t CYGWIN_FAILURE_MSG_LEN = sizeof (CYGWIN_FAILURE_MSG) - 1;
DWORD len;
DWORD done;
va_list args;
HANDLE errh = GetStdHandle (STD_ERROR_HANDLE);
ssize_t modulelen = GetModuleFileNameW (NULL, module, sizeof (module));
if (errh == INVALID_HANDLE_VALUE)
cygwin_internal (CW_EXIT_PROCESS,
STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION,
1);
if (modulelen > 0)
posix_module = cygwin_create_path (CCP_WIN_W_TO_POSIX, module);
va_start (args, msg);
len = (DWORD) vsnprintf (buf, SHORT_MSG_BUF_SZ, msg, args);
va_end (args);
buf[SHORT_MSG_BUF_SZ-1] = '\0'; /* paranoia */
if (posix_module)
{
WriteFile (errh, (PCVOID)CYGWIN_FAILURE_MSG,
CYGWIN_FAILURE_MSG_LEN, &done, NULL);
WriteFile (errh, (PCVOID)posix_module,
strlen(posix_module), &done, NULL);
WriteFile (errh, (PCVOID)": ", 2, &done, NULL);
WriteFile (errh, (PCVOID)buf, len, &done, NULL);
free (posix_module);
}
else
{
WriteFile (errh, (PCVOID)CYGWIN_FAILURE_MSG,
CYGWIN_FAILURE_MSG_LEN, &done, NULL);
WriteFile (errh, (PCVOID)UNKNOWN_MODULE,
UNKNOWN_MODULE_LEN, &done, NULL);
WriteFile (errh, (PCVOID)buf, len, &done, NULL);
}
WriteFile (errh, (PCVOID)"\n", 1, &done, NULL);
cygwin_internal (CW_EXIT_PROCESS,
STATUS_ILLEGAL_DLL_PSEUDO_RELOCATION,
1);
/* not reached, but silences noreturn warning */
abort ();
#else
va_list argp;
va_start (argp, msg);
# ifdef __MINGW64_VERSION_MAJOR
fprintf (stderr, "Mingw-w64 runtime failure:\n");
# else
fprintf (stderr, "Mingw runtime failure:\n");
# endif
vfprintf (stderr, msg, argp);
va_end (argp);
abort ();
#endif
}
/* This function temporarily marks the page containing addr
* writable, before copying len bytes from *src to *addr, and
* then restores the original protection settings to the page.
*
* Using this function eliminates the requirement with older
* pseudo-reloc implementations, that sections containing
* pseudo-relocs (such as .text and .rdata) be permanently
* marked writable. This older behavior sabotaged any memory
* savings achieved by shared libraries on win32 -- and was
* slower, too. However, on cygwin as of binutils 2.20 the
* .text section is still marked writable, and the .rdata section
* is folded into the (writable) .data when --enable-auto-import.
*/
static void
__write_memory (void *addr, const void *src, size_t len)
{
MEMORY_BASIC_INFORMATION b;
DWORD oldprot;
if (!len)
return;
if (!VirtualQuery (addr, &b, sizeof(b)))
abort ();
// Protect
{
__report_error (" VirtualQuery failed for %d bytes at address %p",
(int) sizeof(b), addr);
}
/* Temporarily allow write access to read-only protected memory. */
if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE)
VirtualProtect (b.BaseAddress, b.RegionSize, PAGE_EXECUTE_READWRITE,
&oldprot);
/* write the data. */
memcpy (addr, src, len);
/* Restore original protection. */
if (b.Protect != PAGE_EXECUTE_READWRITE && b.Protect != PAGE_READWRITE)
VirtualProtect (b.BaseAddress, b.RegionSize, oldprot, &oldprot);
}
@ -59,17 +205,56 @@ do_pseudo_reloc (void* start,void *end,void *base)
runtime_pseudo_reloc_v2 *v2_hdr = (runtime_pseudo_reloc_v2 *) start;
runtime_pseudo_reloc_item_v2 *r;
/* A valid relocation list will contain at least one entry, and
* one v1 data structure (the smallest one) requires two DWORDs.
* So, if the relocation list is smaller than 8 bytes, bail.
*/
if (reloc_target < 8)
return;
/* Check if this is old version pseudo relocation version. */
/* Check if this is the old pseudo relocation version. */
/* There are two kinds of v1 relocation lists:
* 1) With a (v2-style) version header. In this case, the
* first entry in the list is a 3-DWORD structure, with
* value:
* { 0, 0, RP_VERSION_V1 }
* In this case, we skip to the next entry in the list,
* knowing that all elements after the head item can
* be cast to runtime_pseudo_reloc_item_v1.
* 2) Without a (v2-style) version header. In this case, the
* first element in the list IS an actual v1 relocation
* record, which is two DWORDs. Because there will never
* be a case where a v1 relocation record has both
* addend == 0 and target == 0, this case will not be
* confused with the prior one.
* All current binutils, when generating a v1 relocation list,
* use the second (e.g. original) form -- that is, without the
* v2-style version header.
*/
if (reloc_target >= 12
&& v2_hdr->magic1 == 0 && v2_hdr->magic2 == 0
&& v2_hdr->version == RP_VERSION_V1)
{
/* We have a list header item indicating that the rest
* of the list contains v1 entries. Move the pointer to
* the first true v1 relocation record. By definition,
* that v1 element will not have both addend == 0 and
* target == 0 (and thus, when interpreted as a
* runtime_pseudo_reloc_v2, it will not have both
* magic1 == 0 and magic2 == 0).
*/
v2_hdr++;
}
if (v2_hdr->magic1 != 0 || v2_hdr->magic2 != 0)
{
/*************************
* Handle v1 relocations *
*************************/
runtime_pseudo_reloc_item_v1 * o;
for (o = (runtime_pseudo_reloc_item_v1 *) v2_hdr; o < (runtime_pseudo_reloc_item_v1 *)end; o++)
for (o = (runtime_pseudo_reloc_item_v1 *) v2_hdr;
o < (runtime_pseudo_reloc_item_v1 *)end;
o++)
{
DWORD newval;
reloc_target = (ptrdiff_t) base + o->target;
@ -78,22 +263,41 @@ do_pseudo_reloc (void* start,void *end,void *base)
}
return;
}
/* If we got this far, then we have relocations of version 2 or newer */
/* Check if this is a known version. */
if (v2_hdr->version != RP_VERSION_V2)
{
fprintf (stderr, "pseudo_relocation protocol version %d is unknown to this runtime.\n",
__report_error (" Unknown pseudo relocation protocol version %d.\n",
(int) v2_hdr->version);
return;
}
/*************************
* Handle v2 relocations *
*************************/
/* Walk over header. */
r = (runtime_pseudo_reloc_item_v2 *) &v2_hdr[1];
for (; r < (runtime_pseudo_reloc_item_v2 *) end; r++)
{
/* location where new address will be written */
reloc_target = (ptrdiff_t) base + r->target;
/* get sym pointer. It points either to the iat entry
* of the referenced element, or to the stub function.
*/
addr_imp = (ptrdiff_t) base + r->sym;
addr_imp = *((ptrdiff_t *) addr_imp);
/* read existing relocation value from image, casting to the
* bitsize indicated by the 8 LSBs of flags. If the value is
* negative, manually sign-extend to ptrdiff_t width. Raise an
* error if the bitsize indicated by the 8 LSBs of flags is not
* supported.
*/
switch ((r->flags & 0xff))
{
case 8:
@ -120,11 +324,16 @@ do_pseudo_reloc (void* start,void *end,void *base)
#endif
default:
reldata=0;
fprintf(stderr, "Unknown pseudo relocation bit size %d\n",(int) (r->flags & 0xff));
__report_error (" Unknown pseudo relocation bit size %d.\n",
(int) (r->flags & 0xff));
break;
}
/* Adjust the relocation value */
reldata -= ((ptrdiff_t) base + r->sym);
reldata += addr_imp;
/* Write the new relocation value back to *reloc_target */
switch ((r->flags & 0xff))
{
case 8:
@ -146,11 +355,13 @@ do_pseudo_reloc (void* start,void *end,void *base)
}
void
_pei386_runtime_relocator ()
_pei386_runtime_relocator (void)
{
static int was_init = 0;
static NO_COPY int was_init = 0;
if (was_init)
return;
++was_init;
do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,&__RUNTIME_PSEUDO_RELOC_LIST_END__,&_image_base__);
do_pseudo_reloc (&__RUNTIME_PSEUDO_RELOC_LIST__,
&__RUNTIME_PSEUDO_RELOC_LIST_END__,
&__MINGW_LSYMBOL(_image_base__));
}

87
reactos/lib/3rdparty/mingw/reactos.diff vendored Normal file
View file

@ -0,0 +1,87 @@
Index: CRT_fp10.c
===================================================================
--- CRT_fp10.c (Revision 43956)
+++ CRT_fp10.c (Arbeitskopie)
@@ -7,6 +7,16 @@
void _fpreset (void);
void _fpreset (void)
- { __asm__ ("fninit" ) ;}
+{
+#ifdef __GNUC__
+ __asm__ ("fninit" );
+#else
+ __asm fninit;
+#endif
+}
+#ifdef __GNUC__
void __attribute__ ((alias ("_fpreset"))) fpreset(void);
+#else
+void fpreset(void) { _fpreset(); }
+#endif
Index: CRT_fp8.c
===================================================================
--- CRT_fp8.c (Revision 43956)
+++ CRT_fp8.c (Arbeitskopie)
@@ -14,4 +14,8 @@
(* __MINGW_IMP_SYMBOL(_fpreset))();
}
+#ifdef __GNUC__
void __attribute__ ((alias ("_fpreset"))) fpreset(void);
+#else
+void fpreset(void) { _fpreset(); }
+#endif
Index: crtexe.c
===================================================================
--- crtexe.c (Revision 43956)
+++ crtexe.c (Arbeitskopie)
@@ -20,6 +20,7 @@
#include <tchar.h>
#include <sect_attribs.h>
#include <locale.h>
+#include <intrin.h>
#ifndef __winitenv
extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
@@ -51,7 +52,11 @@
#define _commode (* __MINGW_IMP_SYMBOL(_commode))
extern int _dowildcard;
+#if defined(__GNUC__)
int _MINGW_INSTALL_DEBUG_MATHERR __attribute__((weak)) = 0;
+#else
+int _MINGW_INSTALL_DEBUG_MATHERR = 0;
+#endif
extern int __defaultmatherr;
extern _CRTIMP void __cdecl _initterm(_PVFV *, _PVFV *);
Index: gs_support.c
===================================================================
--- gs_support.c (Revision 43956)
+++ gs_support.c (Arbeitskopie)
@@ -112,6 +112,7 @@
else
#endif
{
+#ifdef __GNUC__
#ifdef _WIN64
GS_ContextRecord.Rip = (ULONGLONG) __builtin_return_address (0);
GS_ContextRecord.Rsp = (ULONGLONG) __builtin_frame_address (0) + 8;
@@ -119,6 +120,15 @@
GS_ContextRecord.Eip = (DWORD) __builtin_return_address (0);
GS_ContextRecord.Esp = (DWORD) __builtin_frame_address (0) + 4;
#endif
+#else
+#ifdef _WIN64
+ GS_ContextRecord.Rip = (ULONGLONG) _ReturnAddress();
+ GS_ContextRecord.Rsp = (ULONGLONG) _AddressOfReturnAddress();
+#else
+ GS_ContextRecord.Eip = (DWORD) _ReturnAddress();
+ GS_ContextRecord.Esp = (DWORD) _AddressOfReturnAddress();
+#endif
+#endif
}
#ifdef _WIN64

16
reactos/lib/3rdparty/mingw/strcasecmp.c vendored Normal file
View file

@ -0,0 +1,16 @@
/**
* 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.PD within this package.
*/
#define __CRT__NO_INLINE
#include <string.h>
#undef strcasecmp
int strcasecmp (const char *, const char *);
int
strcasecmp (const char *sz1, const char *sz2)
{
return _stricmp (sz1,sz2);
}

View file

@ -0,0 +1,17 @@
/**
* 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.PD within this package.
*/
#define __CRT__NO_INLINE
#include <string.h>
#undef strncasecmp
int strncasecmp (const char *, const char *, size_t);
int
strncasecmp (const char *sz1,const char *sz2,size_t sizeMaxCompare)
{
return _strnicmp (sz1,sz2,sizeMaxCompare);
}

13
reactos/lib/3rdparty/mingw/tlsmcrt.c vendored Normal file
View file

@ -0,0 +1,13 @@
/**
* 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.PD within this package.
*
* Written by Kai Tietz <kai.tietz@onevision.com>
*/
/* We support TLS cleanup code in any case. If shared version of libgcc is used _CRT_MT has value 1,
otherwise
we do tls cleanup in runtime and _CRT_MT has value 2. */
int _CRT_MT = 2;

59
reactos/lib/3rdparty/mingw/tlsmthread.c vendored Normal file
View file

@ -0,0 +1,59 @@
/**
* 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.PD within this package.
*
* Written by Kai Tietz <kai.tietz@onevision.com>
*/
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <stdlib.h>
int __mingwthr_key_dtor (DWORD key, void (*dtor)(void *));
int __mingwthr_remove_key_dtor (DWORD key);
extern int ___w64_mingwthr_remove_key_dtor (DWORD key);
extern int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *));
#ifndef _WIN64
#define MINGWM10_DLL "mingwm10.dll"
typedef int (*fMTRemoveKeyDtor)(DWORD key);
typedef int (*fMTKeyDtor)(DWORD key, void (*dtor)(void *));
extern fMTRemoveKeyDtor __mingw_gMTRemoveKeyDtor;
extern fMTKeyDtor __mingw_gMTKeyDtor;
extern int __mingw_usemthread_dll;
#endif
int
__mingwthr_remove_key_dtor (DWORD key)
{
#ifndef _WIN64
if (!__mingw_usemthread_dll)
#endif
return ___w64_mingwthr_remove_key_dtor (key);
#ifndef _WIN64
if (__mingw_gMTRemoveKeyDtor)
return (*__mingw_gMTRemoveKeyDtor) (key);
return 0;
#endif
}
int
__mingwthr_key_dtor (DWORD key, void (*dtor)(void *))
{
if (dtor)
{
#ifndef _WIN64
if (!__mingw_usemthread_dll)
#endif
return ___w64_mingwthr_add_key_dtor (key, dtor);
#ifndef _WIN64
if (__mingw_gMTKeyDtor)
return (*__mingw_gMTKeyDtor) (key, dtor);
#endif
}
return 0;
}

View file

@ -1,18 +1,32 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*
* Written by Kai Tietz <kai.tietz@onevision.com>
*/
#ifdef CRTDLL
#undef CRTDLL
#endif
#include <internal.h>
#include <sect_attribs.h>
#include <windows.h>
#include <stdio.h>
#include <memory.h>
#include <malloc.h>
#include <crtdbg.h>
#ifndef _CRTALLOC
#define _CRTALLOC(x) __attribute__ ((section (x) ))
#endif
#ifndef __INTERNAL_FUNC_DEFINED
#define __INTERNAL_FUNC_DEFINED
typedef void (__cdecl *_PVFV)(void);
typedef int (__cdecl *_PIFV)(void);
typedef void (__cdecl *_PVFI)(int);
#endif
extern WINBOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved);
#define FUNCS_PER_NODE 30
@ -24,20 +38,21 @@ typedef struct TlsDtorNode {
ULONG _tls_index = 0;
_CRTALLOC(".tls") char _tls_start = 0;
/* TLS raw template data start and end. */
_CRTALLOC(".tls$AAA") char _tls_start = 0;
_CRTALLOC(".tls$ZZZ") char _tls_end = 0;
_CRTALLOC(".CRT$XLA") PIMAGE_TLS_CALLBACK __xl_a = 0;
_CRTALLOC(".CRT$XLZ") PIMAGE_TLS_CALLBACK __xl_z = 0;
#ifdef _WIN64
_CRTALLOC(".rdata$T") const IMAGE_TLS_DIRECTORY64 _tls_used = {
(ULONGLONG) &_tls_start, (ULONGLONG) &_tls_end, (ULONGLONG) &_tls_index,
_CRTALLOC(".tls") const IMAGE_TLS_DIRECTORY64 _tls_used = {
(ULONGLONG) &_tls_start+1, (ULONGLONG) &_tls_end, (ULONGLONG) &_tls_index,
(ULONGLONG) (&__xl_a+1), (ULONG) 0, (ULONG) 0
};
#else
_CRTALLOC(".rdata$T") const IMAGE_TLS_DIRECTORY _tls_used = {
(ULONG)(ULONG_PTR) &_tls_start, (ULONG)(ULONG_PTR) &_tls_end,
_CRTALLOC(".tls") const IMAGE_TLS_DIRECTORY _tls_used = {
(ULONG)(ULONG_PTR) &_tls_start+1, (ULONG)(ULONG_PTR) &_tls_end,
(ULONG)(ULONG_PTR) &_tls_index, (ULONG)(ULONG_PTR) (&__xl_a+1),
(ULONG) 0, (ULONG) 0
};
@ -47,38 +62,93 @@ _CRTALLOC(".rdata$T") const IMAGE_TLS_DIRECTORY _tls_used = {
#ifdef HAVE_ATTRIBUTE_THREAD
#define __CRT_THREAD __declspec(thread)
#else
#define __CRT_THREAD
#define __CRT_THREAD __thread
#endif
#endif
#define DISABLE_MS_TLS 1
static _CRTALLOC(".CRT$XDA") _PVFV __xd_a = 0;
static _CRTALLOC(".CRT$XDZ") _PVFV __xd_z = 0;
#if !defined (DISABLE_MS_TLS)
static __CRT_THREAD TlsDtorNode *dtor_list;
static __CRT_THREAD TlsDtorNode dtor_list_head;
#endif
extern int _CRT_MT;
#ifndef _WIN64
#define MINGWM10_DLL "mingwm10.dll"
typedef int (*fMTRemoveKeyDtor)(DWORD key);
typedef int (*fMTKeyDtor)(DWORD key, void (*dtor)(void *));
fMTRemoveKeyDtor __mingw_gMTRemoveKeyDtor;
fMTKeyDtor __mingw_gMTKeyDtor;
int __mingw_usemthread_dll;
static HANDLE __mingw_mthread_hdll;
#endif
BOOL WINAPI __dyn_tls_init (HANDLE, DWORD, LPVOID);
BOOL WINAPI
__dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
_PVFV *pfunc;
if (dwReason != DLL_THREAD_ATTACH)
#ifndef _WIN64
if (_winmajor < 4)
{
__mingw_usemthread_dll = 1;
__mingw_mthread_hdll = LoadLibrary (MINGWM10_DLL);
if (__mingw_mthread_hdll != NULL)
{
__mingw_gMTRemoveKeyDtor = (fMTRemoveKeyDtor) GetProcAddress (__mingw_mthread_hdll, "__mingwthr_remove_key_dtor");
__mingw_gMTKeyDtor = (fMTKeyDtor) GetProcAddress (__mingw_mthread_hdll, "__mingwthr_key_dtor");
}
if (__mingw_mthread_hdll == NULL || !__mingw_gMTRemoveKeyDtor || !__mingw_gMTKeyDtor)
{
__mingw_gMTKeyDtor = NULL;
__mingw_gMTRemoveKeyDtor = NULL;
if (__mingw_mthread_hdll)
FreeLibrary (__mingw_mthread_hdll);
__mingw_mthread_hdll = NULL;
_CRT_MT = 0;
return TRUE;
}
_CRT_MT = 1;
return TRUE;
}
#endif
/* We don't let us trick here. */
if (_CRT_MT != 2)
_CRT_MT = 2;
if (dwReason != DLL_THREAD_ATTACH)
{
if (dwReason == DLL_PROCESS_ATTACH)
__mingw_TLScallback (hDllHandle, dwReason, lpreserved);
return TRUE;
}
for (pfunc = &__xd_a + 1; pfunc != &__xd_z; ++pfunc)
{
if (*pfunc != NULL)
(*pfunc)();
}
return TRUE;
}
const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback = (const PIMAGE_TLS_CALLBACK) __dyn_tls_init;
_CRTALLOC(".CRT$XLC") PIMAGE_TLS_CALLBACK __xl_c = (PIMAGE_TLS_CALLBACK) __dyn_tls_init;
int __cdecl __tlregdtor (_PVFV);
int __cdecl
__tlregdtor (_PVFV func)
{
if (!func)
return 0;
#if !defined (DISABLE_MS_TLS)
if (dtor_list == NULL)
{
dtor_list = &dtor_list_head;
@ -96,18 +166,28 @@ __tlregdtor (_PVFV func)
dtor_list->count = 0;
}
dtor_list->funcs[dtor_list->count++] = func;
#endif
return 0;
}
static BOOL WINAPI
__dyn_tls_dtor (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
{
#if !defined (DISABLE_MS_TLS)
TlsDtorNode *pnode, *pnext;
int i;
#endif
if (dwReason != DLL_THREAD_DETACH && dwReason != DLL_PROCESS_DETACH)
return TRUE;
/* As TLS variables are detroyed already by DLL_THREAD_DETACH
call, we have to avoid access on the possible DLL_PROCESS_DETACH
call the already destroyed TLS vars.
TODO: The used local thread based variables have to be handled
manually, so that we can control their lifetime here. */
#if !defined (DISABLE_MS_TLS)
if (dwReason != DLL_PROCESS_DETACH)
{
for (pnode = dtor_list; pnode != NULL; pnode = pnext)
{
for (i = pnode->count - 1; i >= 0; --i)
@ -119,6 +199,9 @@ __dyn_tls_dtor (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
if (pnext != NULL)
free ((void *) pnode);
}
}
#endif
__mingw_TLScallback (hDllHandle, dwReason, lpreserved);
return TRUE;
}

148
reactos/lib/3rdparty/mingw/tlsthrd.c vendored Normal file
View file

@ -0,0 +1,148 @@
/**
* 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.PD within this package.
*
* Written by Kai Tietz <kai.tietz@onevision.com>
*
* This file is used by if gcc is built with --enable-threads=win32.
*
* Based on version created by Mumit Khan <khan@nanotech.wisc.edu>
*
*/
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#include <stdlib.h>
WINBOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved);
int ___w64_mingwthr_remove_key_dtor (DWORD key);
int ___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *));
/* To protect the thread/key association data structure modifications. */
static CRITICAL_SECTION __mingwthr_cs;
static volatile int __mingwthr_cs_init = 0;
typedef struct __mingwthr_key __mingwthr_key_t;
/* The list of threads active with key/dtor pairs. */
struct __mingwthr_key {
DWORD key;
void (*dtor)(void *);
__mingwthr_key_t volatile *next;
};
static __mingwthr_key_t volatile *key_dtor_list;
int
___w64_mingwthr_add_key_dtor (DWORD key, void (*dtor)(void *))
{
__mingwthr_key_t *new_key;
if (__mingwthr_cs_init == 0)
return 0;
new_key = (__mingwthr_key_t *) calloc (1, sizeof (__mingwthr_key_t));
if (new_key == NULL)
return -1;
new_key->key = key;
new_key->dtor = dtor;
EnterCriticalSection (&__mingwthr_cs);
new_key->next = key_dtor_list;
key_dtor_list = new_key;
LeaveCriticalSection (&__mingwthr_cs);
return 0;
}
int
___w64_mingwthr_remove_key_dtor (DWORD key)
{
__mingwthr_key_t volatile *prev_key;
__mingwthr_key_t volatile *cur_key;
if (__mingwthr_cs_init == 0)
return 0;
EnterCriticalSection (&__mingwthr_cs);
prev_key = NULL;
cur_key = key_dtor_list;
while (cur_key != NULL)
{
if ( cur_key->key == key)
{
if (prev_key == NULL)
key_dtor_list = cur_key->next;
else
prev_key->next = cur_key->next;
free ((void*)cur_key);
break;
}
prev_key = cur_key;
cur_key = cur_key->next;
}
LeaveCriticalSection (&__mingwthr_cs);
return 0;
}
static void
__mingwthr_run_key_dtors (void)
{
__mingwthr_key_t volatile *keyp;
if (__mingwthr_cs_init == 0)
return;
EnterCriticalSection (&__mingwthr_cs);
for (keyp = key_dtor_list; keyp; )
{
LPVOID value = TlsGetValue (keyp->key);
if (GetLastError () == ERROR_SUCCESS)
{
if (value)
(*keyp->dtor) (value);
}
keyp = keyp->next;
}
LeaveCriticalSection (&__mingwthr_cs);
}
WINBOOL
__mingw_TLScallback (HANDLE hDllHandle __attribute__ ((__unused__)),
DWORD reason,
LPVOID reserved __attribute__ ((__unused__)))
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
if (__mingwthr_cs_init == 0)
InitializeCriticalSection (&__mingwthr_cs);
__mingwthr_cs_init = 1;
break;
case DLL_PROCESS_DETACH:
__mingwthr_run_key_dtors();
if (__mingwthr_cs_init == 1)
{
__mingwthr_cs_init = 0;
DeleteCriticalSection (&__mingwthr_cs);
}
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
__mingwthr_run_key_dtors();
break;
}
return TRUE;
}

17
reactos/lib/3rdparty/mingw/toascii.c vendored Normal file
View file

@ -0,0 +1,17 @@
/**
* 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.PD within this package.
*/
#include <ctype.h>
#undef toascii
int toascii (int);
int
toascii (int c)
{
return __toascii(c);
}

13
reactos/lib/3rdparty/mingw/txtmode.c vendored Normal file
View file

@ -0,0 +1,13 @@
/**
* 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.PD within this package.
*/
#include <fcntl.h>
/* Set default file mode to text */
/* Is this correct? Default value of _fmode in msvcrt.dll is 0. */
int _fmode = _O_TEXT;

14
reactos/lib/3rdparty/mingw/ucrtexe.c vendored Normal file
View file

@ -0,0 +1,14 @@
/**
* 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.PD within this package.
*/
#ifndef UNICODE
#define UNICODE
#endif
#define WPRFLAG 1
#include "crtexe.c"

14
reactos/lib/3rdparty/mingw/udll_argv.c vendored Normal file
View file

@ -0,0 +1,14 @@
/**
* 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.PD within this package.
*/
#ifndef UNICODE
#define UNICODE
#endif
#define WPRFLAG 1
#include "dll_argv.c"

14
reactos/lib/3rdparty/mingw/udllargc.c vendored Normal file
View file

@ -0,0 +1,14 @@
/**
* 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.PD within this package.
*/
#ifndef UNICODE
#define UNICODE
#endif
#define WPRFLAG 1
#include "dllargv.c"

17
reactos/lib/3rdparty/mingw/wcscmpi.c vendored Normal file
View file

@ -0,0 +1,17 @@
/**
* 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.PD within this package.
*/
#define __CRT__NO_INLINE
#include <string.h>
#undef wcscmpi
int wcscmpi (const wchar_t *, const wchar_t *);
int
wcscmpi (const wchar_t * ws1,const wchar_t * ws2)
{
return _wcsicmp (ws1,ws2);
}

View file

@ -1,7 +1,33 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int _dowildcard = 0;
/* _dowildcard is an int that controls the globbing of the command line.
* If _dowildcard is non-zero, the command line will be globbed: *.*
* will be expanded to be all files in the startup directory.
*
* In the mingw-w64 library the _dowildcard variable is defined as being
* 0, therefore command line globbing is DISABLED by default. To turn it
* on and to leave wildcard command line processing MS's globbing code,
* include a line in one of your source modules defining _dowildcard and
* setting it to -1, like so:
* int _dowildcard = -1;
*
* Alternatively, the mingw-w64 library can be configured using the
* --enable-wildcard option and compiled thusly upon which the resulting
* library will have _dowildcard as -1 and command line globbing will be
* enabled by default.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef __ENABLE_GLOBBING
#define __ENABLE_GLOBBING 0 /* -1 */
#endif
int _dowildcard = __ENABLE_GLOBBING;

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int _commode = 0;

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int __globallocalestatus = ~0x1;

View file

@ -1,7 +1,7 @@
/**
* 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.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
int _fmode = 0;

View file

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../tools/rbuild/project.dtd">
<module name="rtl" type="staticlibrary">
<module name="rtl" type="staticlibrary" crt="static">
<define name="_NTOSKRNL_" />
<define name="NO_RTL_INLINES" />
<define name="_NTSYSTEM_" />

View file

@ -25,6 +25,7 @@
<define name="_MSVCRT_LIB_" />
<define name="_MSVCRT_" />
<define name="_MT" />
<define name="_CRTBLD" />
<directory name="conio">
<file>cgets.c</file>
<file>cprintf.c</file>

View file

@ -94,7 +94,7 @@ _XcptFilter(DWORD ExceptionCode,
return ret;
}
int CDECL __CppXcptFilter(NTSTATUS ex, PEXCEPTION_POINTERS ptr)
int CDECL __CppXcptFilter(unsigned long ex, PEXCEPTION_POINTERS ptr)
{
/* only filter c++ exceptions */
if (ex != CXX_EXCEPTION) return EXCEPTION_CONTINUE_SEARCH;

View file

@ -20,7 +20,7 @@ double _chgsign( double __x )
union
{
double* __x;
double_t *x;
double_s *x;
} u;
u.__x = &__x;

View file

@ -19,12 +19,12 @@ double _copysign (double __d, double __s)
union
{
double* __d;
double_t* d;
double_s* d;
} d;
union
{
double* __s;
double_t* s;
double_s* s;
} s;
d.__d = &__d;
s.__s = &__s;

View file

@ -25,7 +25,7 @@
#define _FPCLASS_PINF 0x0200 /* positive infinity */
#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3
//#if __MINGW32_MAJOR_VERSION < 3 || __MINGW32_MINOR_VERSION < 3
#define FP_SNAN 0x0001 // signaling NaN
#define FP_QNAN 0x0002 // quiet NaN
@ -38,7 +38,7 @@
#define FP_NNORM 0x0080 // negative normalized non-zero
#define FP_PNORM 0x0100 // positive normalized non-zero
#endif
//#endif
typedef int fpclass_t;
@ -50,7 +50,7 @@ fpclass_t _fpclass(double __d)
union
{
double* __d;
double_t* d;
double_s* d;
} d;
d.__d = &__d;

View file

@ -28,7 +28,7 @@ int _isnan(double __x)
union
{
double* __x;
double_t* x;
double_s* x;
} x;
x.__x = &__x;
return ( x.x->exponent == 0x7ff && ( x.x->mantissah != 0 || x.x->mantissal != 0 ));
@ -41,7 +41,7 @@ int _isnanl(long double __x)
union
{
long double* __x;
long_double_t* x;
long_double_s* x;
} x;
x.__x = &__x;
@ -59,7 +59,7 @@ int _isinf(double __x)
union
{
double* __x;
double_t* x;
double_s* x;
} x;
x.__x = &__x;
@ -81,7 +81,7 @@ int _isinfl(long double __x)
union
{
long double* __x;
long_double_t* x;
long_double_s* x;
} x;
x.__x = &__x;

View file

@ -19,7 +19,7 @@ double _scalb( double __x, long e )
union
{
double* __x;
double_t* x;
double_s* x;
} x;
x.__x = &__x;

View file

@ -5,14 +5,14 @@ typedef struct {
unsigned int mantissa:23;
unsigned int exponent:8;
unsigned int sign:1;
} float_t;
} float_s;
typedef struct {
unsigned int mantissal:32;
unsigned int mantissah:20;
unsigned int exponent:11;
unsigned int sign:1;
} double_t;
} double_s;
typedef struct {
unsigned int mantissal:32;
@ -20,6 +20,6 @@ typedef struct {
unsigned int exponent:15;
unsigned int sign:1;
unsigned int empty:16;
} long_double_t;
} long_double_s;
#endif

View file

@ -7,6 +7,7 @@
<define name="_NTSYSTEM_" />
<define name="_NTDLLBUILD_" />
<define name="_LIBCNT_" />
<define name="_CRTBLD" />
<if property="ARCH" value="i386">
<define name="__MINGW_IMPORT">"extern __attribute__ ((dllexport))"</define>
</if>

View file

@ -11,7 +11,7 @@ frexp(double __x, int *exptr)
union
{
double* __x;
double_t* x;
double_s* x;
} x;
x.__x = &__x;

View file

@ -3,4 +3,4 @@
#include <internal/ieee.h>
#undef _HUGE
double_t _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 };
double_s _HUGE = { 0x00000, 0x00000, 0x7ff, 0x0 };

View file

@ -21,12 +21,12 @@ long double modfl(long double __x, long double *__i)
union
{
long double* __x;
long_double_t* x;
long_double_s* x;
} x;
union
{
long double* __i;
long_double_t* iptr;
long_double_s* iptr;
} iptr;
int j0;