summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Windows/Process.inc
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2018-11-06 23:39:59 +0000
committerReid Kleckner <rnk@google.com>2018-11-06 23:39:59 +0000
commitc30932248fd73e7ada87ea832ccf7789826639bf (patch)
tree00244f9e7fc8377baeae05db39086dfebc8d4855 /llvm/lib/Support/Windows/Process.inc
parent39b6ba9f3311854672fab754b6263c5db0bb9166 (diff)
downloadbcm5719-llvm-c30932248fd73e7ada87ea832ccf7789826639bf.tar.gz
bcm5719-llvm-c30932248fd73e7ada87ea832ccf7789826639bf.zip
[Windows] Simplify WindowsSupport.h
Sink Windows version detection code from WindowsSupport.h to Path.inc. These functions don't need to be inlined. I randomly picked Process.inc for the Windows version helpers, since that's the most related file. Sink MakeErrMsg to Program.inc since it's the main client. Move those functions into the llvm namespace, and delete the scoped handle copy and assignment operators. Reviewers: zturner, aganea Differential Revision: https://reviews.llvm.org/D54182 llvm-svn: 346280
Diffstat (limited to 'llvm/lib/Support/Windows/Process.inc')
-rw-r--r--llvm/lib/Support/Windows/Process.inc24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Support/Windows/Process.inc b/llvm/lib/Support/Windows/Process.inc
index ce646d63609..2b2d7923143 100644
--- a/llvm/lib/Support/Windows/Process.inc
+++ b/llvm/lib/Support/Windows/Process.inc
@@ -460,3 +460,27 @@ unsigned Process::GetRandomNumber() {
ReportLastErrorFatal("Could not generate a random number");
return Ret;
}
+
+typedef NTSTATUS(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
+#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
+
+llvm::VersionTuple llvm::GetWindowsOSVersion() {
+ HMODULE hMod = ::GetModuleHandleW(L"ntdll.dll");
+ if (hMod) {
+ auto getVer = (RtlGetVersionPtr)::GetProcAddress(hMod, "RtlGetVersion");
+ if (getVer) {
+ RTL_OSVERSIONINFOEXW info{};
+ info.dwOSVersionInfoSize = sizeof(info);
+ if (getVer((PRTL_OSVERSIONINFOW)&info) == STATUS_SUCCESS) {
+ return llvm::VersionTuple(info.dwMajorVersion, info.dwMinorVersion, 0,
+ info.dwBuildNumber);
+ }
+ }
+ }
+ return llvm::VersionTuple(0, 0, 0, 0);
+}
+
+bool llvm::RunningWindows8OrGreater() {
+ // Windows 8 is version 6.2, service pack 0.
+ return GetWindowsOSVersion() >= llvm::VersionTuple(6, 2, 0, 0);
+}
OpenPOWER on IntegriCloud