From 43b07d3f6a95e047d2140cd2bd08a06688bfa491 Mon Sep 17 00:00:00 2001 From: Stefan Ginsberg Date: Fri, 21 Aug 2009 15:57:26 +0000 Subject: [PATCH] - svchost: #ifdef _MSC_VER doesn't mean "using Microsoft's headers" anymore - ddraw, imm32, msxml3, oleaut32, riched20: Include typeof.h for typeof emulation when compiling under MSVC and remove from ReactOS-generic.rbuild (this can't go to port.h as the modules do not include it). - TCPIP: Fix a check for MSVC. - NDIS: Don't use floating point arithmetics in kernel mode -- spotted by MSVC trying to link to ftol (gcc inlined the operation). - SAMLIB: Use __VA_ARGS__ instead of gcc-specific macro manipulation. - WIN32CSR: Don't use gcc-specific \% if you want % in the string -- this is incorrect and will pass a broken string to swprintf (the code seems to be uncalled though, so this shouldn't change anything). Use %% instead. - Error out on MSVC implementation of logb -- it doesn't produce the same code as the gcc version. - Rename gcc's float.h to gcc_float.h and use #include instead of #include_next for consistency. - Remove leftover header guard from types.h - Remove superfluous brackets from PSEH2->MSVC defines -- this isn't necessary anymore after 41597 - Correction to 42216: MSVC *does* let you define types in a function, but only at the top of scope. Move back the C_ASSERT into KiAcquireGuardedMutex. - Simplify definition of alloca - scripts.cpp: Silence unavoidable warning. - Remove compile time warning from Uniata -- the code has been unused for 1 1/2 years and will probably remain so. svn path=/trunk/; revision=42829 --- reactos/ReactOS-generic.rbuild | 1 - reactos/base/services/svchost/svchost.h | 2 +- reactos/dll/directx/wine/ddraw/ddraw.rbuild | 1 + reactos/dll/win32/imm32/imm32.rbuild | 1 + reactos/dll/win32/msxml3/msxml3.rbuild | 1 + reactos/dll/win32/oleaut32/oleaut32.rbuild | 1 + reactos/dll/win32/riched20/riched20.rbuild | 1 + reactos/dll/win32/samlib/debug.h | 6 +++--- reactos/drivers/network/ndis/ndis/config.c | 9 ++++++++- reactos/drivers/network/tcpip/tcpip/dispatch.c | 2 +- reactos/drivers/storage/ide/uniata/id_sata.cpp | 3 +-- reactos/include/crt/float.h | 10 +++++----- reactos/include/crt/malloc.h | 5 ----- reactos/include/crt/mingw32/{float.h => gcc_float.h} | 0 reactos/include/crt/sys/types.h | 5 +---- reactos/include/reactos/libs/pseh/pseh2.h | 8 ++++---- reactos/lib/nls/scripts/scripts.cpp | 9 +++++++++ reactos/lib/sdk/crt/float/i386/logb.c | 1 + reactos/ntoskrnl/ke/wait.c | 6 +++--- reactos/subsystems/win32/csrss/win32csr/guiconsole.c | 4 ++-- 20 files changed, 44 insertions(+), 32 deletions(-) rename reactos/include/crt/mingw32/{float.h => gcc_float.h} (100%) diff --git a/reactos/ReactOS-generic.rbuild b/reactos/ReactOS-generic.rbuild index 91aa3871a44..7b1388b3099 100644 --- a/reactos/ReactOS-generic.rbuild +++ b/reactos/ReactOS-generic.rbuild @@ -100,7 +100,6 @@ /Zl /Zi /W1 - /FIwine/typeof.h diff --git a/reactos/base/services/svchost/svchost.h b/reactos/base/services/svchost/svchost.h index d5e42874f87..390b4d02b0b 100644 --- a/reactos/base/services/svchost/svchost.h +++ b/reactos/base/services/svchost/svchost.h @@ -10,7 +10,7 @@ /* INCLUDES ******************************************************************/ -#ifdef _MSC_VER +#if 0 #define _CRT_SECURE_NO_DEPRECATE 1 #endif diff --git a/reactos/dll/directx/wine/ddraw/ddraw.rbuild b/reactos/dll/directx/wine/ddraw/ddraw.rbuild index 98663668d4f..9a905af1940 100644 --- a/reactos/dll/directx/wine/ddraw/ddraw.rbuild +++ b/reactos/dll/directx/wine/ddraw/ddraw.rbuild @@ -7,6 +7,7 @@ include/reactos/wine + /FIwine/typeof.h advapi32 dxguid diff --git a/reactos/dll/win32/imm32/imm32.rbuild b/reactos/dll/win32/imm32/imm32.rbuild index 2a15eb09246..a0d9b601814 100644 --- a/reactos/dll/win32/imm32/imm32.rbuild +++ b/reactos/dll/win32/imm32/imm32.rbuild @@ -7,6 +7,7 @@ include/reactos/wine 0x600 + /FIwine/typeof.h imm.c version.rc wine diff --git a/reactos/dll/win32/msxml3/msxml3.rbuild b/reactos/dll/win32/msxml3/msxml3.rbuild index 4c09c2c4910..005568d25ef 100644 --- a/reactos/dll/win32/msxml3/msxml3.rbuild +++ b/reactos/dll/win32/msxml3/msxml3.rbuild @@ -10,6 +10,7 @@ 0x601 + /FIwine/typeof.h libxml2 libxslt wine diff --git a/reactos/dll/win32/oleaut32/oleaut32.rbuild b/reactos/dll/win32/oleaut32/oleaut32.rbuild index 5d5c1846f70..faf5ce213ea 100644 --- a/reactos/dll/win32/oleaut32/oleaut32.rbuild +++ b/reactos/dll/win32/oleaut32/oleaut32.rbuild @@ -15,6 +15,7 @@ OLEAUTPS_ + /FIwine/typeof.h connpt.c dispatch.c hash.c diff --git a/reactos/dll/win32/riched20/riched20.rbuild b/reactos/dll/win32/riched20/riched20.rbuild index 384445726f5..f28a2fa0e14 100644 --- a/reactos/dll/win32/riched20/riched20.rbuild +++ b/reactos/dll/win32/riched20/riched20.rbuild @@ -6,6 +6,7 @@ . include/reactos/wine + /FIwine/typeof.h -enable-stdcall-fixup caret.c clipboard.c diff --git a/reactos/dll/win32/samlib/debug.h b/reactos/dll/win32/samlib/debug.h index 6fdb2ede142..b54107f482c 100644 --- a/reactos/dll/win32/samlib/debug.h +++ b/reactos/dll/win32/samlib/debug.h @@ -1,12 +1,12 @@ #ifdef NDEBUG -#define DPRINT(args...) +#define DPRINT(...) #define CHECKPOINT #else -#define DPRINT(args...) do { DebugPrint("(SAMLIB:%s:%d) ",__FILE__,__LINE__); DebugPrint(args); } while(0) +#define DPRINT(...) do { DebugPrint("(SAMLIB:%s:%d) ",__FILE__,__LINE__); DebugPrint(__VA_ARGS__); } while(0) #define CHECKPOINT do { DebugPrint("(SAMLIB:%s:%d) Checkpoint\n",__FILE__,__LINE__); } while(0) #endif -#define DPRINT1(args...) do { DebugPrint("(SAMLIB:%s:%d) ",__FILE__,__LINE__); DebugPrint(args); } while(0) +#define DPRINT1(...) do { DebugPrint("(SAMLIB:%s:%d) ",__FILE__,__LINE__); DebugPrint(__VA_ARGS__); } while(0) #define CHECKPOINT1 do { DebugPrint("(SAMLIB:%s:%d) Checkpoint\n",__FILE__,__LINE__); } while(0) diff --git a/reactos/drivers/network/ndis/ndis/config.c b/reactos/drivers/network/ndis/ndis/config.c index f83be9ea291..85bc7e05316 100644 --- a/reactos/drivers/network/ndis/ndis/config.c +++ b/reactos/drivers/network/ndis/ndis/config.c @@ -705,7 +705,14 @@ NdisReadNetworkAddress( while (j < str.Length && str.Buffer[j] != '\0') j++; - *NetworkAddressLength = (UINT)((j/2)+0.5); + if ((j % 2) == 0) + { + *NetworkAddressLength = (UINT)(j/2); + } + else + { + *NetworkAddressLength = (UINT)((j/2)+1); + } if ((*NetworkAddressLength) == 0) { diff --git a/reactos/drivers/network/tcpip/tcpip/dispatch.c b/reactos/drivers/network/tcpip/tcpip/dispatch.c index 4b0aa94426f..06ffa1bc190 100644 --- a/reactos/drivers/network/tcpip/tcpip/dispatch.c +++ b/reactos/drivers/network/tcpip/tcpip/dispatch.c @@ -1058,7 +1058,7 @@ NTSTATUS DispTdiSendDatagram( ("About to call send routine %x\n", (*((PADDRESS_FILE)Request.Handle.AddressHandle)->Send))); - if( (*((PADDRESS_FILE)Request.Handle.AddressHandle)->Send) ) + if( (*((PADDRESS_FILE)Request.Handle.AddressHandle)->Send != NULL) ) Status = (*((PADDRESS_FILE)Request.Handle.AddressHandle)->Send)( Request.Handle.AddressHandle, DgramInfo->SendDatagramInformation, diff --git a/reactos/drivers/storage/ide/uniata/id_sata.cpp b/reactos/drivers/storage/ide/uniata/id_sata.cpp index 9b0d1e08c2e..e175f195a6b 100644 --- a/reactos/drivers/storage/ide/uniata/id_sata.cpp +++ b/reactos/drivers/storage/ide/uniata/id_sata.cpp @@ -426,9 +426,8 @@ UniataAhciSetupFIS( i++; } else { #ifdef _MSC_VER -#pragma message ("HACK HACK HACK Disabling warning HACK HACK HACK") #pragma warning(push) -#pragma warning(disable:4333) +#pragma warning(disable:4333) // right shift by too large amount, data loss #endif fis[7] |= (plba[3] >> 24) & 0x0f; #ifdef _MSC_VER diff --git a/reactos/include/crt/float.h b/reactos/include/crt/float.h index caa2d0df90b..13bde7b8e2a 100644 --- a/reactos/include/crt/float.h +++ b/reactos/include/crt/float.h @@ -16,12 +16,12 @@ * */ -#ifdef __GNUC__ -#include_next -#endif - -#ifdef _MSC_VER +#if defined(__GNUC__) +#include +#elif defined(_MSC_VER) #include +#else +#error #endif #ifndef _MINGW_FLOAT_H_ diff --git a/reactos/include/crt/malloc.h b/reactos/include/crt/malloc.h index 18ffa80cdb7..24d7c38b27c 100644 --- a/reactos/include/crt/malloc.h +++ b/reactos/include/crt/malloc.h @@ -146,13 +146,8 @@ extern "C" { #endif /* RC_INVOKED */ #ifndef NO_OLDNAMES -#undef alloca -#ifdef __GNUC__ -#define alloca(x) __builtin_alloca((x)) -#else #define alloca _alloca #endif -#endif #ifdef HEAPHOOK #ifndef _HEAPHOOK_DEFINED diff --git a/reactos/include/crt/mingw32/float.h b/reactos/include/crt/mingw32/gcc_float.h similarity index 100% rename from reactos/include/crt/mingw32/float.h rename to reactos/include/crt/mingw32/gcc_float.h diff --git a/reactos/include/crt/sys/types.h b/reactos/include/crt/sys/types.h index eef90b05782..adec8179db5 100644 --- a/reactos/include/crt/sys/types.h +++ b/reactos/include/crt/sys/types.h @@ -36,9 +36,7 @@ typedef unsigned int dev_t; # endif #endif -#ifdef _WINE -#ifndef _PID_T_ -#define _PID_T_ +#if defined(_WINE) #ifndef _WIN64 typedef int _pid_t; #else @@ -50,7 +48,6 @@ typedef __int64 _pid_t; typedef _pid_t pid_t; #endif /* __pid_t_defined */ #endif -#endif /* Not _PID_T_ */ #endif #endif /* !_INC_TYPES */ diff --git a/reactos/include/reactos/libs/pseh/pseh2.h b/reactos/include/reactos/libs/pseh/pseh2.h index b585b0c25c3..9c10af5c95d 100644 --- a/reactos/include/reactos/libs/pseh/pseh2.h +++ b/reactos/include/reactos/libs/pseh/pseh2.h @@ -370,10 +370,10 @@ __SEH_END_SCOPE_CHAIN; #include -#define _SEH2_TRY __try { -#define _SEH2_FINALLY } __finally { -#define _SEH2_EXCEPT(...) } __except(__VA_ARGS__) { -#define _SEH2_END } +#define _SEH2_TRY __try +#define _SEH2_FINALLY __finally +#define _SEH2_EXCEPT(...) __except(__VA_ARGS__) +#define _SEH2_END #define _SEH2_GetExceptionInformation() (GetExceptionInformation()) #define _SEH2_GetExceptionCode() (GetExceptionCode()) diff --git a/reactos/lib/nls/scripts/scripts.cpp b/reactos/lib/nls/scripts/scripts.cpp index faaac2a2a8e..c2bb1d35075 100644 --- a/reactos/lib/nls/scripts/scripts.cpp +++ b/reactos/lib/nls/scripts/scripts.cpp @@ -45,6 +45,11 @@ #include "scripts.h" +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4351) // elements of array 'array' will be default initialized +#endif + struct SCRIPTS_ScriptsSet { private: @@ -145,6 +150,10 @@ public: } }; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + int WINAPI GetStringScripts diff --git a/reactos/lib/sdk/crt/float/i386/logb.c b/reactos/lib/sdk/crt/float/i386/logb.c index b0bd79930ee..dc2b4064484 100644 --- a/reactos/lib/sdk/crt/float/i386/logb.c +++ b/reactos/lib/sdk/crt/float/i386/logb.c @@ -29,6 +29,7 @@ double _logb (double __x) ("fxtract\n\t" : "=t" (__junk), "=u" (__val) : "0" (__x)); #else +#error REVIEW ME __asm fld [__x]; __asm fxtract; __asm fstp st(0); diff --git a/reactos/ntoskrnl/ke/wait.c b/reactos/ntoskrnl/ke/wait.c index ac1ae640d51..83d9c691fbb 100644 --- a/reactos/ntoskrnl/ke/wait.c +++ b/reactos/ntoskrnl/ke/wait.c @@ -117,15 +117,15 @@ KiAcquireFastMutex(IN PFAST_MUTEX FastMutex) NULL); } -/* KiAcquireGuardedMutex depends on these bits being right */ -C_ASSERT((GM_LOCK_WAITER_WOKEN * 2) == GM_LOCK_WAITER_INC); - VOID FASTCALL KiAcquireGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex) { ULONG BitsToRemove, BitsToAdd; LONG OldValue, NewValue; + + /* We depend on these bits being just right */ + C_ASSERT((GM_LOCK_WAITER_WOKEN * 2) == GM_LOCK_WAITER_INC); /* Increase the contention count */ GuardedMutex->Contention++; diff --git a/reactos/subsystems/win32/csrss/win32csr/guiconsole.c b/reactos/subsystems/win32/csrss/win32csr/guiconsole.c index 86c0e092c87..1b43429cc12 100644 --- a/reactos/subsystems/win32/csrss/win32csr/guiconsole.c +++ b/reactos/subsystems/win32/csrss/win32csr/guiconsole.c @@ -375,11 +375,11 @@ GuiConsoleOpenUserSettings(PGUI_CONSOLE_DATA GuiData, DWORD ProcessId, PHKEY hSu while((ptr = wcschr(szProcessName, L'\\'))) ptr[0] = L'_'; - swprintf(szBuffer, L"Console\\\%SystemRoot\%%S", &szProcessName[wLength]); + swprintf(szBuffer, L"Console\\%%SystemRoot%%%S", &szProcessName[wLength]); DPRINT("#3 Path : %S\n", szBuffer); if (RegOpenKeyExW(hKey, szBuffer, 0, samDesired, hSubKey) == ERROR_SUCCESS) { - swprintf(GuiData->szProcessName, L"\%SystemRoot\%%S", &szProcessName[wLength]); + swprintf(GuiData->szProcessName, L"%%SystemRoot%%%S", &szProcessName[wLength]); RegCloseKey(hKey); return TRUE; }