2011-05-23 15:50:03 +00:00
|
|
|
/**
|
|
|
|
* 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.PD within this package.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stdlib.h>
|
[RunTmChk]
- Implement _RTC_GetErrDesc, _RTC_SetErrorFuncW, add stubs for _RTC_NumErrors, _RTC_SetErrorType, _RTC_SetErrorFunc
- Implement _RTC_DefaultErrorFuncW which will be used, when no other error func was set
- Implement _RTC_InitBase, which will be called from _RTC_Initialize, and which in turn calls either _CRT_RTC_INITW, if CRT was linked, or a local _CRT_RTC_INITW0, which in turn will return the error function to use. This allows us to use a custom error function for all modules that link to (MSV)CRT. Only user32 does not really fit into here, since it uses the same startup code but does not link to MSVCRT.
[CRT]
- Call _RTC_Initialize from __main before initializing the global constructors, but fall back to a dummy _RTC_NoInitialize(), when RunTmChk.lib was not linked. Now we properly initialize both our own as well as MS RunTmChk lib.
svn path=/trunk/; revision=64816
2014-10-18 21:22:52 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <rtcapi.h>
|
|
|
|
#include <assert.h>
|
2014-10-18 21:38:07 +00:00
|
|
|
#include <internal.h>
|
[RunTmChk]
- Implement _RTC_GetErrDesc, _RTC_SetErrorFuncW, add stubs for _RTC_NumErrors, _RTC_SetErrorType, _RTC_SetErrorFunc
- Implement _RTC_DefaultErrorFuncW which will be used, when no other error func was set
- Implement _RTC_InitBase, which will be called from _RTC_Initialize, and which in turn calls either _CRT_RTC_INITW, if CRT was linked, or a local _CRT_RTC_INITW0, which in turn will return the error function to use. This allows us to use a custom error function for all modules that link to (MSV)CRT. Only user32 does not really fit into here, since it uses the same startup code but does not link to MSVCRT.
[CRT]
- Call _RTC_Initialize from __main before initializing the global constructors, but fall back to a dummy _RTC_NoInitialize(), when RunTmChk.lib was not linked. Now we properly initialize both our own as well as MS RunTmChk lib.
svn path=/trunk/; revision=64816
2014-10-18 21:22:52 +00:00
|
|
|
|
|
|
|
#if defined(_M_IX86)
|
|
|
|
#pragma comment(linker, "/alternatename:__RTC_Initialize=__RTC_NoInitialize")
|
|
|
|
#elif defined(_M_IA64) || defined(_M_AMD64) || defined(_M_ARM)
|
|
|
|
#pragma comment(linker, "/alternatename:_RTC_Initialize=_RTC_NoInitialize")
|
|
|
|
#else
|
|
|
|
#error Unsupported platform
|
|
|
|
#endif
|
2011-05-23 15:50:03 +00:00
|
|
|
|
2012-04-18 15:12:45 +00:00
|
|
|
void _pei386_runtime_relocator(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int __mingw_init_ehandler(void)
|
2011-08-20 17:11:16 +00:00
|
|
|
{
|
|
|
|
/* Nothing to do */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-05-23 15:50:03 +00:00
|
|
|
BOOL
|
|
|
|
WINAPI
|
|
|
|
_CRT_INIT0(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
[RunTmChk]
- Implement _RTC_GetErrDesc, _RTC_SetErrorFuncW, add stubs for _RTC_NumErrors, _RTC_SetErrorType, _RTC_SetErrorFunc
- Implement _RTC_DefaultErrorFuncW which will be used, when no other error func was set
- Implement _RTC_InitBase, which will be called from _RTC_Initialize, and which in turn calls either _CRT_RTC_INITW, if CRT was linked, or a local _CRT_RTC_INITW0, which in turn will return the error function to use. This allows us to use a custom error function for all modules that link to (MSV)CRT. Only user32 does not really fit into here, since it uses the same startup code but does not link to MSVCRT.
[CRT]
- Call _RTC_Initialize from __main before initializing the global constructors, but fall back to a dummy _RTC_NoInitialize(), when RunTmChk.lib was not linked. Now we properly initialize both our own as well as MS RunTmChk lib.
svn path=/trunk/; revision=64816
2014-10-18 21:22:52 +00:00
|
|
|
int
|
|
|
|
__cdecl
|
|
|
|
Catch_RTC_Failure(
|
|
|
|
int errType,
|
|
|
|
const wchar_t *file,
|
|
|
|
int line,
|
|
|
|
const wchar_t *module,
|
|
|
|
const wchar_t *format,
|
|
|
|
...)
|
2014-10-12 22:59:32 +00:00
|
|
|
{
|
|
|
|
/* FIXME: better failure routine */
|
|
|
|
__debugbreak();
|
[RunTmChk]
- Implement _RTC_GetErrDesc, _RTC_SetErrorFuncW, add stubs for _RTC_NumErrors, _RTC_SetErrorType, _RTC_SetErrorFunc
- Implement _RTC_DefaultErrorFuncW which will be used, when no other error func was set
- Implement _RTC_InitBase, which will be called from _RTC_Initialize, and which in turn calls either _CRT_RTC_INITW, if CRT was linked, or a local _CRT_RTC_INITW0, which in turn will return the error function to use. This allows us to use a custom error function for all modules that link to (MSV)CRT. Only user32 does not really fit into here, since it uses the same startup code but does not link to MSVCRT.
[CRT]
- Call _RTC_Initialize from __main before initializing the global constructors, but fall back to a dummy _RTC_NoInitialize(), when RunTmChk.lib was not linked. Now we properly initialize both our own as well as MS RunTmChk lib.
svn path=/trunk/; revision=64816
2014-10-18 21:22:52 +00:00
|
|
|
return 0;
|
2014-10-12 22:59:32 +00:00
|
|
|
}
|
|
|
|
|
[RunTmChk]
- Implement _RTC_GetErrDesc, _RTC_SetErrorFuncW, add stubs for _RTC_NumErrors, _RTC_SetErrorType, _RTC_SetErrorFunc
- Implement _RTC_DefaultErrorFuncW which will be used, when no other error func was set
- Implement _RTC_InitBase, which will be called from _RTC_Initialize, and which in turn calls either _CRT_RTC_INITW, if CRT was linked, or a local _CRT_RTC_INITW0, which in turn will return the error function to use. This allows us to use a custom error function for all modules that link to (MSV)CRT. Only user32 does not really fit into here, since it uses the same startup code but does not link to MSVCRT.
[CRT]
- Call _RTC_Initialize from __main before initializing the global constructors, but fall back to a dummy _RTC_NoInitialize(), when RunTmChk.lib was not linked. Now we properly initialize both our own as well as MS RunTmChk lib.
svn path=/trunk/; revision=64816
2014-10-18 21:22:52 +00:00
|
|
|
extern
|
|
|
|
void
|
|
|
|
__cdecl
|
|
|
|
_RTC_NoInitialize(void)
|
2014-10-12 22:59:32 +00:00
|
|
|
{
|
[RunTmChk]
- Implement _RTC_GetErrDesc, _RTC_SetErrorFuncW, add stubs for _RTC_NumErrors, _RTC_SetErrorType, _RTC_SetErrorFunc
- Implement _RTC_DefaultErrorFuncW which will be used, when no other error func was set
- Implement _RTC_InitBase, which will be called from _RTC_Initialize, and which in turn calls either _CRT_RTC_INITW, if CRT was linked, or a local _CRT_RTC_INITW0, which in turn will return the error function to use. This allows us to use a custom error function for all modules that link to (MSV)CRT. Only user32 does not really fit into here, since it uses the same startup code but does not link to MSVCRT.
[CRT]
- Call _RTC_Initialize from __main before initializing the global constructors, but fall back to a dummy _RTC_NoInitialize(), when RunTmChk.lib was not linked. Now we properly initialize both our own as well as MS RunTmChk lib.
svn path=/trunk/; revision=64816
2014-10-18 21:22:52 +00:00
|
|
|
/* Do nothing, if RunTmChk.lib is not pulled in */
|
|
|
|
}
|
|
|
|
|
|
|
|
_RTC_error_fnW
|
|
|
|
__cdecl
|
|
|
|
_CRT_RTC_INITW(
|
|
|
|
void *_Res0,
|
|
|
|
void **_Res1,
|
|
|
|
int _Res2,
|
|
|
|
int _Res3,
|
|
|
|
int _Res4)
|
|
|
|
{
|
|
|
|
return &Catch_RTC_Failure;
|
2014-10-12 22:59:32 +00:00
|
|
|
}
|
|
|
|
|
2011-05-23 15:50:03 +00:00
|
|
|
static int initialized = 0;
|
|
|
|
|
|
|
|
void
|
2012-04-18 15:12:45 +00:00
|
|
|
__main(void)
|
2011-05-23 15:50:03 +00:00
|
|
|
{
|
|
|
|
if (!initialized)
|
|
|
|
{
|
|
|
|
initialized = 1;
|
[RunTmChk]
- Implement _RTC_GetErrDesc, _RTC_SetErrorFuncW, add stubs for _RTC_NumErrors, _RTC_SetErrorType, _RTC_SetErrorFunc
- Implement _RTC_DefaultErrorFuncW which will be used, when no other error func was set
- Implement _RTC_InitBase, which will be called from _RTC_Initialize, and which in turn calls either _CRT_RTC_INITW, if CRT was linked, or a local _CRT_RTC_INITW0, which in turn will return the error function to use. This allows us to use a custom error function for all modules that link to (MSV)CRT. Only user32 does not really fit into here, since it uses the same startup code but does not link to MSVCRT.
[CRT]
- Call _RTC_Initialize from __main before initializing the global constructors, but fall back to a dummy _RTC_NoInitialize(), when RunTmChk.lib was not linked. Now we properly initialize both our own as well as MS RunTmChk lib.
svn path=/trunk/; revision=64816
2014-10-18 21:22:52 +00:00
|
|
|
|
|
|
|
_RTC_Initialize();
|
2011-05-23 15:50:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|