diff options
Diffstat (limited to 'lib/Support/Windows/WindowsSupport.h')
| -rw-r--r-- | lib/Support/Windows/WindowsSupport.h | 51 | 
1 files changed, 13 insertions, 38 deletions
diff --git a/lib/Support/Windows/WindowsSupport.h b/lib/Support/Windows/WindowsSupport.h index c2fd6bb982d42..979cc5d013904 100644 --- a/lib/Support/Windows/WindowsSupport.h +++ b/lib/Support/Windows/WindowsSupport.h @@ -41,6 +41,7 @@  #include "llvm/Config/config.h" // Get build system configuration settings  #include "llvm/Support/Chrono.h"  #include "llvm/Support/Compiler.h" +#include "llvm/Support/VersionTuple.h"  #include <cassert>  #include <string>  #include <system_error> @@ -49,54 +50,29 @@  // Must be included after windows.h  #include <wincrypt.h> +namespace llvm { +  /// Determines if the program is running on Windows 8 or newer. This  /// 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); -  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; -} +bool RunningWindows8OrGreater(); -inline bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix) { -  if (!ErrMsg) -    return true; -  char *buffer = NULL; -  DWORD LastError = GetLastError(); -  DWORD R = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | -                               FORMAT_MESSAGE_FROM_SYSTEM | -                               FORMAT_MESSAGE_MAX_WIDTH_MASK, -                           NULL, LastError, 0, (LPSTR)&buffer, 1, NULL); -  if (R) -    *ErrMsg = prefix + ": " + buffer; -  else -    *ErrMsg = prefix + ": Unknown error"; -  *ErrMsg += " (0x" + llvm::utohexstr(LastError) + ")"; - -  LocalFree(buffer); -  return R != 0; -} +/// Returns the Windows version as Major.Minor.0.BuildNumber. Uses +/// RtlGetVersion or GetVersionEx under the hood depending on what is available. +/// GetVersionEx is deprecated, but this API exposes the build number which can +/// be useful for working around certain kernel bugs. +llvm::VersionTuple GetWindowsOSVersion(); + +bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix);  template <typename HandleTraits>  class ScopedHandle {    typedef typename HandleTraits::handle_type handle_type;    handle_type Handle; -  ScopedHandle(const ScopedHandle &other); // = delete; -  void operator=(const ScopedHandle &other); // = delete; +  ScopedHandle(const ScopedHandle &other) = delete; +  void operator=(const ScopedHandle &other) = delete;  public:    ScopedHandle()      : Handle(HandleTraits::GetInvalid()) {} @@ -201,7 +177,6 @@ typedef ScopedHandle<RegTraits>          ScopedRegHandle;  typedef ScopedHandle<FindHandleTraits>   ScopedFindHandle;  typedef ScopedHandle<JobHandleTraits>    ScopedJobHandle; -namespace llvm {  template <class T>  class SmallVectorImpl;  | 
