aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRohlem <rohlemF@gmail.com>2020-12-17 15:55:05 +0100
committerAndrew Kelley <andrew@ziglang.org>2021-01-11 17:48:17 -0700
commit4b280ac7e9730a30cb3a03350711a13cf45c5dfc (patch)
tree1ebea2209836695a8240ff595a9e8eaf66189b5b /lib
parent2922a483099a0a45d4cbaf2bc7c3b43fcebe4e77 (diff)
downloadzig-4b280ac7e9730a30cb3a03350711a13cf45c5dfc.tar.gz
zig-4b280ac7e9730a30cb3a03350711a13cf45c5dfc.zip
add std.zig.system.windows version check utility functions
Diffstat (limited to 'lib')
-rw-r--r--lib/std/zig/system/windows.zig16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/std/zig/system/windows.zig b/lib/std/zig/system/windows.zig
index d32b28f607..d352703e40 100644
--- a/lib/std/zig/system/windows.zig
+++ b/lib/std/zig/system/windows.zig
@@ -43,3 +43,19 @@ pub fn detectRuntimeVersion() WindowsVersion {
return @intToEnum(WindowsVersion, version);
}
+
+/// Returns whether the target os versions are uniformly at least as new as the argument:
+/// true/false if this holds for the entire target range, null if it only holds for some.
+pub fn targetVersionIsAtLeast(requested_version: WindowsVersion) ?bool {
+ const requested = @enumToInt(requested_version);
+ const version_range = std.builtin.os.version_range.windows;
+ const target_min = @enumToInt(version_range.min);
+ const target_max = @enumToInt(version_range.max);
+ return if (target_max < requested) false else if (target_min >= requested) true else null;
+}
+
+/// Returns whether the runtime os version is at least as new as the argument.
+pub fn runtimeVersionIsAtLeast(requested_version: WindowsVersion) bool {
+ return targetVersionIsAtLeast(requested_version) orelse
+ (@enumToInt(detectRuntimeVersion()) >= @enumToInt(requested_version));
+}