mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 07:42:59 +00:00
[CMAKE]
* MSVC fixes for msvcrtex. svn path=/trunk/; revision=52158
This commit is contained in:
parent
65d0fe96c2
commit
07d6a53ecc
3 changed files with 57 additions and 33 deletions
|
@ -20,8 +20,6 @@ list(APPEND MSVCRTEX_SOURCE
|
||||||
startup/atonexit.c
|
startup/atonexit.c
|
||||||
startup/txtmode.c
|
startup/txtmode.c
|
||||||
startup/pesect.c
|
startup/pesect.c
|
||||||
startup/pseudo-reloc.c
|
|
||||||
startup/pseudo-reloc-list.c
|
|
||||||
startup/tlsmcrt.c
|
startup/tlsmcrt.c
|
||||||
startup/tlsthrd.c
|
startup/tlsthrd.c
|
||||||
startup/tlsmthread.c
|
startup/tlsmthread.c
|
||||||
|
@ -37,6 +35,12 @@ list(APPEND MSVCRTEX_SOURCE
|
||||||
misc/ofmt_stub.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)
|
if(ARCH MATCHES i386)
|
||||||
list(APPEND MSVCRTEX_SOURCE
|
list(APPEND MSVCRTEX_SOURCE
|
||||||
except/i386/chkstk_asm.s
|
except/i386/chkstk_asm.s
|
||||||
|
|
|
@ -33,8 +33,12 @@
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
extern void __cdecl _initterm(_PVFV *,_PVFV *);
|
extern void __cdecl _initterm(_PVFV *,_PVFV *);
|
||||||
extern void __main ();
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
extern void __main (void);
|
||||||
extern void _pei386_runtime_relocator (void);
|
extern void _pei386_runtime_relocator (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
extern _CRTALLOC(".CRT$XIA") _PIFV __xi_a[];
|
extern _CRTALLOC(".CRT$XIA") _PIFV __xi_a[];
|
||||||
extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
|
extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
|
||||||
extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
|
extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
|
||||||
|
@ -179,7 +183,9 @@ __DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||||
retcode = FALSE;
|
retcode = FALSE;
|
||||||
goto i__leave;
|
goto i__leave;
|
||||||
}
|
}
|
||||||
|
#if defined(__GNUC__)
|
||||||
_pei386_runtime_relocator ();
|
_pei386_runtime_relocator ();
|
||||||
|
#endif
|
||||||
if (dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH)
|
if (dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH)
|
||||||
{
|
{
|
||||||
retcode = _CRT_INIT (hDllHandle, dwReason, lpreserved);
|
retcode = _CRT_INIT (hDllHandle, dwReason, lpreserved);
|
||||||
|
@ -194,7 +200,9 @@ __DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dwReason == DLL_PROCESS_ATTACH)
|
if (dwReason == DLL_PROCESS_ATTACH)
|
||||||
|
#if defined(__GNUC__)
|
||||||
__main ();
|
__main ();
|
||||||
|
#endif
|
||||||
retcode = DllMain(hDllHandle,dwReason,lpreserved);
|
retcode = DllMain(hDllHandle,dwReason,lpreserved);
|
||||||
if (dwReason == DLL_PROCESS_ATTACH && ! retcode)
|
if (dwReason == DLL_PROCESS_ATTACH && ! retcode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
#include <sect_attribs.h>
|
#include <sect_attribs.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
#ifndef __winitenv
|
#ifndef __winitenv
|
||||||
extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
|
extern wchar_t *** __MINGW_IMP_SYMBOL(__winitenv);
|
||||||
|
@ -32,7 +33,7 @@ extern char *** __MINGW_IMP_SYMBOL(__initenv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Hack, for bug in ld. Will be removed soon. */
|
/* Hack, for bug in ld. Will be removed soon. */
|
||||||
#ifndef _MSC_VER
|
#if defined(__GNUC__)
|
||||||
#define __ImageBase __MINGW_LSYMBOL(_image_base__)
|
#define __ImageBase __MINGW_LSYMBOL(_image_base__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -43,6 +44,8 @@ extern void _fpreset (void);
|
||||||
#define SPACECHAR _T(' ')
|
#define SPACECHAR _T(' ')
|
||||||
#define DQUOTECHAR _T('\"')
|
#define DQUOTECHAR _T('\"')
|
||||||
|
|
||||||
|
__declspec(dllimport) void __setusermatherr(int (__cdecl *)(struct _exception *));
|
||||||
|
|
||||||
extern int * __MINGW_IMP_SYMBOL(_fmode);
|
extern int * __MINGW_IMP_SYMBOL(_fmode);
|
||||||
extern int * __MINGW_IMP_SYMBOL(_commode);
|
extern int * __MINGW_IMP_SYMBOL(_commode);
|
||||||
|
|
||||||
|
@ -55,9 +58,11 @@ extern int _dowildcard;
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
int _MINGW_INSTALL_DEBUG_MATHERR __attribute__((weak)) = 0;
|
int _MINGW_INSTALL_DEBUG_MATHERR __attribute__((weak)) = 0;
|
||||||
#else
|
#else
|
||||||
int _MINGW_INSTALL_DEBUG_MATHERR = 0;
|
int __declspec(selectany) _MINGW_INSTALL_DEBUG_MATHERR = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int __defaultmatherr;
|
extern int __defaultmatherr;
|
||||||
|
|
||||||
extern _CRTIMP void __cdecl _initterm(_PVFV *, _PVFV *);
|
extern _CRTIMP void __cdecl _initterm(_PVFV *, _PVFV *);
|
||||||
|
|
||||||
static int __cdecl check_managed_app (void);
|
static int __cdecl check_managed_app (void);
|
||||||
|
@ -80,7 +85,12 @@ _TCHAR *__mingw_winmain_lpCmdLine;
|
||||||
DWORD __mingw_winmain_nShowCmd;
|
DWORD __mingw_winmain_nShowCmd;
|
||||||
|
|
||||||
static int argc;
|
static int argc;
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
extern void __main(void);
|
extern void __main(void);
|
||||||
|
extern void _pei386_runtime_relocator (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WPRFLAG
|
#ifdef WPRFLAG
|
||||||
static wchar_t **argv;
|
static wchar_t **argv;
|
||||||
static wchar_t **envp;
|
static wchar_t **envp;
|
||||||
|
@ -96,7 +106,7 @@ static int has_cctor = 0;
|
||||||
static _startupinfo startinfo;
|
static _startupinfo startinfo;
|
||||||
extern LPTOP_LEVEL_EXCEPTION_FILTER __mingw_oldexcpt_handler;
|
extern LPTOP_LEVEL_EXCEPTION_FILTER __mingw_oldexcpt_handler;
|
||||||
|
|
||||||
extern void _pei386_runtime_relocator (void);
|
|
||||||
long CALLBACK _gnu_exception_handler (EXCEPTION_POINTERS * exception_data);
|
long CALLBACK _gnu_exception_handler (EXCEPTION_POINTERS * exception_data);
|
||||||
#ifdef WPRFLAG
|
#ifdef WPRFLAG
|
||||||
static void duplicate_ppstrings (int ac, wchar_t ***av);
|
static void duplicate_ppstrings (int ac, wchar_t ***av);
|
||||||
|
@ -107,10 +117,8 @@ static void duplicate_ppstrings (int ac, char ***av);
|
||||||
static int __cdecl pre_c_init (void);
|
static int __cdecl pre_c_init (void);
|
||||||
static void __cdecl pre_cpp_init (void);
|
static void __cdecl pre_cpp_init (void);
|
||||||
static void __cdecl __mingw_prepare_except_for_msvcr80_and_higher (void);
|
static void __cdecl __mingw_prepare_except_for_msvcr80_and_higher (void);
|
||||||
_CRTALLOC(".CRT$XIAA") _PIFV mingw_pcinit = pre_c_init;
|
_CRTALLOC(".CRT$XIAA") _PIFV __declspec(selectany) mingw_pcinit = pre_c_init;
|
||||||
_CRTALLOC(".CRT$XCAA") _PVFV mingw_pcppinit = pre_cpp_init;
|
_CRTALLOC(".CRT$XCAA") _PVFV __declspec(selectany) mingw_pcppinit = pre_cpp_init;
|
||||||
|
|
||||||
extern int _MINGW_INSTALL_DEBUG_MATHERR;
|
|
||||||
|
|
||||||
static int __cdecl
|
static int __cdecl
|
||||||
pre_c_init (void)
|
pre_c_init (void)
|
||||||
|
@ -216,7 +224,7 @@ __tmainCRTStartup (void)
|
||||||
WINBOOL inDoubleQuote = FALSE;
|
WINBOOL inDoubleQuote = FALSE;
|
||||||
memset (&StartupInfo, 0, sizeof (STARTUPINFO));
|
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
|
/* 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
|
and that we align the stack to 16 bytes for the sake of SSE ops in main
|
||||||
or in functions inlined into main. */
|
or in functions inlined into main. */
|
||||||
|
@ -265,7 +273,9 @@ __tmainCRTStartup (void)
|
||||||
if (__dyn_tls_init_callback != NULL)
|
if (__dyn_tls_init_callback != NULL)
|
||||||
__dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL);
|
__dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL);
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
_pei386_runtime_relocator ();
|
_pei386_runtime_relocator ();
|
||||||
|
#endif
|
||||||
__mingw_oldexcpt_handler = SetUnhandledExceptionFilter (_gnu_exception_handler);
|
__mingw_oldexcpt_handler = SetUnhandledExceptionFilter (_gnu_exception_handler);
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
__mingw_init_ehandler ();
|
__mingw_init_ehandler ();
|
||||||
|
@ -277,33 +287,35 @@ __tmainCRTStartup (void)
|
||||||
if (mingw_app_type)
|
if (mingw_app_type)
|
||||||
{
|
{
|
||||||
#ifdef WPRFLAG
|
#ifdef WPRFLAG
|
||||||
lpszCommandLine = (_TCHAR *) _wcmdln;
|
lpszCommandLine = (_TCHAR *) _wcmdln;
|
||||||
#else
|
#else
|
||||||
lpszCommandLine = (char *) _acmdln;
|
lpszCommandLine = (char *) _acmdln;
|
||||||
#endif
|
#endif
|
||||||
while (*lpszCommandLine > SPACECHAR || (*lpszCommandLine&&inDoubleQuote))
|
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? */
|
if (*lpszCommandLine == DQUOTECHAR)
|
||||||
lpszCommandLine++;
|
inDoubleQuote = !inDoubleQuote;
|
||||||
}
|
#ifdef _MBCS
|
||||||
|
if (_ismbblead (*lpszCommandLine))
|
||||||
|
{
|
||||||
|
if (lpszCommandLine) /* FIXME: Why this check? Should I check for *lpszCommandLine != 0 too? */
|
||||||
|
lpszCommandLine++;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
++lpszCommandLine;
|
++lpszCommandLine;
|
||||||
}
|
}
|
||||||
while (*lpszCommandLine && (*lpszCommandLine <= SPACECHAR))
|
while (*lpszCommandLine && (*lpszCommandLine <= SPACECHAR))
|
||||||
lpszCommandLine++;
|
lpszCommandLine++;
|
||||||
|
|
||||||
__mingw_winmain_hInstance = (HINSTANCE) &__ImageBase;
|
__mingw_winmain_hInstance = (HINSTANCE) &__ImageBase;
|
||||||
__mingw_winmain_lpCmdLine = lpszCommandLine;
|
__mingw_winmain_lpCmdLine = lpszCommandLine;
|
||||||
__mingw_winmain_nShowCmd = StartupInfo.dwFlags & STARTF_USESHOWWINDOW ?
|
__mingw_winmain_nShowCmd = StartupInfo.dwFlags & STARTF_USESHOWWINDOW ?
|
||||||
StartupInfo.wShowWindow : SW_SHOWDEFAULT;
|
StartupInfo.wShowWindow : SW_SHOWDEFAULT;
|
||||||
}
|
}
|
||||||
duplicate_ppstrings (argc, &argv);
|
duplicate_ppstrings (argc, &argv);
|
||||||
|
#if defined(__GNUC__)
|
||||||
__main ();
|
__main ();
|
||||||
|
#endif
|
||||||
#ifdef WPRFLAG
|
#ifdef WPRFLAG
|
||||||
__winitenv = envp;
|
__winitenv = envp;
|
||||||
/* C++ initialization.
|
/* C++ initialization.
|
||||||
|
@ -422,8 +434,8 @@ __mingw_invalidParameterHandler (const wchar_t * __UNUSED_PARAM_1(expression),
|
||||||
uintptr_t __UNUSED_PARAM(pReserved))
|
uintptr_t __UNUSED_PARAM(pReserved))
|
||||||
{
|
{
|
||||||
#ifdef __MINGW_SHOW_INVALID_PARAMETER_EXCEPTION
|
#ifdef __MINGW_SHOW_INVALID_PARAMETER_EXCEPTION
|
||||||
wprintf(L"Invalid parameter detected in function %s. File: %s Line: %d\n", function, file, line);
|
wprintf(L"Invalid parameter detected in function %s. File: %s Line: %d\n", function, file, line);
|
||||||
wprintf(L"Expression: %s\n", expression);
|
wprintf(L"Expression: %s\n", expression);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue