authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-03-18 23:18:35-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-03-20 02:25:16+01:00
log3c8b96df6d146e6ae820f58ec993510d1eedf2c0
tree17a3c1e211b3f6384f4ceec0a60684cf588fd0b9
parent30de1678a624bb90a8664a10f8c15a81382f749e

windows: use enums for boolean types


9 files changed, 85 insertions(+), 92 deletions(-)

lib/std/Build/Watch.zig+2-2
......@@ -345,7 +345,7 @@ const Os = switch (builtin.os.tag) {
345345 .LAST_WRITE = true,
346346 .CREATION = true,
347347 },
348 windows.FALSE,
348 .FALSE,
349349 .Notify,
350350 )) {
351351 .SUCCESS, .PENDING => dir.state = .listening,
......@@ -632,7 +632,7 @@ const Os = switch (builtin.os.tag) {
632632 .none => std.math.minInt(windows.LARGE_INTEGER),
633633 .ms => |ms| -@as(windows.LARGE_INTEGER, ms) * (std.time.ns_per_ms / 100),
634634 };
635 _ = windows.ntdll.NtDelayExecution(windows.TRUE, &delay_interval);
635 _ = windows.ntdll.NtDelayExecution(.TRUE, &delay_interval);
636636 } else unreachable;
637637 }
638638 },
lib/std/Io/Threaded.zig+35-37
......@@ -1572,7 +1572,7 @@ const AlertableSyscall = struct {
15721572
15731573pub fn waitForApcOrAlert() void {
15741574 const infinite_timeout: windows.LARGE_INTEGER = std.math.minInt(windows.LARGE_INTEGER);
1575 _ = windows.ntdll.NtDelayExecution(windows.TRUE, &infinite_timeout);
1575 _ = windows.ntdll.NtDelayExecution(.TRUE, &infinite_timeout);
15761576}
15771577
15781578pub const max_iovecs_len = 8;
......@@ -2735,7 +2735,7 @@ fn batchAwaitConcurrent(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout
27352735 break :interval timeoutToWindowsInterval(.{ .deadline = d }).?;
27362736 };
27372737 const alertable_syscall = try AlertableSyscall.start();
2738 const delay_rc = windows.ntdll.NtDelayExecution(windows.TRUE, &delay_interval);
2738 const delay_rc = windows.ntdll.NtDelayExecution(.TRUE, &delay_interval);
27392739 alertable_syscall.finish();
27402740 switch (delay_rc) {
27412741 .SUCCESS, .TIMEOUT => {
......@@ -4533,8 +4533,8 @@ fn dirCreateFileWindows(
45334533 &windows_lock_range_off,
45344534 &windows_lock_range_len,
45354535 null,
4536 @intFromBool(flags.lock_nonblocking),
4537 @intFromBool(exclusive),
4536 .fromBool(flags.lock_nonblocking),
4537 .fromBool(exclusive),
45384538 )) {
45394539 .SUCCESS => {
45404540 syscall.finish();
......@@ -5129,8 +5129,8 @@ pub fn dirOpenFileWtf16(
51295129 &windows_lock_range_off,
51305130 &windows_lock_range_len,
51315131 null,
5132 @intFromBool(flags.lock_nonblocking),
5133 @intFromBool(exclusive),
5132 .fromBool(flags.lock_nonblocking),
5133 .fromBool(exclusive),
51345134 )) {
51355135 .SUCCESS => break syscall.finish(),
51365136 .INSUFFICIENT_RESOURCES => return syscall.fail(error.SystemResources),
......@@ -5886,9 +5886,9 @@ fn dirReadWindows(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) D
58865886 unreserved_buffer.ptr,
58875887 std.math.lossyCast(w.ULONG, unreserved_buffer.len),
58885888 .BothDirectory,
5889 w.FALSE,
5889 .FALSE,
58905890 null,
5891 @intFromBool(dr.state == .reset),
5891 .fromBool(dr.state == .reset),
58925892 )) {
58935893 .CANCELLED => {
58945894 try syscall.checkCancel();
......@@ -7229,9 +7229,7 @@ fn dirDeleteWindows(userdata: ?*anyopaque, dir: Dir, sub_path: []const u8, remov
72297229
72307230 // Deletion with file pending semantics, which requires waiting or moving
72317231 // files to get them removed (from here).
7232 var file_dispo: w.FILE.DISPOSITION.INFORMATION = .{
7233 .DeleteFile = w.TRUE,
7234 };
7232 var file_dispo: w.FILE.DISPOSITION.INFORMATION = .{ .DeleteFile = .TRUE };
72357233
72367234 while (true) switch (w.ntdll.NtSetInformationFile(
72377235 tmp_handle,
......@@ -9188,8 +9186,8 @@ fn fileLock(userdata: ?*anyopaque, file: File, lock: File.Lock) File.LockError!v
91889186 &windows_lock_range_off,
91899187 &windows_lock_range_len,
91909188 null,
9191 windows.FALSE,
9192 @intFromBool(exclusive),
9189 .FALSE,
9190 .fromBool(exclusive),
91939191 )) {
91949192 .SUCCESS => return syscall.finish(),
91959193 .CANCELLED => {
......@@ -9269,8 +9267,8 @@ fn fileTryLock(userdata: ?*anyopaque, file: File, lock: File.Lock) File.LockErro
92699267 &windows_lock_range_off,
92709268 &windows_lock_range_len,
92719269 null,
9272 windows.TRUE,
9273 @intFromBool(exclusive),
9270 .TRUE,
9271 .fromBool(exclusive),
92749272 )) {
92759273 .SUCCESS => {
92769274 syscall.finish();
......@@ -9382,8 +9380,8 @@ fn fileDowngradeLock(userdata: ?*anyopaque, file: File) File.DowngradeLockError!
93829380 &windows_lock_range_off,
93839381 &windows_lock_range_len,
93849382 null,
9385 windows.TRUE,
9386 windows.FALSE,
9383 .TRUE,
9384 .FALSE,
93879385 )) {
93889386 .SUCCESS => break syscall.finish(),
93899387 .CANCELLED => {
......@@ -11469,7 +11467,7 @@ fn clockResolution(userdata: ?*anyopaque, clock: Io.Clock) Io.Clock.ResolutionEr
1146911467 // https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddk/ns-ntddk-kuser_shared_data
1147011468 // https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/ntexapi_x/kuser_shared_data/index.htm
1147111469 var qpf: windows.LARGE_INTEGER = undefined;
11472 if (windows.ntdll.RtlQueryPerformanceFrequency(&qpf) != 0) {
11470 if (windows.ntdll.RtlQueryPerformanceFrequency(&qpf).toBool()) {
1147311471 recoverableOsBugDetected();
1147411472 return .zero;
1147511473 }
......@@ -11523,14 +11521,14 @@ fn nowWindows(clock: Io.Clock) Io.Timestamp {
1152311521 // https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/ntexapi_x/kuser_shared_data/index.htm
1152411522 const qpf: u64 = qpf: {
1152511523 var qpf: windows.LARGE_INTEGER = undefined;
11526 assert(windows.ntdll.RtlQueryPerformanceFrequency(&qpf) != windows.FALSE);
11524 assert(windows.ntdll.RtlQueryPerformanceFrequency(&qpf).toBool());
1152711525 break :qpf @bitCast(qpf);
1152811526 };
1152911527
1153011528 // QPC on windows doesn't fail on >= XP/2000 and includes time suspended.
1153111529 const qpc: u64 = qpc: {
1153211530 var qpc: windows.LARGE_INTEGER = undefined;
11533 assert(windows.ntdll.RtlQueryPerformanceCounter(&qpc) != windows.FALSE);
11531 assert(windows.ntdll.RtlQueryPerformanceCounter(&qpc).toBool());
1153411532 break :qpc @bitCast(qpc);
1153511533 };
1153611534
......@@ -11745,9 +11743,9 @@ fn netListenIpWindows(
1174511743 .file = .{ .handle = socket_handle, .flags = .{ .nonblocking = true } },
1174611744 .code = windows.IOCTL.AFD.START_LISTEN,
1174711745 .in = @ptrCast(&windows.AFD.LISTEN_INFO{
11748 .UseSAN = windows.FALSE,
11746 .UseSAN = .FALSE,
1174911747 .MaximumConnectionQueue = options.kernel_backlog,
11750 .UseDelayedAcceptance = windows.FALSE,
11748 .UseDelayedAcceptance = .FALSE,
1175111749 }),
1175211750 })).u.Status) {
1175311751 .SUCCESS => {},
......@@ -11830,9 +11828,9 @@ fn netListenUnixWindows(
1183011828 .file = .{ .handle = socket_handle, .flags = .{ .nonblocking = true } },
1183111829 .code = windows.IOCTL.AFD.START_LISTEN,
1183211830 .in = @ptrCast(&windows.AFD.LISTEN_INFO{
11833 .UseSAN = windows.FALSE,
11831 .UseSAN = .FALSE,
1183411832 .MaximumConnectionQueue = options.kernel_backlog,
11835 .UseDelayedAcceptance = windows.FALSE,
11833 .UseDelayedAcceptance = .FALSE,
1183611834 }),
1183711835 })).u.Status) {
1183811836 .SUCCESS => {},
......@@ -12529,7 +12527,7 @@ fn netAcceptWindows(userdata: ?*anyopaque, listen_handle: net.Socket.Handle, opt
1252912527 .file = .{ .handle = listen_handle, .flags = .{ .nonblocking = true } },
1253012528 .code = windows.IOCTL.AFD.ACCEPT,
1253112529 .in = @ptrCast(&windows.AFD.ACCEPT_INFO{
12532 .UseSAN = windows.FALSE,
12530 .UseSAN = .FALSE,
1253312531 .Sequence = storage.Info.Sequence,
1253412532 .AcceptHandle = accept_handle,
1253512533 }),
......@@ -12550,7 +12548,7 @@ fn deferAcceptAfd(t: *Threaded, listen_handle: net.Socket.Handle, info: windows.
1255012548 .code = windows.IOCTL.AFD.DEFER_ACCEPT,
1255112549 .in = @ptrCast(&windows.AFD.DEFER_ACCEPT_INFO{
1255212550 .Sequence = info.Sequence,
12553 .Reject = windows.FALSE,
12551 .Reject = .FALSE,
1255412552 }),
1255512553 }) catch |err| switch (err) {
1255612554 error.Canceled => unreachable, // blocked
......@@ -15098,7 +15096,7 @@ fn childKillWindows(t: *Threaded, child: *process.Child, exit_code: windows.UINT
1509815096 switch (windows.ntdll.NtTerminateProcess(handle, @enumFromInt(exit_code))) {
1509915097 .SUCCESS, .PROCESS_IS_TERMINATING => {
1510015098 const infinite_timeout: windows.LARGE_INTEGER = std.math.minInt(windows.LARGE_INTEGER);
15101 _ = windows.ntdll.NtWaitForSingleObject(handle, windows.FALSE, &infinite_timeout);
15099 _ = windows.ntdll.NtWaitForSingleObject(handle, .FALSE, &infinite_timeout);
1510215100 childCleanupWindows(child);
1510315101 },
1510415102 .ACCESS_DENIED => {
......@@ -15108,7 +15106,7 @@ fn childKillWindows(t: *Threaded, child: *process.Child, exit_code: windows.UINT
1510815106 // PROCESS_TERMINATE access right, so let's do another check to make
1510915107 // sure the process is really no longer running:
1511015108 const minimal_timeout: windows.LARGE_INTEGER = -1;
15111 return switch (windows.ntdll.NtWaitForSingleObject(handle, windows.FALSE, &minimal_timeout)) {
15109 return switch (windows.ntdll.NtWaitForSingleObject(handle, .FALSE, &minimal_timeout)) {
1511215110 windows.NTSTATUS.WAIT_0 => error.AlreadyTerminated,
1511315111 else => error.AccessDenied,
1511415112 };
......@@ -15122,7 +15120,7 @@ fn childWaitWindows(child: *process.Child) process.Child.WaitError!process.Child
1512215120
1512315121 const alertable_syscall: AlertableSyscall = try .start();
1512415122 const infinite_timeout: windows.LARGE_INTEGER = std.math.minInt(windows.LARGE_INTEGER);
15125 while (true) switch (windows.ntdll.NtWaitForSingleObject(handle, windows.TRUE, &infinite_timeout)) {
15123 while (true) switch (windows.ntdll.NtWaitForSingleObject(handle, .TRUE, &infinite_timeout)) {
1512615124 windows.NTSTATUS.WAIT_0 => break alertable_syscall.finish(),
1512715125 .USER_APC, .ALERTED, .TIMEOUT => {
1512815126 try alertable_syscall.checkCancel();
......@@ -15458,7 +15456,7 @@ fn processSpawnWindows(userdata: ?*anyopaque, options: process.SpawnOptions) pro
1545815456 .sa = &.{
1545915457 .nLength = @sizeOf(windows.SECURITY_ATTRIBUTES),
1546015458 .lpSecurityDescriptor = null,
15461 .bInheritHandle = windows.TRUE,
15459 .bInheritHandle = .TRUE,
1546215460 },
1546315461 .creation = .OPEN,
1546415462 }),
......@@ -15477,7 +15475,7 @@ fn processSpawnWindows(userdata: ?*anyopaque, options: process.SpawnOptions) pro
1547715475 .sa = &.{
1547815476 .nLength = @sizeOf(windows.SECURITY_ATTRIBUTES),
1547915477 .lpSecurityDescriptor = null,
15480 .bInheritHandle = windows.TRUE,
15478 .bInheritHandle = .TRUE,
1548115479 },
1548215480 .creation = .OPEN,
1548315481 }),
......@@ -15496,7 +15494,7 @@ fn processSpawnWindows(userdata: ?*anyopaque, options: process.SpawnOptions) pro
1549615494 .sa = &.{
1549715495 .nLength = @sizeOf(windows.SECURITY_ATTRIBUTES),
1549815496 .lpSecurityDescriptor = null,
15499 .bInheritHandle = windows.TRUE,
15497 .bInheritHandle = .TRUE,
1550015498 },
1550115499 .creation = .OPEN,
1550215500 }),
......@@ -16021,9 +16019,9 @@ fn windowsCreateProcessPathExt(
1602116019 &file_information_buf,
1602216020 file_information_buf.len,
1602316021 .Directory,
16024 windows.FALSE, // single result
16022 .FALSE, // single result
1602516023 &.init(app_name_wildcard),
16026 windows.FALSE, // restart iteration
16024 .FALSE, // restart iteration
1602716025 )) {
1602816026 .SUCCESS => {},
1602916027 .NO_SUCH_FILE => return error.FileNotFound,
......@@ -16184,13 +16182,13 @@ fn windowsCreateProcess(
1618416182 cmd_line,
1618516183 null,
1618616184 null,
16187 windows.TRUE,
16185 .TRUE,
1618816186 flags,
1618916187 if (env_block) |block| block.slice.ptr else null,
1619016188 cwd_ptr,
1619116189 lpStartupInfo,
1619216190 lpProcessInformation,
16193 ) != 0) {
16191 ).toBool()) {
1619416192 return syscall.finish();
1619516193 } else switch (windows.GetLastError()) {
1619616194 .INVALID_PARAMETER => unreachable,
......@@ -18742,7 +18740,7 @@ fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!windows
1874218740
1874318741 const attr: windows.OBJECT.ATTRIBUTES = .{
1874418742 .RootDirectory = if (Dir.path.isAbsoluteWindowsWtf16(sub_path_w)) null else options.dir,
18745 .Attributes = .{ .INHERIT = if (options.sa) |sa| sa.bInheritHandle != windows.FALSE else false },
18743 .Attributes = .{ .INHERIT = if (options.sa) |sa| sa.bInheritHandle.toBool() else false },
1874618744 .ObjectName = @constCast(&windows.UNICODE_STRING.init(sub_path_w)),
1874718745 .SecurityDescriptor = if (options.sa) |ptr| ptr.lpSecurityDescriptor else null,
1874818746 };
lib/std/Io/Threaded/test.zig+1-2
......@@ -285,8 +285,7 @@ test "memory mapping fallback" {
285285/// because it allocates.
286286fn RtlDosPathNameToNtPathName_U(path: [:0]const u16) !Io.Threaded.WindowsPathSpace {
287287 var out: windows.UNICODE_STRING = undefined;
288 const rc = windows.ntdll.RtlDosPathNameToNtPathName_U(path, &out, null, null);
289 if (rc != windows.TRUE) return error.BadPathName;
288 if (!windows.ntdll.RtlDosPathNameToNtPathName_U(path, &out, null, null).toBool()) return error.BadPathName;
290289 defer windows.ntdll.RtlFreeUnicodeString(&out);
291290
292291 var path_space: Io.Threaded.WindowsPathSpace = undefined;
lib/std/Thread.zig+1-1
......@@ -646,7 +646,7 @@ const WindowsThreadImpl = struct {
646646
647647 fn join(self: Impl) void {
648648 const infinite_timeout: windows.LARGE_INTEGER = std.math.minInt(windows.LARGE_INTEGER);
649 switch (windows.ntdll.NtWaitForSingleObject(self.thread.thread_handle, windows.FALSE, &infinite_timeout)) {
649 switch (windows.ntdll.NtWaitForSingleObject(self.thread.thread_handle, .FALSE, &infinite_timeout)) {
650650 windows.NTSTATUS.WAIT_0 => {},
651651 else => |status| windows.unexpectedStatus(status) catch unreachable,
652652 }
lib/std/os/windows.zig+32-13
......@@ -895,9 +895,9 @@ pub const CONSOLE = struct {
895895 /// input
896896 Mode: MODE,
897897
898 pub const MODE = enum(BOOLEAN) {
899 Input = FALSE,
900 Output = TRUE,
898 pub const MODE = enum(BOOLEAN.Backing) {
899 Input,
900 Output,
901901 };
902902 };
903903
......@@ -907,9 +907,9 @@ pub const CONSOLE = struct {
907907 /// input
908908 Mode: MODE,
909909
910 pub const MODE = enum(BOOLEAN) {
911 Character = FALSE,
912 WideCharacter = TRUE,
910 pub const MODE = enum(BOOLEAN.Backing) {
911 Character,
912 WideCharacter,
913913 };
914914 };
915915
......@@ -1930,7 +1930,7 @@ pub const DNS = struct {
19301930
19311931 pub const @"3" = extern struct {
19321932 Base: REQUEST,
1933 IsNetworkQueryRequired: BOOL = FALSE,
1933 IsNetworkQueryRequired: BOOL = .FALSE,
19341934 RequiredNetworkIndex: DWORD = 0,
19351935 cCustomServers: DWORD = 0,
19361936 pCustomServers: ?*CUSTOM_SERVER = null,
......@@ -4018,7 +4018,7 @@ pub fn eqlIgnoreCaseWtf16(a: []const u16, b: []const u16) bool {
40184018 }
40194019 // Use RtlEqualUnicodeString on Windows when not in comptime to avoid including a
40204020 // redundant copy of the uppercase data.
4021 return ntdll.RtlEqualUnicodeString(&.init(a), &.init(b), TRUE) == TRUE;
4021 return ntdll.RtlEqualUnicodeString(&.init(a), &.init(b), .TRUE).toBool();
40224022}
40234023
40244024/// Compares two WTF-8 strings using the equivalent functionality of
......@@ -4270,8 +4270,8 @@ pub const Win32Error = @import("windows/win32error.zig").Win32Error;
42704270pub const LANG = @import("windows/lang.zig");
42714271pub const SUBLANG = @import("windows/sublang.zig");
42724272
4273pub const BOOL = c_int;
4274pub const BOOLEAN = BYTE;
4273pub const BOOL = Bool(c_int);
4274pub const BOOLEAN = Bool(BYTE);
42754275pub const BYTE = u8;
42764276pub const CHAR = u8;
42774277pub const UCHAR = u8;
......@@ -4376,8 +4376,27 @@ fn STRING(comptime C: type) type {
43764376pub const ANSI_STRING = STRING(CHAR);
43774377pub const UNICODE_STRING = STRING(WCHAR);
43784378
4379pub const TRUE = 1;
4380pub const FALSE = 0;
4379fn Bool(comptime BackingInteger: type) type {
4380 return enum(Backing) {
4381 /// false
4382 FALSE = 0,
4383 /// true
4384 _,
4385
4386 /// This is not the only truthy value, comparisons against this value are always a bug.
4387 pub const TRUE: @This() = @enumFromInt(1);
4388
4389 pub const Backing = BackingInteger;
4390
4391 pub fn toBool(b: @This()) bool {
4392 return b != .FALSE;
4393 }
4394
4395 pub fn fromBool(b: bool) @This() {
4396 return @enumFromInt(@intFromBool(b));
4397 }
4398 };
4399}
43814400
43824401pub const INVALID_HANDLE_VALUE: HANDLE = @ptrFromInt(maxInt(usize));
43834402
......@@ -6087,7 +6106,7 @@ pub const SharedUserData: *const KUSER_SHARED_DATA = @ptrFromInt(0x7FFE0000);
60876106
60886107pub fn IsProcessorFeaturePresent(feature: PF) bool {
60896108 if (@intFromEnum(feature) >= PROCESSOR_FEATURE_MAX) return false;
6090 return SharedUserData.ProcessorFeatures[@intFromEnum(feature)] == 1;
6109 return SharedUserData.ProcessorFeatures[@intFromEnum(feature)].toBool();
60916110}
60926111
60936112// https://github.com/reactos/reactos/blob/master/sdk/include/ndk/pstypes.h#L977-L983
lib/std/process.zig+1-1
......@@ -800,7 +800,7 @@ pub fn abort() noreturn {
800800 // even when linking libc on Windows we use our own abort implementation.
801801 // See https://github.com/ziglang/zig/issues/2071 for more details.
802802 if (native_os == .windows) {
803 if (builtin.mode == .Debug and windows.peb().BeingDebugged != 0) {
803 if (builtin.mode == .Debug and windows.peb().BeingDebugged.toBool()) {
804804 @breakpoint();
805805 }
806806 windows.ntdll.RtlExitUserProcess(3);
lib/std/start.zig+1-1
......@@ -84,7 +84,7 @@ fn _DllMainCRTStartup(
8484 return root.DllMain(hinstDLL, fdwReason, lpReserved);
8585 }
8686
87 return std.os.windows.TRUE;
87 return .TRUE;
8888}
8989
9090fn wasm_freestanding_start() callconv(.c) void {
test/standalone/windows_argv/fuzz.zig+4-6
......@@ -129,20 +129,18 @@ fn spawnVerify(verify_path: [:0]const u16, cmd_line: [:0]const u16) !windows.DWO
129129 };
130130 var proc_info: windows.PROCESS.INFORMATION = undefined;
131131
132 if (windows.kernel32.CreateProcessW(
132 if (!windows.kernel32.CreateProcessW(
133133 @constCast(verify_path.ptr),
134134 @constCast(cmd_line.ptr),
135135 null,
136136 null,
137 windows.TRUE,
137 .TRUE,
138138 .{},
139139 null,
140140 null,
141141 &startup_info,
142142 &proc_info,
143 ) == 0) {
144 std.process.fatal("kernel32 CreateProcessW failed with {t}", .{windows.GetLastError()});
145 }
143 ).toBool()) std.process.fatal("kernel32 CreateProcessW failed with {t}", .{windows.GetLastError()});
146144
147145 windows.CloseHandle(proc_info.hThread);
148146
......@@ -150,7 +148,7 @@ fn spawnVerify(verify_path: [:0]const u16, cmd_line: [:0]const u16) !windows.DWO
150148 };
151149 defer windows.CloseHandle(child_proc);
152150 const infinite_timeout: windows.LARGE_INTEGER = std.math.minInt(windows.LARGE_INTEGER);
153 switch (windows.ntdll.NtWaitForSingleObject(child_proc, windows.FALSE, &infinite_timeout)) {
151 switch (windows.ntdll.NtWaitForSingleObject(child_proc, .FALSE, &infinite_timeout)) {
154152 windows.NTSTATUS.WAIT_0 => {},
155153 .TIMEOUT => return error.WaitTimeOut,
156154 else => |status| return windows.unexpectedStatus(status),
test/standalone/windows_spawn/main.zig+8-29
......@@ -29,16 +29,10 @@ pub fn main(init: std.process.Init) !void {
2929 defer gpa.free(tmp_relative_path);
3030
3131 // Clear PATH
32 std.debug.assert(SetEnvironmentVariableW(
33 utf16Literal("PATH"),
34 null,
35 ) == windows.TRUE);
32 std.debug.assert(SetEnvironmentVariableW(utf16Literal("PATH"), null).toBool());
3633
3734 // Set PATHEXT to something predictable
38 std.debug.assert(SetEnvironmentVariableW(
39 utf16Literal("PATHEXT"),
40 utf16Literal(".COM;.EXE;.BAT;.CMD;.JS"),
41 ) == windows.TRUE);
35 std.debug.assert(SetEnvironmentVariableW(utf16Literal("PATHEXT"), utf16Literal(".COM;.EXE;.BAT;.CMD;.JS")).toBool());
4236
4337 // No PATH, so it should fail to find anything not in the cwd
4438 try testExecError(error.FileNotFound, gpa, io, "something_missing");
......@@ -46,10 +40,7 @@ pub fn main(init: std.process.Init) !void {
4640 // make sure we don't get error.BadPath traversing out of cwd with a relative path
4741 try testExecError(error.FileNotFound, gpa, io, "..\\.\\.\\.\\\\..\\more_missing");
4842
49 std.debug.assert(SetEnvironmentVariableW(
50 utf16Literal("PATH"),
51 tmp_absolute_path_w,
52 ) == windows.TRUE);
43 std.debug.assert(SetEnvironmentVariableW(utf16Literal("PATH"), tmp_absolute_path_w).toBool());
5344
5445 // Move hello.exe into the tmp dir which is now added to the path
5546 try Io.Dir.cwd().copyFile(hello_exe_cache_path, tmp_dir, "hello.exe", io, .{});
......@@ -129,10 +120,7 @@ pub fn main(init: std.process.Init) !void {
129120 const something_subdir_abs_path = try std.mem.concatWithSentinel(gpa, u16, &.{ tmp_absolute_path_w, utf16Literal("\\something") }, 0);
130121 defer gpa.free(something_subdir_abs_path);
131122
132 std.debug.assert(SetEnvironmentVariableW(
133 utf16Literal("PATH"),
134 something_subdir_abs_path,
135 ) == windows.TRUE);
123 std.debug.assert(SetEnvironmentVariableW(utf16Literal("PATH"), something_subdir_abs_path).toBool());
136124
137125 // Now trying to execute goodbye should give error.InvalidExe since it's the original
138126 // error that we got when trying within the cwd
......@@ -169,18 +157,12 @@ pub fn main(init: std.process.Init) !void {
169157 defer gpa.free(denormed_something_subdir_wtf8);
170158
171159 // clear the path to ensure that the match comes from the cwd
172 std.debug.assert(SetEnvironmentVariableW(
173 utf16Literal("PATH"),
174 null,
175 ) == windows.TRUE);
160 std.debug.assert(SetEnvironmentVariableW(utf16Literal("PATH"), null).toBool());
176161
177162 try testExecWithCwd(gpa, io, "goodbye", denormed_something_subdir_wtf8, "hello from exe\n");
178163
179164 // normalization should also work if the non-normalized path is found in the PATH var.
180 std.debug.assert(SetEnvironmentVariableW(
181 utf16Literal("PATH"),
182 denormed_something_subdir_abs_path,
183 ) == windows.TRUE);
165 std.debug.assert(SetEnvironmentVariableW(utf16Literal("PATH"), denormed_something_subdir_abs_path).toBool());
184166 try testExec(gpa, io, "goodbye", "hello from exe\n");
185167
186168 // now make sure we can launch executables "outside" of the cwd
......@@ -191,10 +173,7 @@ pub fn main(init: std.process.Init) !void {
191173 try std.process.setCurrentDir(io, subdir_cwd);
192174
193175 // clear the PATH again
194 std.debug.assert(SetEnvironmentVariableW(
195 utf16Literal("PATH"),
196 null,
197 ) == windows.TRUE);
176 std.debug.assert(SetEnvironmentVariableW(utf16Literal("PATH"), null).toBool());
198177
199178 // while we're at it make sure non-windows separators work fine
200179 try testExec(gpa, io, "../hello", "hello from exe\n");
......@@ -237,7 +216,7 @@ fn renameExe(dir: Io.Dir, io: Io, old_sub_path: []const u8, new_sub_path: []cons
237216 if (attempt == 26) return error.AccessDenied;
238217 // give the kernel a chance to finish closing the executable handle
239218 const interval = @as(std.os.windows.LARGE_INTEGER, -1) << attempt;
240 _ = std.os.windows.ntdll.NtDelayExecution(std.os.windows.FALSE, &interval);
219 _ = std.os.windows.ntdll.NtDelayExecution(.FALSE, &interval);
241220 attempt += 1;
242221 continue;
243222 },