X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=lib%2FSupport%2FWindows%2FWindowsSupport.h;h=60490f2664345baf03504449ec997beee78df3c6;hp=cb091f186404dd7e8193b95e04f5b063d55f6058;hb=4e5af8fec07665154fd7b290c4ce2ab16000eee3;hpb=f8f4df59dc4afa5478d3e307e9d5aa38e3946755 diff --git a/lib/Support/Windows/WindowsSupport.h b/lib/Support/Windows/WindowsSupport.h index cb091f18640..60490f26643 100644 --- a/lib/Support/Windows/WindowsSupport.h +++ b/lib/Support/Windows/WindowsSupport.h @@ -48,16 +48,25 @@ #include /// Determines if the program is running on Windows 8 or newer. This -/// reimplements the helpers in the Windows 8.1 SDK, which are intended to -/// supercede raw calls to GetVersionEx, because old Windows SDKs, Cygwin, and -/// MinGW don't have VersionSupport.h yet. -inline bool IsWindows8OrGreater() { - OSVERSIONINFO osvi = {}; +/// reimplements one of the helpers in the Windows 8.1 SDK, which are intended +/// to supercede raw calls to GetVersionEx. Old SDKs, Cygwin, and MinGW don't +/// yet have VersionHelpers.h, so we have our own helper. +inline bool RunningWindows8OrGreater() { + // Windows 8 is version 6.2, service pack 0. + OSVERSIONINFOEXW osvi = {}; osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (!::GetVersionEx(&osvi)) - return false; - return (osvi.dwMajorVersion > 6 || - (osvi.dwMajorVersion == 6 && osvi.dwMinorVersion >= 2)); + osvi.dwMajorVersion = 6; + osvi.dwMinorVersion = 2; + osvi.wServicePackMajor = 0; + + DWORDLONG Mask = 0; + Mask = VerSetConditionMask(Mask, VER_MAJORVERSION, VER_GREATER_EQUAL); + Mask = VerSetConditionMask(Mask, VER_MINORVERSION, VER_GREATER_EQUAL); + Mask = VerSetConditionMask(Mask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL); + + return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | + VER_SERVICEPACKMAJOR, + Mask) != FALSE; } inline bool MakeErrMsg(std::string* ErrMsg, const std::string& prefix) {