Sync CRT initialization code with mingw-w64 r690

- Fixed initialization for Console apps with Unicode entry point. Now stuff like "cout" in <iostream> 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
This commit is contained in:
Colin Finck 2009-03-17 20:17:02 +00:00
parent 72e2fbe6f8
commit 9ffc9028a2
5 changed files with 14 additions and 36 deletions

View file

@ -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);
}

View file

@ -6,7 +6,9 @@
#ifdef CRTDLL
#undef CRTDLL
#ifndef _DLL
#define _DLL
#endif
#include <oscalls.h>
#include <internal.h>

View file

@ -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;

View file

@ -12,9 +12,6 @@
#include <tchar.h>
#include <sect_attribs.h>
#include <locale.h>
#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

View file

@ -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: