authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-02-29 14:19:13+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-02-29 14:19:13+01:00
log58222204353c052a62f3723f879dc16f2d608f8b
treeef9b1c9b0789c1776361ded3110e73e20209c6af
parentf072b0c056768648eb56230036dc8c973116d066

Address review comments


1 files changed, 6 insertions(+), 7 deletions(-)

lib/std/zig/system.zig+6-7
...@@ -181,7 +181,6 @@ pub const NativeTargetInfo = struct {...@@ -181,7 +181,6 @@ pub const NativeTargetInfo = struct {
181 ProcessFdQuotaExceeded,181 ProcessFdQuotaExceeded,
182 SystemFdQuotaExceeded,182 SystemFdQuotaExceeded,
183 DeviceBusy,183 DeviceBusy,
184 Unexpected,
185 };184 };
186185
187 /// Given a `CrossTarget`, which specifies in detail which parts of the target should be detected186 /// Given a `CrossTarget`, which specifies in detail which parts of the target should be detected
...@@ -225,10 +224,9 @@ pub const NativeTargetInfo = struct {...@@ -225,10 +224,9 @@ pub const NativeTargetInfo = struct {
225 var version_info: std.os.windows.RTL_OSVERSIONINFOW = undefined;224 var version_info: std.os.windows.RTL_OSVERSIONINFOW = undefined;
226 version_info.dwOSVersionInfoSize = @sizeOf(@TypeOf(version_info));225 version_info.dwOSVersionInfoSize = @sizeOf(@TypeOf(version_info));
227226
228 const rc = std.os.windows.ntdll.RtlGetVersion(&version_info);227 switch (std.os.windows.ntdll.RtlGetVersion(&version_info)) {
229 switch (rc) {
230 .SUCCESS => {},228 .SUCCESS => {},
231 else => return std.os.windows.unexpectedStatus(rc),229 else => unreachable,
232 }230 }
233231
234 // Starting from the system infos build a NTDDI-like version232 // Starting from the system infos build a NTDDI-like version
...@@ -245,15 +243,16 @@ pub const NativeTargetInfo = struct {...@@ -245,15 +243,16 @@ pub const NativeTargetInfo = struct {
245 // There's no other way to obtain this info beside243 // There's no other way to obtain this info beside
246 // checking the build number against a known set of244 // checking the build number against a known set of
247 // values245 // values
248 for ([_]u32{246 const known_build_numbers = [_]u32{
249 10240, 10586, 14393, 15063, 16299, 17134, 17763,247 10240, 10586, 14393, 15063, 16299, 17134, 17763,
250 18362, 18363,248 18362, 18363,
251 }) |build, i| {249 };
250 for (known_build_numbers) |build, i| {
252 if (version_info.dwBuildNumber < build)251 if (version_info.dwBuildNumber < build)
253 break :subver @truncate(u8, i);252 break :subver @truncate(u8, i);
254 }253 }
255 // Unknown subversion, the OS is too new...254 // Unknown subversion, the OS is too new...
256 break :subver 0;255 break :subver @truncate(u8, known_build_numbers.len);
257 } else 0;256 } else 0;
258257
259 const version: u32 = @as(u32, os_ver) << 16 | @as(u32, sp_ver) << 8 | sub_ver;258 const version: u32 = @as(u32, os_ver) << 16 | @as(u32, sp_ver) << 8 | sub_ver;