Bug 1368150: Add IsWindows10BuildOrNewer to MFBT; r=froydnj a=IanN CLOSED TREE DONTBUILD SEAMONKEY_2_49_ESR_RELBRANCH
authorAaron Klotz <aklotz@mozilla.com>
Thu, 29 Jun 2017 13:36:47 +0900
branchSEAMONKEY_2_49_ESR_RELBRANCH
changeset 357501 daee65cb6a9be052a5433ca527bfa27691b01659
parent 357500 73a764862ae6919e7e0d5668d12cecf782ba39f4
child 357502 1f9aa563be7a7ce9c4f49915ab4485ee11654b61
push id7834
push userfrgrahl@gmx.net
push dateSun, 13 Jan 2019 12:17:02 +0000
treeherdermozilla-esr52@6e4ad8a8f2e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj, IanN
bugs1368150
milestone52.9.1
Bug 1368150: Add IsWindows10BuildOrNewer to MFBT; r=froydnj a=IanN CLOSED TREE DONTBUILD mozilla-esr52 SEAMONKEY_2_49_ESR_RELBRANCH I need to be able to distinguish between builds of Windows 10. Unfortunately the stuff that I am working with cannot be sorted out via feature detection.
mfbt/WindowsVersion.h
--- a/mfbt/WindowsVersion.h
+++ b/mfbt/WindowsVersion.h
@@ -79,16 +79,54 @@ IsWindowsBuildOrLater(uint32_t aBuild)
     minBuild = aBuild;
     return true;
   }
 
   maxBuild = aBuild;
   return false;
 }
 
+inline bool
+IsWindows10BuildOrLater(uint32_t aBuild)
+{
+  static uint32_t minBuild = 0;
+  static uint32_t maxBuild = UINT32_MAX;
+
+  if (minBuild >= aBuild) {
+    return true;
+  }
+
+  if (aBuild >= maxBuild) {
+    return false;
+  }
+
+  OSVERSIONINFOEX info;
+  ZeroMemory(&info, sizeof(OSVERSIONINFOEX));
+  info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+  info.dwMajorVersion = 10;
+  info.dwBuildNumber = aBuild;
+
+  DWORDLONG conditionMask = 0;
+  VER_SET_CONDITION(conditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
+  VER_SET_CONDITION(conditionMask, VER_MINORVERSION, VER_GREATER_EQUAL);
+  VER_SET_CONDITION(conditionMask, VER_BUILDNUMBER, VER_GREATER_EQUAL);
+  VER_SET_CONDITION(conditionMask, VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL);
+  VER_SET_CONDITION(conditionMask, VER_SERVICEPACKMINOR, VER_GREATER_EQUAL);
+
+  if (VerifyVersionInfo(&info, VER_MAJORVERSION | VER_MINORVERSION |
+                        VER_BUILDNUMBER | VER_SERVICEPACKMAJOR |
+                        VER_SERVICEPACKMINOR, conditionMask)) {
+    minBuild = aBuild;
+    return true;
+  }
+
+  maxBuild = aBuild;
+  return false;
+}
+
 #if defined(_M_X64) || defined(_M_AMD64)
 // We support only Win7 or later on Win64.
 MOZ_ALWAYS_INLINE bool
 IsXPSP3OrLater()
 {
   return true;
 }
 
@@ -179,16 +217,22 @@ IsWin8Point1OrLater()
 
 MOZ_ALWAYS_INLINE bool
 IsWin10OrLater()
 {
   return IsWindowsVersionOrLater(0x0a000000ul);
 }
 
 MOZ_ALWAYS_INLINE bool
+IsWin10CreatorsUpdateOrLater()
+{
+  return IsWindows10BuildOrLater(15063);
+}
+
+MOZ_ALWAYS_INLINE bool
 IsNotWin7PreRTM()
 {
   return IsWin7SP1OrLater() || !IsWin7OrLater() ||
          IsWindowsBuildOrLater(7600);
 }
 
 MOZ_ALWAYS_INLINE bool
 IsWin7AndPre2000Compatible() {