mirror of
https://github.com/reactos/reactos.git
synced 2025-07-30 22:31:38 +00:00
[CMAKE/MSVC]
* Introduce support for for MSVC native run-time checks. Set RUNTIME_CHECKS to TRUE to enable it. * Dedicated to Christoph von Wittich and all ReactOS devs that use MSVC builds ;) CORE-8626 svn path=/trunk/; revision=64704
This commit is contained in:
parent
64a6fffdbc
commit
f7a5377817
7 changed files with 40 additions and 1 deletions
|
@ -502,6 +502,14 @@ function(add_importlibs _module)
|
|||
if("${LIB}" MATCHES "msvcrt")
|
||||
add_target_compile_definitions(${_module} _DLL __USE_CRTIMP)
|
||||
target_link_libraries(${_module} msvcrtex)
|
||||
if(MSVC)
|
||||
if(RUNTIME_CHECKS)
|
||||
if(NOT ${_module} STREQUAL "kernel32")
|
||||
add_target_compile_flags(${_module} "/RTC1")
|
||||
target_link_libraries(${_module} RunTmChk.lib)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(${_module} lib${LIB})
|
||||
add_dependencies(${_module} lib${LIB})
|
||||
|
|
|
@ -82,6 +82,14 @@ if(MSVC_IDE)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED RUNTIME_CHECKS)
|
||||
set(RUNTIME_CHECKS FALSE)
|
||||
endif()
|
||||
|
||||
if(RUNTIME_CHECKS)
|
||||
add_definitions(-D__RUNTIME_CHECKS__)
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /MANIFEST:NO /INCREMENTAL:NO /SAFESEH:NO /NODEFAULTLIB /RELEASE")
|
||||
|
|
|
@ -107,6 +107,10 @@ set_subsystem(kernel32 console)
|
|||
|
||||
target_link_libraries(kernel32 wine chkstk ${PSEH_LIB})
|
||||
|
||||
if(RUNTIME_CHECKS)
|
||||
target_link_libraries(kernel32 RunTmChk.lib)
|
||||
endif()
|
||||
|
||||
add_importlibs(kernel32 ntdll)
|
||||
add_pch(kernel32 k32.h SOURCE)
|
||||
add_dependencies(kernel32 psdk errcodes asm)
|
||||
|
|
|
@ -22,9 +22,12 @@ EXTERN _RtlUnwind@16:PROC
|
|||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
#ifndef __RUNTIME_CHECKS__
|
||||
PUBLIC __global_unwind2
|
||||
PUBLIC __local_unwind2
|
||||
PUBLIC __abnormal_termination
|
||||
#endif
|
||||
|
||||
PUBLIC __except_handler2
|
||||
PUBLIC __except_handler3
|
||||
|
||||
|
|
|
@ -25,8 +25,11 @@ EXTERN _RtlUnwind@16:PROC
|
|||
PUBLIC __global_unwind2
|
||||
PUBLIC __local_unwind2
|
||||
PUBLIC __abnormal_termination
|
||||
|
||||
#if !defined(__RUNTIME_CHECKS__) || (defined(__RUNTIME_CHECKS__) && !defined(_LIBCNT_))
|
||||
PUBLIC __except_handler2
|
||||
PUBLIC __except_handler3
|
||||
#endif
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ __security_init_cookie (void)
|
|||
|
||||
__declspec(noreturn) void __cdecl __report_gsfailure (ULONG_PTR);
|
||||
|
||||
#ifndef _MSC_VER
|
||||
__declspec(noreturn) void __cdecl
|
||||
__report_gsfailure (ULONG_PTR StackCookie)
|
||||
{
|
||||
|
@ -147,4 +148,4 @@ __report_gsfailure (ULONG_PTR StackCookie)
|
|||
TerminateProcess (GetCurrentProcess (), STATUS_STACK_BUFFER_OVERRUN);
|
||||
abort();
|
||||
}
|
||||
|
||||
#endif /* !_MSC_VER */
|
||||
|
|
|
@ -36,6 +36,18 @@ _CRT_INIT0(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void Catch_RTC_Failure(int errType, const wchar_t *file, int line,
|
||||
const wchar_t *module, const wchar_t *format, ...)
|
||||
{
|
||||
/* FIXME: better failure routine */
|
||||
__debugbreak();
|
||||
}
|
||||
|
||||
void* __cdecl _CRT_RTC_INITW(void *res0, void **res1, int res2, int res3, int res4)
|
||||
{
|
||||
return &Catch_RTC_Failure;
|
||||
}
|
||||
|
||||
static int initialized = 0;
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue