Author: akhaldi Date: Thu Jun 9 17:59:26 2011 New Revision: 52158
URL: http://svn.reactos.org/svn/reactos?rev=52158&view=rev Log: [CMAKE] * MSVC fixes for msvcrtex.
Modified: trunk/reactos/lib/sdk/crt/msvcrtex.cmake trunk/reactos/lib/sdk/crt/startup/crtdll.c trunk/reactos/lib/sdk/crt/startup/crtexe.c
Modified: trunk/reactos/lib/sdk/crt/msvcrtex.cmake URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/msvcrtex.cmake?... ============================================================================== --- trunk/reactos/lib/sdk/crt/msvcrtex.cmake [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/msvcrtex.cmake [iso-8859-1] Thu Jun 9 17:59:26 2011 @@ -20,8 +20,6 @@ startup/atonexit.c startup/txtmode.c startup/pesect.c - startup/pseudo-reloc.c - startup/pseudo-reloc-list.c startup/tlsmcrt.c startup/tlsthrd.c startup/tlsmthread.c @@ -36,6 +34,12 @@ misc/fltused.c misc/ofmt_stub.c ) + +if(NOT MSVC) +list(APPEND MSVCRTEX_SOURCE + startup/pseudo-reloc.c + startup/pseudo-reloc-list.c) +endif()
if(ARCH MATCHES i386) list(APPEND MSVCRTEX_SOURCE
Modified: trunk/reactos/lib/sdk/crt/startup/crtdll.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/startup/crtdll.... ============================================================================== --- trunk/reactos/lib/sdk/crt/startup/crtdll.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/startup/crtdll.c [iso-8859-1] Thu Jun 9 17:59:26 2011 @@ -33,8 +33,12 @@ #include <locale.h>
extern void __cdecl _initterm(_PVFV *,_PVFV *); -extern void __main (); + +#if defined(__GNUC__) +extern void __main (void); extern void _pei386_runtime_relocator (void); +#endif + extern _CRTALLOC(".CRT$XIA") _PIFV __xi_a[]; extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[]; extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[]; @@ -179,7 +183,9 @@ retcode = FALSE; goto i__leave; } +#if defined(__GNUC__) _pei386_runtime_relocator (); +#endif if (dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH) { retcode = _CRT_INIT (hDllHandle, dwReason, lpreserved); @@ -194,7 +200,9 @@ } } if (dwReason == DLL_PROCESS_ATTACH) +#if defined(__GNUC__) __main (); +#endif retcode = DllMain(hDllHandle,dwReason,lpreserved); if (dwReason == DLL_PROCESS_ATTACH && ! retcode) {
Modified: trunk/reactos/lib/sdk/crt/startup/crtexe.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/startup/crtexe.... ============================================================================== --- trunk/reactos/lib/sdk/crt/startup/crtexe.c [iso-8859-1] (original) +++ trunk/reactos/lib/sdk/crt/startup/crtexe.c [iso-8859-1] Thu Jun 9 17:59:26 2011 @@ -20,6 +20,7 @@ #include <tchar.h> #include <sect_attribs.h> #include <locale.h> +#include <malloc.h>
#ifndef __winitenv extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv); @@ -32,7 +33,7 @@ #endif
/* Hack, for bug in ld. Will be removed soon. */ -#ifndef _MSC_VER +#if defined(__GNUC__) #define __ImageBase __MINGW_LSYMBOL(_image_base__) #endif
@@ -42,6 +43,8 @@ extern void _fpreset (void); #define SPACECHAR _T(' ') #define DQUOTECHAR _T('"') + +__declspec(dllimport) void __setusermatherr(int (__cdecl *)(struct _exception *));
extern int * __MINGW_IMP_SYMBOL(_fmode); extern int * __MINGW_IMP_SYMBOL(_commode); @@ -55,9 +58,11 @@ #if defined(__GNUC__) int _MINGW_INSTALL_DEBUG_MATHERR __attribute__((weak)) = 0; #else -int _MINGW_INSTALL_DEBUG_MATHERR = 0; -#endif +int __declspec(selectany) _MINGW_INSTALL_DEBUG_MATHERR = 0; +#endif + extern int __defaultmatherr; + extern _CRTIMP void __cdecl _initterm(_PVFV *, _PVFV *);
static int __cdecl check_managed_app (void); @@ -80,7 +85,12 @@ DWORD __mingw_winmain_nShowCmd;
static int argc; + +#if defined(__GNUC__) extern void __main(void); +extern void _pei386_runtime_relocator (void); +#endif + #ifdef WPRFLAG static wchar_t **argv; static wchar_t **envp; @@ -96,7 +106,7 @@ static _startupinfo startinfo; extern LPTOP_LEVEL_EXCEPTION_FILTER __mingw_oldexcpt_handler;
-extern void _pei386_runtime_relocator (void); + long CALLBACK _gnu_exception_handler (EXCEPTION_POINTERS * exception_data); #ifdef WPRFLAG static void duplicate_ppstrings (int ac, wchar_t ***av); @@ -107,10 +117,8 @@ 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; - -extern int _MINGW_INSTALL_DEBUG_MATHERR; +_CRTALLOC(".CRT$XIAA") _PIFV __declspec(selectany) mingw_pcinit = pre_c_init; +_CRTALLOC(".CRT$XCAA") _PVFV __declspec(selectany) mingw_pcppinit = pre_cpp_init;
static int __cdecl pre_c_init (void) @@ -216,7 +224,7 @@ WINBOOL inDoubleQuote = FALSE; memset (&StartupInfo, 0, sizeof (STARTUPINFO));
-#ifndef _WIN64 +#if !defined(_WIN64) && defined(__GNUC__) /* We need to make sure that this function is build with frame-pointer and that we align the stack to 16 bytes for the sake of SSE ops in main or in functions inlined into main. */ @@ -265,7 +273,9 @@ if (__dyn_tls_init_callback != NULL) __dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL);
+#if defined(__GNUC__) _pei386_runtime_relocator (); +#endif __mingw_oldexcpt_handler = SetUnhandledExceptionFilter (_gnu_exception_handler); #ifdef _WIN64 __mingw_init_ehandler (); @@ -277,33 +287,35 @@ if (mingw_app_type) { #ifdef WPRFLAG - lpszCommandLine = (_TCHAR *) _wcmdln; -#else - lpszCommandLine = (char *) _acmdln; -#endif - while (*lpszCommandLine > SPACECHAR || (*lpszCommandLine&&inDoubleQuote)) - { - if (*lpszCommandLine == DQUOTECHAR) - inDoubleQuote = !inDoubleQuote; + lpszCommandLine = (_TCHAR *) _wcmdln; +#else + lpszCommandLine = (char *) _acmdln; +#endif + while (*lpszCommandLine > SPACECHAR || (*lpszCommandLine && inDoubleQuote)) + { + if (*lpszCommandLine == DQUOTECHAR) + inDoubleQuote = !inDoubleQuote; #ifdef _MBCS - if (_ismbblead (*lpszCommandLine)) - { - if (lpszCommandLine) /* FIXME: Why this check? Should I check for *lpszCommandLine != 0 too? */ - lpszCommandLine++; + if (_ismbblead (*lpszCommandLine)) + { + if (lpszCommandLine) /* FIXME: Why this check? Should I check for *lpszCommandLine != 0 too? */ + lpszCommandLine++; + } +#endif + ++lpszCommandLine; } -#endif - ++lpszCommandLine; + while (*lpszCommandLine && (*lpszCommandLine <= SPACECHAR)) + lpszCommandLine++; + + __mingw_winmain_hInstance = (HINSTANCE) &__ImageBase; + __mingw_winmain_lpCmdLine = lpszCommandLine; + __mingw_winmain_nShowCmd = StartupInfo.dwFlags & STARTF_USESHOWWINDOW ? + StartupInfo.wShowWindow : SW_SHOWDEFAULT; } - while (*lpszCommandLine && (*lpszCommandLine <= SPACECHAR)) - lpszCommandLine++; - - __mingw_winmain_hInstance = (HINSTANCE) &__ImageBase; - __mingw_winmain_lpCmdLine = lpszCommandLine; - __mingw_winmain_nShowCmd = StartupInfo.dwFlags & STARTF_USESHOWWINDOW ? - StartupInfo.wShowWindow : SW_SHOWDEFAULT; - } duplicate_ppstrings (argc, &argv); +#if defined(__GNUC__) __main (); +#endif #ifdef WPRFLAG __winitenv = envp; /* C++ initialization. @@ -422,8 +434,8 @@ uintptr_t __UNUSED_PARAM(pReserved)) { #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); + wprintf(L"Invalid parameter detected in function %s. File: %s Line: %d\n", function, file, line); + wprintf(L"Expression: %s\n", expression); #endif }