From 9ffc9028a20a4143a6b138f5ef5014e087578f1f Mon Sep 17 00:00:00 2001 From: Colin Finck Date: Tue, 17 Mar 2009 20:17:02 +0000 Subject: [PATCH] Sync CRT initialization code with mingw-w64 r690 - Fixed initialization for Console apps with Unicode entry point. Now stuff like "cout" in doesn't lead to instant crashes. - Unified the name of the entry point for ANSI and Unicode. The difference is just in the library now ("mingw_main" vs. "mingw_wmain") RBuild was changed appropriately to support this - No more ReactOS-specific changes inside the initialization code svn path=/trunk/; revision=40077 --- reactos/lib/3rdparty/mingw/crt0_w.c | 5 ----- reactos/lib/3rdparty/mingw/crtdll.c | 2 ++ reactos/lib/3rdparty/mingw/crtexe.c | 21 ++++++++++----------- reactos/lib/3rdparty/mingw/mingw_helpers.c | 12 ------------ reactos/tools/rbuild/module.cpp | 10 ++-------- 5 files changed, 14 insertions(+), 36 deletions(-) diff --git a/reactos/lib/3rdparty/mingw/crt0_w.c b/reactos/lib/3rdparty/mingw/crt0_w.c index 06e4afe6319..4e096483e11 100644 --- a/reactos/lib/3rdparty/mingw/crt0_w.c +++ b/reactos/lib/3rdparty/mingw/crt0_w.c @@ -12,10 +12,5 @@ int WINAPI wWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPWSTR lpCmdLine int wmain (int flags, wchar_t **cmdline, wchar_t **inst) { -#ifdef __GNUC__ - /* C++ initialization. - gcc inserts this call automatically for a function called main , but not for wmain. */ - __main(); -#endif return (int) wWinMain ((HINSTANCE) inst, NULL, (LPWSTR) cmdline,(DWORD) flags); } diff --git a/reactos/lib/3rdparty/mingw/crtdll.c b/reactos/lib/3rdparty/mingw/crtdll.c index ef2bacd20e5..c14a7a0310c 100644 --- a/reactos/lib/3rdparty/mingw/crtdll.c +++ b/reactos/lib/3rdparty/mingw/crtdll.c @@ -6,7 +6,9 @@ #ifdef CRTDLL #undef CRTDLL +#ifndef _DLL #define _DLL +#endif #include #include diff --git a/reactos/lib/3rdparty/mingw/crtexe.c b/reactos/lib/3rdparty/mingw/crtexe.c index ae4db0dc858..d9889aeaf3d 100644 --- a/reactos/lib/3rdparty/mingw/crtexe.c +++ b/reactos/lib/3rdparty/mingw/crtexe.c @@ -5,7 +5,9 @@ */ #undef CRTDLL -//#define _DLL +#ifndef _DLL +#define _DLL +#endif #define SPECIAL_CRTEXE @@ -69,6 +71,7 @@ extern int mingw_app_type; static int argc; #ifdef WPRFLAG +extern void __main(void); static wchar_t **argv; static wchar_t **envp; #else @@ -144,22 +147,14 @@ pre_cpp_init (void) static int __tmainCRTStartup (void); -#ifdef WPRFLAG -int wWinMainCRTStartup (void) -#else int WinMainCRTStartup (void) -#endif { mingw_app_type = 1; __security_init_cookie (); return __tmainCRTStartup (); } -#ifdef WPRFLAG -int wmainCRTStartup (void) -#else int mainCRTStartup (void) -#endif { mingw_app_type = 0; __security_init_cookie (); @@ -236,8 +231,6 @@ __tmainCRTStartup (void) if (mingw_app_type) { #ifdef WPRFLAG - if (_wcmdln == NULL) - return 255; lpszCommandLine = (_TCHAR *) _wcmdln; #else lpszCommandLine = (char *) _acmdln; @@ -259,6 +252,9 @@ __tmainCRTStartup (void) 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); @@ -273,6 +269,9 @@ __tmainCRTStartup (void) duplicate_ppstrings (argc, &argv); #ifdef WPRFLAG __winitenv = envp; + /* C++ initialization. + gcc inserts this call automatically for a function called main, but not for wmain. */ + __main (); mainret = wmain (argc, argv, envp); #else __initenv = envp; diff --git a/reactos/lib/3rdparty/mingw/mingw_helpers.c b/reactos/lib/3rdparty/mingw/mingw_helpers.c index cc8671f0f89..dad8891b00c 100644 --- a/reactos/lib/3rdparty/mingw/mingw_helpers.c +++ b/reactos/lib/3rdparty/mingw/mingw_helpers.c @@ -12,9 +12,6 @@ #include #include #include -#if 0 -#include "../revstamp.h" -#endif const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback; @@ -32,12 +29,3 @@ _encode_pointer (void *ptr) /* 0:console, 1:windows. */ int mingw_app_type = 0; - -#if 0 -const char *__mingw_get_crt_info (void) -{ - return "MinGW-W64 Runtime " __MINGW64_VERSION " (" - __MINGW64_VERSION_STATE " - " - "rev. " __MINGW_W64_REV ") " __MINGW_W64_REV_STAMP; -} -#endif diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index fffcedc7616..e87a21091a3 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -1090,16 +1090,10 @@ Module::GetDefaultModuleEntrypoint () const return "DllMain@12"; case Win32CUI: case Test: - if ( isUnicode ) - return "wmainCRTStartup"; - else - return "mainCRTStartup"; + return "mainCRTStartup"; case Win32SCR: case Win32GUI: - if ( isUnicode ) - return "wWinMainCRTStartup"; - else - return "WinMainCRTStartup"; + return "WinMainCRTStartup"; case BuildTool: case StaticLibrary: case HostStaticLibrary: