[ros-diffs] [tkreuzer] 43956: Sync mingw lib to version 4.4.1-1a

tkreuzer at svn.reactos.org tkreuzer at svn.reactos.org
Wed Nov 4 22:22:53 CET 2009


Author: tkreuzer
Date: Wed Nov  4 22:22:53 2009
New Revision: 43956

URL: http://svn.reactos.org/svn/reactos?rev=43956&view=rev
Log:
Sync mingw lib to version 4.4.1-1a

Added:
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_glob.c   (with props)
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/binmode.c   (with props)
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt_handler.c   (with props)
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dll_argv.c   (with props)
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dummy_mingwthrd.c   (with props)
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingw_custom.c   (with props)
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingwthrd_nomt.c   (with props)
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/txtmode.c   (with props)
Modified:
    branches/ros-amd64-bringup/reactos/include/crt/_mingw.h
    branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/internal.h
    branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/oscalls.h
    branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/sect_attribs.h
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_fp10.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_fp8.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/atonexit.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt0_c.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt0_w.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crtdll.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crtexe.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dllentry.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dllmain.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/gccmain.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/gs_support.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingw.rbuild
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/pesect.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/pseudo-reloc.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/tlssup.c
    branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/wildcard.c

Modified: branches/ros-amd64-bringup/reactos/include/crt/_mingw.h
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/include/crt/_mingw.h?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/include/crt/_mingw.h [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/include/crt/_mingw.h [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -189,5 +189,15 @@
 #define _CRT_UNUSED(x) (void)x
 #endif
 
+#define __MINGW_USE_UNDERSCORE_PREFIX 1
+
+#if __MINGW_USE_UNDERSCORE_PREFIX == 0
+#define __MINGW_IMP_SYMBOL(sym)	_imp_##sym
+#define __MINGW_USYMBOL(sym) sym
+#else
+#define __MINGW_IMP_SYMBOL(sym)	_imp__##sym
+#define __MINGW_USYMBOL(sym) _##sym
+#endif
+
 #endif /* !_INC_MINGW */
 

Modified: branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/internal.h
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/internal.h?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/internal.h [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/internal.h [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -22,7 +22,7 @@
   typedef int (__cdecl *_PIFV)(void);
   typedef void (__cdecl *_PVFI)(int);
 
-#if defined (SPECIAL_CRTEXE) && defined (_DLL)
+#if defined (SPECIAL_CRTEXE) && (defined (_DLL) || defined (__GNUC__))
   extern int _commode;
 #else
   _CRTIMP extern int _commode;
@@ -31,12 +31,6 @@
 #define __IOINFO_TM_ANSI 0
 #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;
@@ -48,10 +42,6 @@
     char unicode : 1;
     char pipech2[2];
   } ioinfo;
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
 
 #define IOINFO_ARRAY_ELTS (1 << 5)
 
@@ -69,13 +59,13 @@
 #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 +97,24 @@
   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 +159,7 @@
 #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);

Modified: branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/oscalls.h
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/oscalls.h?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/oscalls.h [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/oscalls.h [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -30,11 +30,6 @@
 #endif
 #endif
 
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4214)
-#endif
-
 typedef struct _FTIME
 {
   unsigned short twosecs : 5;
@@ -51,10 +46,6 @@
   unsigned short year : 7;
 } FDATE;
 
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
 typedef FDATE *PFDATE;
 
 #endif

Modified: branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/sect_attribs.h
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/sect_attribs.h?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/sect_attribs.h [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/include/reactos/mingw-w64/sect_attribs.h [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -10,7 +10,7 @@
 #define _ATTRIBUTES shared
 #endif
 
-#if defined(_MSC_VER)
+#if 0
 /* Reference list of existing section for msvcrt.  */
 #pragma section(".CRTMP$XCA",long,_ATTRIBUTES)
 #pragma section(".CRTMP$XCZ",long,_ATTRIBUTES)
@@ -55,14 +55,6 @@
 #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

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_fp10.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_fp10.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_fp10.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_fp10.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -4,17 +4,9 @@
  * No warranty is given; refer to the file DISCLAIMER within this package.
  */
 
+void _fpreset (void);
+
 void _fpreset (void)
-{ 
-#ifdef __GNUC__
-    __asm__ ("fninit" );
-#else
-    __asm fninit;
-#endif
-}
+  { __asm__ ("fninit" ) ;}
 
-#ifdef __GNUC__
 void __attribute__ ((alias ("_fpreset"))) fpreset(void);
-#else
-void fpreset(void) { _fpreset(); }
-#endif

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_fp8.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_fp8.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_fp8.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_fp8.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -4,12 +4,14 @@
  * No warranty is given; refer to the file DISCLAIMER 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);
-#else
-void fpreset(void) { _fpreset(); }
-#endif

Added: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_glob.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_glob.c?rev=43956&view=auto
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_glob.c (added)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_glob.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -1,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 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;
+

Propchange: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/CRT_glob.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/atonexit.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/atonexit.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/atonexit.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/atonexit.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -25,10 +25,11 @@
 _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);
 
-#if 0
 /* 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;
@@ -38,7 +39,7 @@
   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);
@@ -56,4 +57,3 @@
 {
   return (mingw_onexit((_onexit_t)func) == NULL) ? -1 : 0;
 }
-#endif

Added: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/binmode.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/binmode.c?rev=43956&view=auto
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/binmode.c (added)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/binmode.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -1,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 within this package.
+ */
+
+#define SPECIAL_CRTEXE
+
+#include <fcntl.h>
+#include <stdlib.h>

Propchange: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/binmode.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt0_c.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt0_c.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt0_c.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt0_c.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -6,7 +6,15 @@
 
 #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);
 }

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt0_w.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt0_w.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt0_w.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt0_w.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -3,14 +3,23 @@
  * 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>
 
-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);
 }

Added: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt_handler.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt_handler.c?rev=43956&view=auto
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt_handler.c (added)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt_handler.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -1,0 +1,177 @@
+/**
+ * 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 <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 _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;
+	}
+      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;
+	}
+      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

Propchange: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crt_handler.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crtdll.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crtdll.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crtdll.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crtdll.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -110,10 +110,9 @@
 	}
       if (! nested)
 	{
-	  InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
-	}
-      if (__dyn_tls_init_callback != NULL &&
-	  _IsNonwritableInCurrentImage ((PBYTE) &__dyn_tls_init_callback))
+	  (void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
+	}
+      if (__dyn_tls_init_callback != NULL)
 	{
 	  __dyn_tls_init_callback (hDllHandle, DLL_THREAD_ATTACH, lpreserved);
 	}
@@ -143,7 +142,7 @@
 	      __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;
@@ -151,13 +150,19 @@
 
 static BOOL __DllMainCRTStartup (HANDLE, DWORD, LPVOID);
 
+BOOL WINAPI DllMainCRTStartup (HANDLE, DWORD, LPVOID);
+int __mingw_init_ehandler (void);
+
 BOOL WINAPI
-DllMainCRTStartup(HANDLE hDllHandle,DWORD dwReason,LPVOID lpreserved)
+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);
 }

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crtexe.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crtexe.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crtexe.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/crtexe.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -20,16 +20,15 @@
 #include <tchar.h>
 #include <sect_attribs.h>
 #include <locale.h>
-#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.  */
@@ -43,20 +42,16 @@
 
 __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__)
 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 *);
 
@@ -73,6 +68,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
@@ -89,10 +88,10 @@
 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 +100,7 @@
 
 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 +114,8 @@
     __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 +151,8 @@
 
 static int __tmainCRTStartup (void);
 
+int WinMainCRTStartup (void);
+
 int WinMainCRTStartup (void)
 {
   mingw_app_type = 1;
@@ -159,6 +160,12 @@
   return __tmainCRTStartup ();
 }
 
+int mainCRTStartup (void);
+
+#ifdef _WIN64
+int __mingw_init_ehandler (void);
+#endif
+
 int mainCRTStartup (void)
 {
   mingw_app_type = 0;
@@ -166,7 +173,7 @@
   return __tmainCRTStartup ();
 }
 
-
+static
 __declspec(noinline) int
 __tmainCRTStartup (void)
 {
@@ -174,7 +181,7 @@
   STARTUPINFO StartupInfo;
   BOOL inDoubleQuote = FALSE;
   memset (&StartupInfo, 0, sizeof (STARTUPINFO));
-
+  
   if (mingw_app_type)
     GetStartupInfo (&StartupInfo);
   {
@@ -211,18 +218,17 @@
     _ASSERTE(__native_startup_state == __initialized);
     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);
-#endif
-    //AddVectoredExceptionHandler (0, (PVECTORED_EXCEPTION_HANDLER)__mingw_vex);
-    SetUnhandledExceptionFilter (_gnu_exception_handler);
-
+    __mingw_oldexcpt_handler = SetUnhandledExceptionFilter (_gnu_exception_handler);
+#ifdef _WIN64
+    __mingw_init_ehandler ();
+#endif
+    __mingw_prepare_except_for_msvcr80_and_higher ();
+    
     _fpreset ();
 
     if (mingw_app_type)
@@ -239,7 +245,7 @@
 #ifdef _MBCS
 	if (_ismbblead (*lpszCommandLine))
 	  {
-	    if (lpszCommandLine)
+	    if (*lpszCommandLine)
 	      lpszCommandLine++;
 	  }
 #endif
@@ -248,21 +254,11 @@
     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 +270,6 @@
     __initenv = envp;
     mainret = main (argc, argv, envp);
 #endif
-    }
     if (!managedapp)
       exit (mainret);
 
@@ -328,7 +323,7 @@
 }
 
 static long CALLBACK
-_gnu_exception_handler (EXCEPTION_POINTERS * exception_data)
+_gnu_exception_handler (EXCEPTION_POINTERS *exception_data)
 {
   void (*old_handler) (int);
   long action = EXCEPTION_CONTINUE_SEARCH;
@@ -399,42 +394,26 @@
 	  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
-
+#ifdef WPRFLAG
 static size_t wbytelen(const wchar_t *p)
 {
 	size_t ret = 1;
@@ -465,7 +444,7 @@
 	char **avl;
 	int i;
 	char **n = (char **) malloc (sizeof (char *) * (ac + 1));
-
+	
 	avl=*av;
 	for (i=0; i < ac; i++)
 	  {
@@ -477,3 +456,35 @@
 	*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);
+}

Added: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dll_argv.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dll_argv.c?rev=43956&view=auto
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dll_argv.c (added)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dll_argv.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -1,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 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;
+}

Propchange: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dll_argv.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dllentry.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dllentry.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dllentry.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dllentry.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -8,7 +8,11 @@
 #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;
 }

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dllmain.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dllmain.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dllmain.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dllmain.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -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;
 }

Added: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dummy_mingwthrd.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dummy_mingwthrd.c?rev=43956&view=auto
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dummy_mingwthrd.c (added)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dummy_mingwthrd.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -1,0 +1,146 @@
+/*
+ * mthr_stub.c
+ *
+ * Implement Mingw-w64 thread-support.
+ *
+ * This file is used by if gcc is built with --enable-threads=win32. 
+ *
+ * Based on version created by Mumit Khan  <khan at nanotech.wisc.edu>
+ *
+ */
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#include <stdlib.h>
+
+BOOL __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);
+}
+  
+BOOL
+__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;
+}
+

Propchange: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/dummy_mingwthrd.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/gccmain.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/gccmain.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/gccmain.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/gccmain.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -13,10 +13,15 @@
 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 @@
       (*(p)) ();
       p++;
     }
-  if (hMsvcrt)
+  if (free_Msvcrt && hMsvcrt)
     {
+      free_Msvcrt = 0;
       FreeLibrary (hMsvcrt);
       hMsvcrt = NULL;
     }
@@ -42,7 +48,15 @@
   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");
   }
 

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/gs_support.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/gs_support.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/gs_support.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/gs_support.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -43,6 +43,8 @@
 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_cookie_complement = ~cookie;
 }
 
+__declspec(noreturn) void __cdecl __report_gsfailure (ULONGLONG);
+
 __declspec(noreturn) void __cdecl
 __report_gsfailure (ULONGLONG StackCookie)
 {
@@ -108,22 +112,12 @@
   else
 #endif
     {
-#ifdef __GNUC__
 #ifdef _WIN64
       GS_ContextRecord.Rip = (ULONGLONG) __builtin_return_address (0);
       GS_ContextRecord.Rsp = (ULONGLONG) __builtin_frame_address (0) + 8;
 #else
       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
     }
 

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingw.rbuild
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingw.rbuild?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingw.rbuild [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingw.rbuild [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -8,21 +8,28 @@
 	<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>dummy_mingwthrd.c</file>
 	<file>gccmain.c</file>
-	<file>getopt.c</file>
+	<!-- file>getopt.c</file -->
 	<file>gs_support.c</file>
 	<file>merr.c</file>
+	<!-- file>mingw_custom.c</file -->
 	<file>mingw_helpers.c</file>
+	<file>mingwthrd_nomt.c</file>
 	<file>natstart.c</file>
 	<file>pesect.c</file>
 	<file>pseudo-reloc.c</file>
 	<file>pseudo-reloc-list.c</file>
 	<file>tlssup.c</file>
+	<file>txtmode.c</file>
 	<file>wildcard.c</file>
 	<file>xncommod.c</file>
 	<file>xthdloc.c</file>
@@ -35,6 +42,7 @@
 	<file>crt0_c.c</file>
 	<file>crtexe.c</file>
 	<file>dllargv.c</file>
+	<file>ucrtexe.c</file>
 </module>
 <module name="mingw_wmain" type="staticlibrary" isstartuplib="true" unicode="yes" crt="dll">
 	<define name="_CRTBLD" />
@@ -44,11 +52,13 @@
 	<file>crt0_w.c</file>
 	<file>crtexe.c</file>
 	<file>dllargv.c</file>
+	<file>ucrtexe.c</file>
 </module>
 <module name="mingw_dllmain" type="staticlibrary" isstartuplib="true" crt="dll">
 	<define name="_CRTBLD" />
 	<include base="ReactOS">include/reactos/mingw-w64</include>
 	<file>crtdll.c</file>
 	<file>dllargv.c</file>
+	<file>udllargc.c</file>
 </module>
 </group>

Added: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingw_custom.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingw_custom.c?rev=43956&view=auto
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingw_custom.c (added)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingw_custom.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -1,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 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;
+}
+

Propchange: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingw_custom.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingwthrd_nomt.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingwthrd_nomt.c?rev=43956&view=auto
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingwthrd_nomt.c (added)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingwthrd_nomt.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -1,0 +1,30 @@
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+#include <stdlib.h>
+
+/* 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;
+
+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 *));
+
+int
+__mingwthr_remove_key_dtor (DWORD key)
+{
+   return ___w64_mingwthr_remove_key_dtor (key);
+}
+
+int
+__mingwthr_key_dtor (DWORD key, void (*dtor)(void *))
+{
+  if (dtor)
+    return ___w64_mingwthr_add_key_dtor (key, dtor);
+
+  return 0;
+}

Propchange: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/mingwthrd_nomt.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/pesect.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/pesect.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/pesect.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/pesect.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -5,6 +5,7 @@
  */
 
 #include <windows.h>
+#include <string.h>
 
 #if defined (_WIN64) && defined (__ia64__)
 #error FIXME: Unsupported __ImageBase implementation.
@@ -14,6 +15,8 @@
 /* This symbol is defined by the linker.  */
 extern IMAGE_DOS_HEADER __ImageBase;
 #endif
+
+BOOL _ValidateImageBase (PBYTE);
 
 BOOL
 _ValidateImageBase (PBYTE pImageBase)
@@ -33,6 +36,8 @@
     return FALSE;
   return TRUE;
 }
+
+PIMAGE_SECTION_HEADER _FindPESection (PBYTE, DWORD_PTR);
 
 PIMAGE_SECTION_HEADER
 _FindPESection (PBYTE pImageBase, DWORD_PTR rva)
@@ -54,6 +59,80 @@
   return NULL;
 }
 
+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;
+}
+
+BOOL _IsNonwritableInCurrentImage (PBYTE);
+
 BOOL
 _IsNonwritableInCurrentImage (PBYTE pTarget)
 {

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/pseudo-reloc.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/pseudo-reloc.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/pseudo-reloc.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/pseudo-reloc.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -2,12 +2,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 within this package.
+ *
+ * Contributed by Egor Duda  <deo at logos-m.ru>
+ * Modified by addition of runtime_pseudo_reloc version 2
+ * by Kai Tietz  <kai.tietz at onevision.com>
  */
 
 #include <windows.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <memory.h>
+#include <assert.h>
 
 extern char __RUNTIME_PSEUDO_RELOC_LIST__;
 extern char __RUNTIME_PSEUDO_RELOC_LIST_END__;
@@ -31,15 +36,14 @@
 } runtime_pseudo_reloc_v2;
 
 static void
-__write_memory (void *addr,const void *src,size_t len)
+__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
+  assert (VirtualQuery (addr, &b, sizeof(b)));
+  /* 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);
@@ -52,7 +56,7 @@
 #define RP_VERSION_V2 1
 
 static void
-do_pseudo_reloc (void* start,void *end,void *base)
+do_pseudo_reloc (void *start, void *end, void *base)
 {
   ptrdiff_t addr_imp, reldata;
   ptrdiff_t reloc_target = (ptrdiff_t) ((char *)end - (char*)start);
@@ -81,8 +85,10 @@
   /* Check if this is a known version.  */
   if (v2_hdr->version != RP_VERSION_V2)
     {
+#ifdef DEBUG
       fprintf (stderr, "pseudo_relocation protocol version %d is unknown to this runtime.\n",
 	       (int) v2_hdr->version);
+#endif
       return;
     }
   /* Walk over header.  */
@@ -120,7 +126,9 @@
 #endif
 	  default:
 	    reldata=0;
+#ifdef DEBUG
 	    fprintf(stderr, "Unknown pseudo relocation bit size %d\n",(int) (r->flags & 0xff));
+#endif
 	    break;
         }
       reldata -= ((ptrdiff_t) base + r->sym);
@@ -145,8 +153,10 @@
     }
 }
 
+void _pei386_runtime_relocator (void);
+
 void
-_pei386_runtime_relocator ()
+_pei386_runtime_relocator (void)
 {
   static int was_init = 0;
   if (was_init)

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/tlssup.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/tlssup.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/tlssup.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/tlssup.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -14,6 +14,8 @@
 #include <malloc.h>
 #include <crtdbg.h>
 
+extern BOOL __mingw_TLScallback (HANDLE hDllHandle, DWORD reason, LPVOID reserved);
+
 #define FUNCS_PER_NODE 30
 
 typedef struct TlsDtorNode {
@@ -24,20 +26,21 @@
 
 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 +50,59 @@
 #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;
+
+BOOL WINAPI __dyn_tls_init (HANDLE, DWORD, LPVOID);
 
 BOOL WINAPI
 __dyn_tls_init (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
 {
   _PVFV *pfunc;
 
+  /* We don't let us trick here.  */
+  if (_CRT_MT != 2)
+   _CRT_MT = 2;
+
   if (dwReason != DLL_THREAD_ATTACH)
-    return TRUE;
+    {
+      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,29 +120,42 @@
       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;
-
-  for (pnode = dtor_list; pnode != NULL; pnode = pnext)
+  /* 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 (i = pnode->count - 1; i >= 0; --i)
-	{
-	  if (pnode->funcs[i] != NULL)
-	    (*pnode->funcs[i])();
-	}
-      pnext = pnode->next;
-      if (pnext != NULL)
-	free ((void *) pnode);
+      for (pnode = dtor_list; pnode != NULL; pnode = pnext)
+        {
+          for (i = pnode->count - 1; i >= 0; --i)
+	    {
+	      if (pnode->funcs[i] != NULL)
+	        (*pnode->funcs[i])();
+	    }
+          pnext = pnode->next;
+          if (pnext != NULL)
+	    free ((void *) pnode);
+        }
     }
+#endif
+  __mingw_TLScallback (hDllHandle, dwReason, lpreserved);
   return TRUE;
 }
 

Added: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/txtmode.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/txtmode.c?rev=43956&view=auto
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/txtmode.c (added)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/txtmode.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -1,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 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; 

Propchange: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/txtmode.c
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/wildcard.c
URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/wildcard.c?rev=43956&r1=43955&r2=43956&view=diff
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/wildcard.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/3rdparty/mingw/wildcard.c [iso-8859-1] Wed Nov  4 22:22:53 2009
@@ -4,4 +4,16 @@
  * No warranty is given; refer to the file DISCLAIMER within this package.
  */
 
+/* _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;
+ */
+
 int _dowildcard = 0;
+




More information about the Ros-diffs mailing list