From 3933ca6bce3443b51cc131366614ce537dab4a43 Mon Sep 17 00:00:00 2001 From: David Quintana Date: Thu, 30 Apr 2015 21:48:26 +0000 Subject: [PATCH] This commit brings support for compiling ReactOS with Visual Studio 2015 RC (and possibly the final release). [BUILD] msvc.cmake: Disable thread-local static initialization. CMakeLists.txt: Disable PCH for VS2015. configure.cmd: Make it aware of cl.exe version 19.x [CPPRT] Add alias for the new variants of the delete operators. [BROWSEUI] [MFIFS] [FRAMEDYN] [NDIS] [DDK] [PSDK] [STLPORT] Add explicit declarations of the new delete operators for those modules that don't use the WITH_RUNTIME option. [WIDL] [WPP] Do not alias the snprintf family of functions to the _snprintf variants, since VS14 already declares them internally. svn path=/trunk/; revision=67483 --- reactos/CMakeLists.txt | 2 +- reactos/cmake/msvc.cmake | 5 +++++ reactos/configure.cmd | 1 + reactos/dll/win32/browseui/utility.cpp | 5 +++++ reactos/dll/win32/fmifs/precomp.h | 3 ++- reactos/dll/win32/framedyn/chstring.cpp | 13 +++++++++++++ reactos/drivers/network/ndis/include/ndissys.h | 14 +++++++------- reactos/include/ddk/stdunk.h | 7 +++++++ reactos/include/psdk/kcom.h | 6 ++++++ .../lib/3rdparty/stlport/test/eh/nc_alloc.cpp | 8 ++++++++ reactos/lib/sdk/cpprt/i386/cpprt.s | 10 ++++++++++ reactos/tools/widl/CMakeLists.txt | 10 ++++++---- reactos/tools/wpp/CMakeLists.txt | 16 +++++++++------- 13 files changed, 80 insertions(+), 20 deletions(-) diff --git a/reactos/CMakeLists.txt b/reactos/CMakeLists.txt index 01777800242..59d6c4c5542 100644 --- a/reactos/CMakeLists.txt +++ b/reactos/CMakeLists.txt @@ -137,7 +137,7 @@ else() add_definitions(-D_WINKD_=1) endif() - if(CMAKE_VERSION MATCHES "ReactOS") + if(CMAKE_VERSION MATCHES "ReactOS" AND MSVC_VERSION LESS 1900) set(PCH 1 CACHE BOOL "Whether to use precompiled headers") else() set(PCH 0 CACHE BOOL "Whether to use precompiled headers") diff --git a/reactos/cmake/msvc.cmake b/reactos/cmake/msvc.cmake index 53e4f075e9c..af6f501e964 100644 --- a/reactos/cmake/msvc.cmake +++ b/reactos/cmake/msvc.cmake @@ -33,6 +33,11 @@ if(MSVC_VERSION GREATER 1799 AND NOT MSVC_IDE) add_compile_flags("/FS") endif () +# VS14+ tries to use thread-safe initialization +if(MSVC_VERSION GREATER 1899) + add_compile_flags("/Zc:threadSafeInit-") +endif () + # Disable overly sensitive warnings as well as those that generally aren't # useful to us. # - C4244: implicit integer truncation diff --git a/reactos/configure.cmd b/reactos/configure.cmd index d6cfb525429..2d61b43864c 100755 --- a/reactos/configure.cmd +++ b/reactos/configure.cmd @@ -56,6 +56,7 @@ if defined ROS_ARCH ( cl 2>&1 | find "16.00." > NUL && set VS_VERSION=10 cl 2>&1 | find "17.00." > NUL && set VS_VERSION=11 cl 2>&1 | find "18.00." > NUL && set VS_VERSION=12 + cl 2>&1 | find "19.00." > NUL && set VS_VERSION=14 if not defined VS_VERSION ( echo Error: Visual Studio version too old or version detection failed. exit /b diff --git a/reactos/dll/win32/browseui/utility.cpp b/reactos/dll/win32/browseui/utility.cpp index fa07188d1e7..15c891b672e 100644 --- a/reactos/dll/win32/browseui/utility.cpp +++ b/reactos/dll/win32/browseui/utility.cpp @@ -9,3 +9,8 @@ void operator delete(void *p) { LocalFree(p); } + +void operator delete(void *p, unsigned int) +{ + LocalFree(p); +} diff --git a/reactos/dll/win32/fmifs/precomp.h b/reactos/dll/win32/fmifs/precomp.h index 0d2218f47f8..a72cf5e5b1f 100644 --- a/reactos/dll/win32/fmifs/precomp.h +++ b/reactos/dll/win32/fmifs/precomp.h @@ -13,9 +13,10 @@ /* INCLUDES ******************************************************************/ +#define WIN32_NO_STATUS + #include -#define WIN32_NO_STATUS /* PSDK/NDK Headers */ #include diff --git a/reactos/dll/win32/framedyn/chstring.cpp b/reactos/dll/win32/framedyn/chstring.cpp index d9bf714993e..3b43c456cb7 100644 --- a/reactos/dll/win32/framedyn/chstring.cpp +++ b/reactos/dll/win32/framedyn/chstring.cpp @@ -54,6 +54,19 @@ void operator delete(void* ptr) } } +#if _MSC_VER >= 51900 +void __cdecl operator delete(void* ptr, unsigned int) +{ + // In Windows 2k3, they check for ptr being null. + // ISO, POSIX and even MSDN explains that it is allowed + // to call free with NULL pointer... + if (ptr) + { + free(ptr); + } +} +#endif + // Implement our own new operator so that we can throw our own exception in case // of allocation failure. // It could have been done using set_new_handler(), but well. MS guys didn't do it diff --git a/reactos/drivers/network/ndis/include/ndissys.h b/reactos/drivers/network/ndis/include/ndissys.h index b80a6a0bbfa..6c2fa358ef3 100644 --- a/reactos/drivers/network/ndis/include/ndissys.h +++ b/reactos/drivers/network/ndis/include/ndissys.h @@ -10,6 +10,13 @@ #ifndef __NDISSYS_H #define __NDISSYS_H +/* portability fixes */ +#ifdef _M_AMD64 +#define KfReleaseSpinLock KeReleaseSpinLock +#define KefAcquireSpinLockAtDpcLevel KeAcquireSpinLockAtDpcLevel +#define KefReleaseSpinLockFromDpcLevel KeReleaseSpinLockFromDpcLevel +#endif + #include #include "debug.h" @@ -54,11 +61,4 @@ NTAPI ExGetCurrentProcessorCpuUsage( PULONG CpuUsage); -/* portability fixes */ -#ifdef _M_AMD64 -#define KfReleaseSpinLock KeReleaseSpinLock -#define KefAcquireSpinLockAtDpcLevel KeAcquireSpinLockAtDpcLevel -#define KefReleaseSpinLockFromDpcLevel KeReleaseSpinLockFromDpcLevel -#endif - #endif /* __NDISSYS_H */ diff --git a/reactos/include/ddk/stdunk.h b/reactos/include/ddk/stdunk.h index 6f95270aa4d..f9915cfc87a 100644 --- a/reactos/include/ddk/stdunk.h +++ b/reactos/include/ddk/stdunk.h @@ -204,6 +204,13 @@ operator delete( ExFreePool(ptr); } +inline void __cdecl +operator delete( + PVOID ptr, UINT unk) +{ + ExFreePool(ptr); +} + #endif /* ALLOCATION_OPERATORS_DEFINED */ diff --git a/reactos/include/psdk/kcom.h b/reactos/include/psdk/kcom.h index 0edbf563e87..956e25f6978 100644 --- a/reactos/include/psdk/kcom.h +++ b/reactos/include/psdk/kcom.h @@ -234,6 +234,12 @@ inline void __cdecl operator delete( if (pVoid) ExFreePool(pVoid); } +inline void __cdecl operator delete( + PVOID pVoid, UINT unk) +{ + if (pVoid) ExFreePool(pVoid); +} + #endif /* _NEW_DELETE_OPERATORS_ */ #if defined(_SYS_GUID_OPERATOR_EQ_) diff --git a/reactos/lib/3rdparty/stlport/test/eh/nc_alloc.cpp b/reactos/lib/3rdparty/stlport/test/eh/nc_alloc.cpp index 6234eab0e23..c8e58915771 100644 --- a/reactos/lib/3rdparty/stlport/test/eh/nc_alloc.cpp +++ b/reactos/lib/3rdparty/stlport/test/eh/nc_alloc.cpp @@ -264,6 +264,14 @@ void _STLP_CALL operator delete(void* s) } } +#if defined (EH_DELETE_HAS_THROW_SPEC) +void _STLP_CALL operator delete(void* s, unsigned int) throw() +#else +void _STLP_CALL operator delete(void* s, unsigned int) +#endif +{ + ::operator delete(s); +} /*=================================================================================== ClearAllocationSet (private helper) diff --git a/reactos/lib/sdk/cpprt/i386/cpprt.s b/reactos/lib/sdk/cpprt/i386/cpprt.s index da85111d5b5..8935893ab15 100644 --- a/reactos/lib/sdk/cpprt/i386/cpprt.s +++ b/reactos/lib/sdk/cpprt/i386/cpprt.s @@ -27,7 +27,17 @@ _CallCxxFrameHandler: ; void __stdcall `eh vector constructor iterator'(void *,unsigned int,int,void (__thiscall*)(void *),void (__thiscall*)(void *)) DEFINE_ALIAS ??_L@YGXPAXIHP6EX0@Z1@Z, ?MSVCRTEX_eh_vector_constructor_iterator@@YGXPAXIHP6EX0@Z1@Z +; void __stdcall `eh vector constructor iterator'(void *,unsigned int,int,void (__thiscall*)(void *),void (__thiscall*)(void *)) +DEFINE_ALIAS ??_L@YGXPAXIIP6EX0@Z1@Z, ?MSVCRTEX_eh_vector_constructor_iterator@@YGXPAXIHP6EX0@Z1@Z + ; void __stdcall `eh vector destructor iterator'(void *,unsigned int,int,void (__thiscall*)(void *)) DEFINE_ALIAS ??_M@YGXPAXIHP6EX0@Z@Z, ?MSVCRTEX_eh_vector_destructor_iterator@@YGXPAXIHP6EX0@Z@Z +; void __stdcall `eh vector destructor iterator'(void *,unsigned int,unsigned int,void (__thiscall*)(void *)) +DEFINE_ALIAS ??_M@YGXPAXIIP6EX0@Z@Z, ?MSVCRTEX_eh_vector_destructor_iterator@@YGXPAXIHP6EX0@Z@Z + +; void __cdecl operator delete(void *,unsigned int) +DEFINE_ALIAS ??3@YAXPAXI@Z, ??3@YAXPAX@Z +DEFINE_ALIAS ??3@YAXPAXII@Z, ??3@YAXPAX@Z + END diff --git a/reactos/tools/widl/CMakeLists.txt b/reactos/tools/widl/CMakeLists.txt index 7fe6a4c1be4..009c4152994 100644 --- a/reactos/tools/widl/CMakeLists.txt +++ b/reactos/tools/widl/CMakeLists.txt @@ -1,10 +1,12 @@ if(MSVC) - add_definitions(-Dsnprintf=_snprintf) + if(MSVC_VERSION LESS 1900) + add_definitions(-Dsnprintf=_snprintf) - # Add this definition for WDK only, VS 9 doesn't like that - if(DEFINED ENV{DDKBUILDENV}) - add_definitions(-Dvsnprintf=_vsnprintf) + # Add this definition for WDK only, VS 9 doesn't like that + if(DEFINED ENV{DDKBUILDENV}) + add_definitions(-Dvsnprintf=_vsnprintf) + endif() endif() list(APPEND SOURCE getopt.c) diff --git a/reactos/tools/wpp/CMakeLists.txt b/reactos/tools/wpp/CMakeLists.txt index 8150477580a..fd41bbfda3c 100644 --- a/reactos/tools/wpp/CMakeLists.txt +++ b/reactos/tools/wpp/CMakeLists.txt @@ -1,13 +1,15 @@ if(MSVC) - add_definitions( - -Dsnprintf=_snprintf - -Dstrtoull=_strtoui64 - -Dstrtoll=_strtoi64) + if(MSVC_VERSION LESS 1900) + add_definitions( + -Dsnprintf=_snprintf + -Dstrtoull=_strtoui64 + -Dstrtoll=_strtoi64) - # Add this definition for WDK only, VS 9 doesn't like that - if(DEFINED ENV{DDKBUILDENV}) - add_definitions(-Dvsnprintf=_vsnprintf) + # Add this definition for WDK only, VS 9 doesn't like that + if(DEFINED ENV{DDKBUILDENV}) + add_definitions(-Dvsnprintf=_vsnprintf) + endif() endif() endif()