1
1
forked from 0ad/0ad

fixes from work: use ICC bswap intrinsics instead of fallbacks; update UNUSED2 to work with ICC; update mahaf for Win7

This was SVN commit r8553.
This commit is contained in:
janwas 2010-11-08 10:01:12 +00:00
parent 9c53fda749
commit 6b4d5091b3
3 changed files with 23 additions and 12 deletions

View File

@ -127,15 +127,16 @@ LIB_API i64 movsx_le64(const u8* p, size_t size);
LIB_API i64 movsx_be64(const u8* p, size_t size); LIB_API i64 movsx_be64(const u8* p, size_t size);
#if MSC_VERSION #if ICC_VERSION
#define swap32 _bswap
#define swap64 _bswap64
#elif MSC_VERSION
extern unsigned short _byteswap_ushort(unsigned short); extern unsigned short _byteswap_ushort(unsigned short);
extern unsigned long _byteswap_ulong(unsigned long); extern unsigned long _byteswap_ulong(unsigned long);
extern unsigned __int64 _byteswap_uint64(unsigned __int64); extern unsigned __int64 _byteswap_uint64(unsigned __int64);
# if !ICC_VERSION // ICC doesn't need (and warns about) the pragmas #pragma intrinsic(_byteswap_ushort)
# pragma intrinsic(_byteswap_ushort) #pragma intrinsic(_byteswap_ulong)
# pragma intrinsic(_byteswap_ulong) #pragma intrinsic(_byteswap_uint64)
# pragma intrinsic(_byteswap_uint64)
# endif
# define swap16 _byteswap_ushort # define swap16 _byteswap_ushort
# define swap32 _byteswap_ulong # define swap32 _byteswap_ulong
# define swap64 _byteswap_uint64 # define swap64 _byteswap_uint64

View File

@ -27,12 +27,20 @@
#ifndef INCLUDED_CODE_ANNOTATION #ifndef INCLUDED_CODE_ANNOTATION
#define INCLUDED_CODE_ANNOTATION #define INCLUDED_CODE_ANNOTATION
#include "lib/sysdep/compiler.h"
/** /**
* mark a function local variable or parameter as unused and avoid * mark a function local variable or parameter as unused and avoid
* the corresponding compiler warning. * the corresponding compiler warning.
* use inside the function body, e.g. void f(int x) { UNUSED2(x); } * use inside the function body, e.g. void f(int x) { UNUSED2(x); }
**/ **/
#define UNUSED2(param) (void)param; #if ICC_VERSION
// NB: #pragma unused is documented but "unrecognized" when used;
// casting to void isn't sufficient, but the following is:
# define UNUSED2(param) param = param
#else
# define UNUSED2(param) (void)param
#endif
/** /**
* mark a function parameter as unused and avoid * mark a function parameter as unused and avoid

View File

@ -218,7 +218,7 @@ static SC_HANDLE OpenServiceControlManager()
// Least-Permission accounts to use it, but is too invasive and // Least-Permission accounts to use it, but is too invasive and
// thus out of the question. // thus out of the question.
// make sure the error is as expected, otherwise something is afoot. // rule out other problems
debug_assert(GetLastError() == ERROR_ACCESS_DENIED); debug_assert(GetLastError() == ERROR_ACCESS_DENIED);
return 0; return 0;
@ -286,9 +286,10 @@ static void StartDriver(const fs::wpath& driverPathname)
if(!hService) if(!hService)
{ {
LPCWSTR startName = 0; // LocalSystem LPCWSTR startName = 0; // LocalSystem
// NB: Windows 7 seems to insist upon backslashes (i.e. external_file_string)
hService = CreateServiceW(hSCM, AKEN_NAME, AKEN_NAME, hService = CreateServiceW(hSCM, AKEN_NAME, AKEN_NAME,
SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL, SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER, SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
driverPathname.string().c_str(), 0, 0, 0, startName, 0); driverPathname.external_file_string().c_str(), 0, 0, 0, startName, 0);
debug_assert(hService != 0); debug_assert(hService != 0);
} }
@ -302,7 +303,7 @@ static void StartDriver(const fs::wpath& driverPathname)
{ {
// starting failed. don't raise a warning because this // starting failed. don't raise a warning because this
// always happens on least-permission user accounts. // always happens on least-permission user accounts.
//WARN_IF_FALSE(0); //debug_assert(0);
} }
} }
} }
@ -340,7 +341,7 @@ static fs::wpath DriverPathname()
static LibError Init() static LibError Init()
{ {
if(wutil_HasCommandLineArgument(L"-wNoMahaf")) if(wutil_HasCommandLineArgument(L"-wNoMahaf"))
return ERR::NOT_SUPPORTED; return ERR::NOT_SUPPORTED; // NOWARN
{ {
const fs::wpath driverPathname = DriverPathname(); const fs::wpath driverPathname = DriverPathname();
@ -351,7 +352,7 @@ static LibError Init()
const DWORD shareMode = 0; const DWORD shareMode = 0;
hAken = CreateFileW(L"\\\\.\\Aken", GENERIC_READ, shareMode, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); hAken = CreateFileW(L"\\\\.\\Aken", GENERIC_READ, shareMode, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if(hAken == INVALID_HANDLE_VALUE) if(hAken == INVALID_HANDLE_VALUE)
return ERR::INVALID_HANDLE; return ERR::INVALID_HANDLE; // NOWARN (happens often due to security restrictions)
} }
return INFO::OK; return INFO::OK;
@ -365,6 +366,7 @@ static void Shutdown()
UninstallDriver(); UninstallDriver();
} }
static ModuleInitState initState; static ModuleInitState initState;
LibError mahaf_Init() LibError mahaf_Init()