| ... | ... | @@ -2,10 +2,13 @@ const std = @import("std"); |
| 2 | 2 | const testing = std.testing; |
| 3 | 3 | const builtin = @import("builtin"); |
| 4 | 4 | const linkage: std.builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; |
| 5 | | pub const panic = @import("common.zig").panic; |
| 5 | const panic = @import("common.zig").panic; |
| 6 | |
| 7 | const have_availability_version_check = builtin.os.tag.isDarwin() and |
| 8 | builtin.os.version_range.semver.min.order(.{ .major = 10, .minor = 15, .patch = 0 }).compare(.gte); |
| 6 | 9 | |
| 7 | 10 | comptime { |
| 8 | | if (builtin.os.tag.isDarwin()) { |
| 11 | if (have_availability_version_check) { |
| 9 | 12 | @export(__isPlatformVersionAtLeast, .{ .name = "__isPlatformVersionAtLeast", .linkage = linkage }); |
| 10 | 13 | } |
| 11 | 14 | } |
| ... | ... | @@ -25,7 +28,7 @@ comptime { |
| 25 | 28 | // the newer codepath, which merely calls out to the Darwin _availability_version_check API which is |
| 26 | 29 | // available on macOS 10.15+, iOS 13+, tvOS 13+ and watchOS 6+. |
| 27 | 30 | |
| 28 | | const __isPlatformVersionAtLeast = if (builtin.os.tag.isDarwin()) struct { |
| 31 | const __isPlatformVersionAtLeast = if (have_availability_version_check) struct { |
| 29 | 32 | inline fn constructVersion(major: u32, minor: u32, subminor: u32) u32 { |
| 30 | 33 | return ((major & 0xffff) << 16) | ((minor & 0xff) << 8) | (subminor & 0xff); |
| 31 | 34 | } |
| ... | ... | @@ -50,7 +53,7 @@ const __isPlatformVersionAtLeast = if (builtin.os.tag.isDarwin()) struct { |
| 50 | 53 | }.__isPlatformVersionAtLeast else struct {}; |
| 51 | 54 | |
| 52 | 55 | test "isPlatformVersionAtLeast" { |
| 53 | | if (!comptime builtin.os.tag.isDarwin()) return error.SkipZigTest; |
| 56 | if (!have_availability_version_check) return error.SkipZigTest; |
| 54 | 57 | |
| 55 | 58 | // Note: this test depends on the actual host OS version since it is merely calling into the |
| 56 | 59 | // native Darwin API. |