authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-01-28 01:04:38+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-02-01 15:22:36+02:00
loga4f27e8987ef3e2388839b6452b9f485ab82e7b7
tree6420c218896c0f44dea7353b8a9c00b01461c2ec
parentb0bea72588c685c1d6439f61d2e842756b5fc496

remove std.io.Mode


25 files changed, 119 insertions(+), 579 deletions(-)

lib/std/Build/Step/Compile.zig-5
......@@ -55,7 +55,6 @@ global_base: ?u64 = null,
5555zig_lib_dir: ?LazyPath,
5656exec_cmd_args: ?[]const ?[]const u8,
5757filter: ?[]const u8,
58test_evented_io: bool = false,
5958test_runner: ?[]const u8,
6059test_server_mode: bool,
6160wasi_exec_model: ?std.builtin.WasiExecModel = null,
......@@ -1294,10 +1293,6 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void {
12941293 try zig_args.append(filter);
12951294 }
12961295
1297 if (self.test_evented_io) {
1298 try zig_args.append("--test-evented-io");
1299 }
1300
13011296 if (self.test_runner) |test_runner| {
13021297 try zig_args.append("--test-runner");
13031298 try zig_args.append(b.pathFromRoot(test_runner));
lib/std/Build/Step/Run.zig+2-10
......@@ -1147,19 +1147,14 @@ fn evalZigTest(
11471147 test_count = tm_hdr.tests_len;
11481148
11491149 const names_bytes = body[@sizeOf(TmHdr)..][0 .. test_count * @sizeOf(u32)];
1150 const async_frame_lens_bytes = body[@sizeOf(TmHdr) + names_bytes.len ..][0 .. test_count * @sizeOf(u32)];
1151 const expected_panic_msgs_bytes = body[@sizeOf(TmHdr) + names_bytes.len + async_frame_lens_bytes.len ..][0 .. test_count * @sizeOf(u32)];
1152 const string_bytes = body[@sizeOf(TmHdr) + names_bytes.len + async_frame_lens_bytes.len + expected_panic_msgs_bytes.len ..][0..tm_hdr.string_bytes_len];
1150 const expected_panic_msgs_bytes = body[@sizeOf(TmHdr) + names_bytes.len ..][0 .. test_count * @sizeOf(u32)];
1151 const string_bytes = body[@sizeOf(TmHdr) + names_bytes.len + expected_panic_msgs_bytes.len ..][0..tm_hdr.string_bytes_len];
11531152
11541153 const names = std.mem.bytesAsSlice(u32, names_bytes);
1155 const async_frame_lens = std.mem.bytesAsSlice(u32, async_frame_lens_bytes);
11561154 const expected_panic_msgs = std.mem.bytesAsSlice(u32, expected_panic_msgs_bytes);
11571155 const names_aligned = try arena.alloc(u32, names.len);
11581156 for (names_aligned, names) |*dest, src| dest.* = src;
11591157
1160 const async_frame_lens_aligned = try arena.alloc(u32, async_frame_lens.len);
1161 for (async_frame_lens_aligned, async_frame_lens) |*dest, src| dest.* = src;
1162
11631158 const expected_panic_msgs_aligned = try arena.alloc(u32, expected_panic_msgs.len);
11641159 for (expected_panic_msgs_aligned, expected_panic_msgs) |*dest, src| dest.* = src;
11651160
......@@ -1167,7 +1162,6 @@ fn evalZigTest(
11671162 metadata = .{
11681163 .string_bytes = try arena.dupe(u8, string_bytes),
11691164 .names = names_aligned,
1170 .async_frame_lens = async_frame_lens_aligned,
11711165 .expected_panic_msgs = expected_panic_msgs_aligned,
11721166 .next_index = 0,
11731167 .prog_node = prog_node,
......@@ -1237,7 +1231,6 @@ fn evalZigTest(
12371231
12381232const TestMetadata = struct {
12391233 names: []const u32,
1240 async_frame_lens: []const u32,
12411234 expected_panic_msgs: []const u32,
12421235 string_bytes: []const u8,
12431236 next_index: u32,
......@@ -1253,7 +1246,6 @@ fn requestNextTest(in: fs.File, metadata: *TestMetadata, sub_prog_node: *?std.Pr
12531246 const i = metadata.next_index;
12541247 metadata.next_index += 1;
12551248
1256 if (metadata.async_frame_lens[i] != 0) continue;
12571249 if (metadata.expected_panic_msgs[i] != 0) continue;
12581250
12591251 const name = metadata.testName(i);
lib/std/builtin.zig-1
......@@ -732,7 +732,6 @@ pub const CompilerBackend = enum(u64) {
732732pub const TestFn = struct {
733733 name: []const u8,
734734 func: *const fn () anyerror!void,
735 async_frame_size: ?usize,
736735};
737736
738737/// This function type is used by the Zig language code generation and
lib/std/child_process.zig+3-12
......@@ -493,7 +493,7 @@ pub const ChildProcess = struct {
493493 }
494494
495495 fn spawnPosix(self: *ChildProcess) SpawnError!void {
496 const pipe_flags = if (io.is_async) os.O.NONBLOCK else 0;
496 const pipe_flags = 0;
497497 const stdin_pipe = if (self.stdin_behavior == StdIo.Pipe) try os.pipe2(pipe_flags) else undefined;
498498 errdefer if (self.stdin_behavior == StdIo.Pipe) {
499499 destroyPipe(stdin_pipe);
......@@ -665,7 +665,6 @@ pub const ChildProcess = struct {
665665 .share_access = windows.FILE_SHARE_READ | windows.FILE_SHARE_WRITE,
666666 .sa = &saAttr,
667667 .creation = windows.OPEN_EXISTING,
668 .io_mode = .blocking,
669668 }) catch |err| switch (err) {
670669 error.PathAlreadyExists => unreachable, // not possible for "NUL"
671670 error.PipeBusy => unreachable, // not possible for "NUL"
......@@ -1491,20 +1490,12 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn {
14911490const ErrInt = std.meta.Int(.unsigned, @sizeOf(anyerror) * 8);
14921491
14931492fn writeIntFd(fd: i32, value: ErrInt) !void {
1494 const file = File{
1495 .handle = fd,
1496 .capable_io_mode = .blocking,
1497 .intended_io_mode = .blocking,
1498 };
1493 const file = File{ .handle = fd };
14991494 file.writer().writeInt(u64, @intCast(value), .little) catch return error.SystemResources;
15001495}
15011496
15021497fn readIntFd(fd: i32) !ErrInt {
1503 const file = File{
1504 .handle = fd,
1505 .capable_io_mode = .blocking,
1506 .intended_io_mode = .blocking,
1507 };
1498 const file = File{ .handle = fd };
15081499 return @as(ErrInt, @intCast(file.reader().readInt(u64, .little) catch return error.SystemResources));
15091500}
15101501
lib/std/debug.zig+5-8
......@@ -1141,8 +1141,8 @@ pub fn readElfDebugInfo(
11411141) !ModuleDebugInfo {
11421142 nosuspend {
11431143 const elf_file = (if (elf_filename) |filename| blk: {
1144 break :blk fs.cwd().openFile(filename, .{ .intended_io_mode = .blocking });
1145 } else fs.openSelfExe(.{ .intended_io_mode = .blocking })) catch |err| switch (err) {
1144 break :blk fs.cwd().openFile(filename, .{});
1145 } else fs.openSelfExe(.{})) catch |err| switch (err) {
11461146 error.FileNotFound => return error.MissingDebugInfo,
11471147 else => return err,
11481148 };
......@@ -1452,7 +1452,7 @@ fn readMachODebugInfo(allocator: mem.Allocator, macho_file: File) !ModuleDebugIn
14521452fn printLineFromFileAnyOs(out_stream: anytype, line_info: LineInfo) !void {
14531453 // Need this to always block even in async I/O mode, because this could potentially
14541454 // be called from e.g. the event loop code crashing.
1455 var f = try fs.cwd().openFile(line_info.file_name, .{ .intended_io_mode = .blocking });
1455 var f = try fs.cwd().openFile(line_info.file_name, .{});
14561456 defer f.close();
14571457 // TODO fstat and make sure that the file has the correct size
14581458
......@@ -1640,7 +1640,6 @@ const MachoSymbol = struct {
16401640 }
16411641};
16421642
1643/// `file` is expected to have been opened with .intended_io_mode == .blocking.
16441643/// Takes ownership of file, even on error.
16451644/// TODO it's weird to take ownership even on error, rework this code.
16461645fn mapWholeFile(file: File) ![]align(mem.page_size) const u8 {
......@@ -1824,9 +1823,7 @@ pub const DebugInfo = struct {
18241823 errdefer self.allocator.destroy(obj_di);
18251824
18261825 const macho_path = mem.sliceTo(std.c._dyld_get_image_name(i), 0);
1827 const macho_file = fs.cwd().openFile(macho_path, .{
1828 .intended_io_mode = .blocking,
1829 }) catch |err| switch (err) {
1826 const macho_file = fs.cwd().openFile(macho_path, .{}) catch |err| switch (err) {
18301827 error.FileNotFound => return error.MissingDebugInfo,
18311828 else => return err,
18321829 };
......@@ -2162,7 +2159,7 @@ pub const ModuleDebugInfo = switch (native_os) {
21622159 }
21632160
21642161 fn loadOFile(self: *@This(), allocator: mem.Allocator, o_file_path: []const u8) !*OFileInfo {
2165 const o_file = try fs.cwd().openFile(o_file_path, .{ .intended_io_mode = .blocking });
2162 const o_file = try fs.cwd().openFile(o_file_path, .{});
21662163 const mapped_mem = try mapWholeFile(o_file);
21672164
21682165 const hdr: *const macho.mach_header_64 = @ptrCast(@alignCast(mapped_mem.ptr));
lib/std/fs.zig-7
......@@ -84,13 +84,6 @@ pub const base64_encoder = base64.Base64Encoder.init(base64_alphabet, null);
8484/// Base64 decoder, replacing the standard `+/` with `-_` so that it can be used in a file name on any filesystem.
8585pub const base64_decoder = base64.Base64Decoder.init(base64_alphabet, null);
8686
87/// Whether or not async file system syscalls need a dedicated thread because the operating
88/// system does not support non-blocking I/O on the file system.
89pub const need_async_thread = std.io.is_async and switch (builtin.os.tag) {
90 .windows, .other => false,
91 else => true,
92};
93
9487/// TODO remove the allocator requirement from this API
9588/// TODO move to Dir
9689pub fn atomicSymLink(allocator: Allocator, existing_path: []const u8, new_path: []const u8) !void {
lib/std/fs/Dir.zig+12-59
......@@ -751,11 +751,7 @@ pub const OpenError = error{
751751} || posix.UnexpectedError;
752752
753753pub fn close(self: *Dir) void {
754 if (fs.need_async_thread) {
755 std.event.Loop.instance.?.close(self.fd);
756 } else {
757 posix.close(self.fd);
758 }
754 posix.close(self.fd);
759755 self.* = undefined;
760756}
761757
......@@ -837,10 +833,7 @@ pub fn openFileZ(self: Dir, sub_path: [*:0]const u8, flags: File.OpenFlags) File
837833 .write_only => @as(u32, posix.O.WRONLY),
838834 .read_write => @as(u32, posix.O.RDWR),
839835 };
840 const fd = if (flags.intended_io_mode != .blocking)
841 try std.event.Loop.instance.?.openatZ(self.fd, sub_path, os_flags, 0)
842 else
843 try posix.openatZ(self.fd, sub_path, os_flags, 0);
836 const fd = try posix.openatZ(self.fd, sub_path, os_flags, 0);
844837 errdefer posix.close(fd);
845838
846839 // WASI doesn't have posix.flock so we intetinally check OS prior to the inner if block
......@@ -877,11 +870,7 @@ pub fn openFileZ(self: Dir, sub_path: [*:0]const u8, flags: File.OpenFlags) File
877870 };
878871 }
879872
880 return File{
881 .handle = fd,
882 .capable_io_mode = .blocking,
883 .intended_io_mode = flags.intended_io_mode,
884 };
873 return File{ .handle = fd };
885874}
886875
887876/// Same as `openFile` but Windows-only and the path parameter is
......@@ -895,10 +884,7 @@ pub fn openFileW(self: Dir, sub_path_w: []const u16, flags: File.OpenFlags) File
895884 (if (flags.isRead()) @as(u32, w.GENERIC_READ) else 0) |
896885 (if (flags.isWrite()) @as(u32, w.GENERIC_WRITE) else 0),
897886 .creation = w.FILE_OPEN,
898 .io_mode = flags.intended_io_mode,
899887 }),
900 .capable_io_mode = std.io.default_mode,
901 .intended_io_mode = flags.intended_io_mode,
902888 };
903889 errdefer file.close();
904890 var io: w.IO_STATUS_BLOCK = undefined;
......@@ -994,10 +980,7 @@ pub fn createFileZ(self: Dir, sub_path_c: [*:0]const u8, flags: File.CreateFlags
994980 (if (flags.truncate) @as(u32, posix.O.TRUNC) else 0) |
995981 (if (flags.read) @as(u32, posix.O.RDWR) else posix.O.WRONLY) |
996982 (if (flags.exclusive) @as(u32, posix.O.EXCL) else 0);
997 const fd = if (flags.intended_io_mode != .blocking)
998 try std.event.Loop.instance.?.openatZ(self.fd, sub_path_c, os_flags, flags.mode)
999 else
1000 try posix.openatZ(self.fd, sub_path_c, os_flags, flags.mode);
983 const fd = try posix.openatZ(self.fd, sub_path_c, os_flags, flags.mode);
1001984 errdefer posix.close(fd);
1002985
1003986 // WASI doesn't have posix.flock so we intetinally check OS prior to the inner if block
......@@ -1034,11 +1017,7 @@ pub fn createFileZ(self: Dir, sub_path_c: [*:0]const u8, flags: File.CreateFlags
10341017 };
10351018 }
10361019
1037 return File{
1038 .handle = fd,
1039 .capable_io_mode = .blocking,
1040 .intended_io_mode = flags.intended_io_mode,
1041 };
1020 return File{ .handle = fd };
10421021}
10431022
10441023/// Same as `createFile` but Windows-only and the path parameter is
......@@ -1056,10 +1035,7 @@ pub fn createFileW(self: Dir, sub_path_w: []const u16, flags: File.CreateFlags)
10561035 @as(u32, w.FILE_OVERWRITE_IF)
10571036 else
10581037 @as(u32, w.FILE_OPEN_IF),
1059 .io_mode = flags.intended_io_mode,
10601038 }),
1061 .capable_io_mode = std.io.default_mode,
1062 .intended_io_mode = flags.intended_io_mode,
10631039 };
10641040 errdefer file.close();
10651041 var io: w.IO_STATUS_BLOCK = undefined;
......@@ -1276,7 +1252,6 @@ pub fn realpathW(self: Dir, pathname: []const u16, out_buffer: []u8) ![]u8 {
12761252 .access_mask = access_mask,
12771253 .share_access = share_access,
12781254 .creation = creation,
1279 .io_mode = .blocking,
12801255 .filter = .any,
12811256 }) catch |err| switch (err) {
12821257 error.WouldBlock => unreachable,
......@@ -1449,11 +1424,7 @@ pub fn openDirW(self: Dir, sub_path_w: [*:0]const u16, args: OpenDirOptions) Ope
14491424
14501425/// `flags` must contain `posix.O.DIRECTORY`.
14511426fn openDirFlagsZ(self: Dir, sub_path_c: [*:0]const u8, flags: u32) OpenError!Dir {
1452 const result = if (fs.need_async_thread)
1453 std.event.Loop.instance.?.openatZ(self.fd, sub_path_c, flags, 0)
1454 else
1455 posix.openatZ(self.fd, sub_path_c, flags, 0);
1456 const fd = result catch |err| switch (err) {
1427 const fd = posix.openatZ(self.fd, sub_path_c, flags, 0) catch |err| switch (err) {
14571428 error.FileTooBig => unreachable, // can't happen for directories
14581429 error.IsDir => unreachable, // we're providing O.DIRECTORY
14591430 error.NoSpaceLeft => unreachable, // not providing O.CREAT
......@@ -2270,10 +2241,7 @@ pub fn accessZ(self: Dir, sub_path: [*:0]const u8, flags: File.OpenFlags) Access
22702241 .write_only => @as(u32, posix.W_OK),
22712242 .read_write => @as(u32, posix.R_OK | posix.W_OK),
22722243 };
2273 const result = if (fs.need_async_thread and flags.intended_io_mode != .blocking)
2274 std.event.Loop.instance.?.faccessatZ(self.fd, sub_path, os_mode, 0)
2275 else
2276 posix.faccessatZ(self.fd, sub_path, os_mode, 0);
2244 const result = posix.faccessatZ(self.fd, sub_path, os_mode, 0);
22772245 return result;
22782246}
22792247
......@@ -2457,10 +2425,7 @@ pub const Stat = File.Stat;
24572425pub const StatError = File.StatError;
24582426
24592427pub fn stat(self: Dir) StatError!Stat {
2460 const file: File = .{
2461 .handle = self.fd,
2462 .capable_io_mode = .blocking,
2463 };
2428 const file: File = .{ .handle = self.fd };
24642429 return file.stat();
24652430}
24662431
......@@ -2496,10 +2461,7 @@ pub const ChmodError = File.ChmodError;
24962461/// of the directory. Additionally, the directory must have been opened
24972462/// with `OpenDirOptions{ .iterate = true }`.
24982463pub fn chmod(self: Dir, new_mode: File.Mode) ChmodError!void {
2499 const file: File = .{
2500 .handle = self.fd,
2501 .capable_io_mode = .blocking,
2502 };
2464 const file: File = .{ .handle = self.fd };
25032465 try file.chmod(new_mode);
25042466}
25052467
......@@ -2510,10 +2472,7 @@ pub fn chmod(self: Dir, new_mode: File.Mode) ChmodError!void {
25102472/// must have been opened with `OpenDirOptions{ .iterate = true }`. If the
25112473/// owner or group is specified as `null`, the ID is not changed.
25122474pub fn chown(self: Dir, owner: ?File.Uid, group: ?File.Gid) ChownError!void {
2513 const file: File = .{
2514 .handle = self.fd,
2515 .capable_io_mode = .blocking,
2516 };
2475 const file: File = .{ .handle = self.fd };
25172476 try file.chown(owner, group);
25182477}
25192478
......@@ -2525,10 +2484,7 @@ pub const SetPermissionsError = File.SetPermissionsError;
25252484/// Sets permissions according to the provided `Permissions` struct.
25262485/// This method is *NOT* available on WASI
25272486pub fn setPermissions(self: Dir, permissions: Permissions) SetPermissionsError!void {
2528 const file: File = .{
2529 .handle = self.fd,
2530 .capable_io_mode = .blocking,
2531 };
2487 const file: File = .{ .handle = self.fd };
25322488 try file.setPermissions(permissions);
25332489}
25342490
......@@ -2537,10 +2493,7 @@ pub const MetadataError = File.MetadataError;
25372493
25382494/// Returns a `Metadata` struct, representing the permissions on the directory
25392495pub fn metadata(self: Dir) MetadataError!Metadata {
2540 const file: File = .{
2541 .handle = self.fd,
2542 .capable_io_mode = .blocking,
2543 };
2496 const file: File = .{ .handle = self.fd };
25442497 return try file.metadata();
25452498}
25462499
lib/std/fs/File.zig+16-80
......@@ -1,20 +1,6 @@
11/// The OS-specific file descriptor or file handle.
22handle: Handle,
33
4/// On some systems, such as Linux, file system file descriptors are incapable
5/// of non-blocking I/O. This forces us to perform asynchronous I/O on a dedicated thread,
6/// to achieve non-blocking file-system I/O. To do this, `File` must be aware of whether
7/// it is a file system file descriptor, or, more specifically, whether the I/O is always
8/// blocking.
9capable_io_mode: io.ModeOverride = io.default_mode,
10
11/// Furthermore, even when `std.options.io_mode` is async, it is still sometimes desirable
12/// to perform blocking I/O, although not by default. For example, when printing a
13/// stack trace to stderr. This field tracks both by acting as an overriding I/O mode.
14/// When not building in async I/O mode, the type only has the `.blocking` tag, making
15/// it a zero-bit type.
16intended_io_mode: io.ModeOverride = io.default_mode,
17
184pub const Handle = posix.fd_t;
195pub const Mode = posix.mode_t;
206pub const INode = posix.ino_t;
......@@ -108,16 +94,8 @@ pub const OpenFlags = struct {
10894 /// Sets whether or not to wait until the file is locked to return. If set to true,
10995 /// `error.WouldBlock` will be returned. Otherwise, the file will wait until the file
11096 /// is available to proceed.
111 /// In async I/O mode, non-blocking at the OS level is
112 /// determined by `intended_io_mode`, and `true` means `error.WouldBlock` is returned,
113 /// and `false` means `error.WouldBlock` is handled by the event loop.
11497 lock_nonblocking: bool = false,
11598
116 /// Setting this to `.blocking` prevents `O.NONBLOCK` from being passed even
117 /// if `std.io.is_async`. It allows the use of `nosuspend` when calling functions
118 /// related to opening the file, reading, writing, and locking.
119 intended_io_mode: io.ModeOverride = io.default_mode,
120
12199 /// Set this to allow the opened file to automatically become the
122100 /// controlling TTY for the current process.
123101 allow_ctty: bool = false,
......@@ -172,19 +150,11 @@ pub const CreateFlags = struct {
172150 /// Sets whether or not to wait until the file is locked to return. If set to true,
173151 /// `error.WouldBlock` will be returned. Otherwise, the file will wait until the file
174152 /// is available to proceed.
175 /// In async I/O mode, non-blocking at the OS level is
176 /// determined by `intended_io_mode`, and `true` means `error.WouldBlock` is returned,
177 /// and `false` means `error.WouldBlock` is handled by the event loop.
178153 lock_nonblocking: bool = false,
179154
180155 /// For POSIX systems this is the file system mode the file will
181156 /// be created with. On other systems this is always 0.
182157 mode: Mode = default_mode,
183
184 /// Setting this to `.blocking` prevents `O.NONBLOCK` from being passed even
185 /// if `std.io.is_async`. It allows the use of `nosuspend` when calling functions
186 /// related to opening the file, reading, writing, and locking.
187 intended_io_mode: io.ModeOverride = io.default_mode,
188158};
189159
190160/// Upon success, the stream is in an uninitialized state. To continue using it,
......@@ -192,8 +162,6 @@ pub const CreateFlags = struct {
192162pub fn close(self: File) void {
193163 if (is_windows) {
194164 windows.CloseHandle(self.handle);
195 } else if (self.capable_io_mode != self.intended_io_mode) {
196 std.event.Loop.instance.?.close(self.handle);
197165 } else {
198166 posix.close(self.handle);
199167 }
......@@ -1013,14 +981,10 @@ pub const PReadError = posix.PReadError;
1013981
1014982pub fn read(self: File, buffer: []u8) ReadError!usize {
1015983 if (is_windows) {
1016 return windows.ReadFile(self.handle, buffer, null, self.intended_io_mode);
984 return windows.ReadFile(self.handle, buffer, null);
1017985 }
1018986
1019 if (self.intended_io_mode == .blocking) {
1020 return posix.read(self.handle, buffer);
1021 } else {
1022 return std.event.Loop.instance.?.read(self.handle, buffer, self.capable_io_mode != self.intended_io_mode);
1023 }
987 return posix.read(self.handle, buffer);
1024988}
1025989
1026990/// Returns the number of bytes read. If the number read is smaller than `buffer.len`, it
......@@ -1039,14 +1003,10 @@ pub fn readAll(self: File, buffer: []u8) ReadError!usize {
10391003/// https://github.com/ziglang/zig/issues/12783
10401004pub fn pread(self: File, buffer: []u8, offset: u64) PReadError!usize {
10411005 if (is_windows) {
1042 return windows.ReadFile(self.handle, buffer, offset, self.intended_io_mode);
1006 return windows.ReadFile(self.handle, buffer, offset);
10431007 }
10441008
1045 if (self.intended_io_mode == .blocking) {
1046 return posix.pread(self.handle, buffer, offset);
1047 } else {
1048 return std.event.Loop.instance.?.pread(self.handle, buffer, offset, self.capable_io_mode != self.intended_io_mode);
1049 }
1009 return posix.pread(self.handle, buffer, offset);
10501010}
10511011
10521012/// Returns the number of bytes read. If the number read is smaller than `buffer.len`, it
......@@ -1069,14 +1029,10 @@ pub fn readv(self: File, iovecs: []const posix.iovec) ReadError!usize {
10691029 // TODO improve this to use ReadFileScatter
10701030 if (iovecs.len == 0) return @as(usize, 0);
10711031 const first = iovecs[0];
1072 return windows.ReadFile(self.handle, first.iov_base[0..first.iov_len], null, self.intended_io_mode);
1032 return windows.ReadFile(self.handle, first.iov_base[0..first.iov_len], null);
10731033 }
10741034
1075 if (self.intended_io_mode == .blocking) {
1076 return posix.readv(self.handle, iovecs);
1077 } else {
1078 return std.event.Loop.instance.?.readv(self.handle, iovecs, self.capable_io_mode != self.intended_io_mode);
1079 }
1035 return posix.readv(self.handle, iovecs);
10801036}
10811037
10821038/// Returns the number of bytes read. If the number read is smaller than the total bytes
......@@ -1129,14 +1085,10 @@ pub fn preadv(self: File, iovecs: []const posix.iovec, offset: u64) PReadError!u
11291085 // TODO improve this to use ReadFileScatter
11301086 if (iovecs.len == 0) return @as(usize, 0);
11311087 const first = iovecs[0];
1132 return windows.ReadFile(self.handle, first.iov_base[0..first.iov_len], offset, self.intended_io_mode);
1088 return windows.ReadFile(self.handle, first.iov_base[0..first.iov_len], offset);
11331089 }
11341090
1135 if (self.intended_io_mode == .blocking) {
1136 return posix.preadv(self.handle, iovecs, offset);
1137 } else {
1138 return std.event.Loop.instance.?.preadv(self.handle, iovecs, offset, self.capable_io_mode != self.intended_io_mode);
1139 }
1091 return posix.preadv(self.handle, iovecs, offset);
11401092}
11411093
11421094/// Returns the number of bytes read. If the number read is smaller than the total bytes
......@@ -1173,14 +1125,10 @@ pub const PWriteError = posix.PWriteError;
11731125
11741126pub fn write(self: File, bytes: []const u8) WriteError!usize {
11751127 if (is_windows) {
1176 return windows.WriteFile(self.handle, bytes, null, self.intended_io_mode);
1128 return windows.WriteFile(self.handle, bytes, null);
11771129 }
11781130
1179 if (self.intended_io_mode == .blocking) {
1180 return posix.write(self.handle, bytes);
1181 } else {
1182 return std.event.Loop.instance.?.write(self.handle, bytes, self.capable_io_mode != self.intended_io_mode);
1183 }
1131 return posix.write(self.handle, bytes);
11841132}
11851133
11861134pub fn writeAll(self: File, bytes: []const u8) WriteError!void {
......@@ -1194,14 +1142,10 @@ pub fn writeAll(self: File, bytes: []const u8) WriteError!void {
11941142/// https://github.com/ziglang/zig/issues/12783
11951143pub fn pwrite(self: File, bytes: []const u8, offset: u64) PWriteError!usize {
11961144 if (is_windows) {
1197 return windows.WriteFile(self.handle, bytes, offset, self.intended_io_mode);
1145 return windows.WriteFile(self.handle, bytes, offset);
11981146 }
11991147
1200 if (self.intended_io_mode == .blocking) {
1201 return posix.pwrite(self.handle, bytes, offset);
1202 } else {
1203 return std.event.Loop.instance.?.pwrite(self.handle, bytes, offset, self.capable_io_mode != self.intended_io_mode);
1204 }
1148 return posix.pwrite(self.handle, bytes, offset);
12051149}
12061150
12071151/// On Windows, this function currently does alter the file pointer.
......@@ -1220,14 +1164,10 @@ pub fn writev(self: File, iovecs: []const posix.iovec_const) WriteError!usize {
12201164 // TODO improve this to use WriteFileScatter
12211165 if (iovecs.len == 0) return @as(usize, 0);
12221166 const first = iovecs[0];
1223 return windows.WriteFile(self.handle, first.iov_base[0..first.iov_len], null, self.intended_io_mode);
1167 return windows.WriteFile(self.handle, first.iov_base[0..first.iov_len], null);
12241168 }
12251169
1226 if (self.intended_io_mode == .blocking) {
1227 return posix.writev(self.handle, iovecs);
1228 } else {
1229 return std.event.Loop.instance.?.writev(self.handle, iovecs, self.capable_io_mode != self.intended_io_mode);
1230 }
1170 return posix.writev(self.handle, iovecs);
12311171}
12321172
12331173/// The `iovecs` parameter is mutable because:
......@@ -1271,14 +1211,10 @@ pub fn pwritev(self: File, iovecs: []posix.iovec_const, offset: u64) PWriteError
12711211 // TODO improve this to use WriteFileScatter
12721212 if (iovecs.len == 0) return @as(usize, 0);
12731213 const first = iovecs[0];
1274 return windows.WriteFile(self.handle, first.iov_base[0..first.iov_len], offset, self.intended_io_mode);
1214 return windows.WriteFile(self.handle, first.iov_base[0..first.iov_len], offset);
12751215 }
12761216
1277 if (self.intended_io_mode == .blocking) {
1278 return posix.pwritev(self.handle, iovecs, offset);
1279 } else {
1280 return std.event.Loop.instance.?.pwritev(self.handle, iovecs, offset, self.capable_io_mode != self.intended_io_mode);
1281 }
1217 return posix.pwritev(self.handle, iovecs, offset);
12821218}
12831219
12841220/// The `iovecs` parameter is mutable because this function needs to mutate the fields in
lib/std/fs/test.zig-5
......@@ -1508,11 +1508,6 @@ test "open file with exclusive and shared nonblocking lock" {
15081508test "open file with exclusive lock twice, make sure second lock waits" {
15091509 if (builtin.single_threaded) return error.SkipZigTest;
15101510
1511 if (std.io.is_async) {
1512 // This test starts its own threads and is not compatible with async I/O.
1513 return error.SkipZigTest;
1514 }
1515
15161511 try testWithAllSupportedPathTypes(struct {
15171512 fn impl(ctx: *TestContext) !void {
15181513 const filename = try ctx.transformPath("file_lock_test.txt");
lib/std/io.zig+3-36
......@@ -12,21 +12,6 @@ const meta = std.meta;
1212const File = std.fs.File;
1313const Allocator = std.mem.Allocator;
1414
15pub const Mode = enum {
16 /// I/O operates normally, waiting for the operating system syscalls to complete.
17 blocking,
18
19 /// I/O functions are generated async and rely on a global event loop. Event-based I/O.
20 evented,
21};
22
23pub const is_async = false;
24
25/// This is an enum value to use for I/O mode at runtime, since it takes up zero bytes at runtime,
26/// and makes expressions comptime-known when `is_async` is `false`.
27pub const ModeOverride = if (is_async) Mode else enum { blocking };
28pub const default_mode: ModeOverride = if (is_async) Mode.evented else .blocking;
29
3015fn getStdOutHandle() os.fd_t {
3116 if (builtin.os.tag == .windows) {
3217 if (builtin.zig_backend == .stage2_aarch64) {
......@@ -43,14 +28,8 @@ fn getStdOutHandle() os.fd_t {
4328 return os.STDOUT_FILENO;
4429}
4530
46/// TODO: async stdout on windows without a dedicated thread.
47/// https://github.com/ziglang/zig/pull/4816#issuecomment-604521023
4831pub fn getStdOut() File {
49 return File{
50 .handle = getStdOutHandle(),
51 .capable_io_mode = .blocking,
52 .intended_io_mode = default_mode,
53 };
32 return File{ .handle = getStdOutHandle() };
5433}
5534
5635fn getStdErrHandle() os.fd_t {
......@@ -69,14 +48,8 @@ fn getStdErrHandle() os.fd_t {
6948 return os.STDERR_FILENO;
7049}
7150
72/// This returns a `File` that is configured to block with every write, in order
73/// to facilitate better debugging. This can be changed by modifying the `intended_io_mode` field.
7451pub fn getStdErr() File {
75 return File{
76 .handle = getStdErrHandle(),
77 .capable_io_mode = .blocking,
78 .intended_io_mode = .blocking,
79 };
52 return File{ .handle = getStdErrHandle() };
8053}
8154
8255fn getStdInHandle() os.fd_t {
......@@ -95,14 +68,8 @@ fn getStdInHandle() os.fd_t {
9568 return os.STDIN_FILENO;
9669}
9770
98/// TODO: async stdin on windows without a dedicated thread.
99/// https://github.com/ziglang/zig/pull/4816#issuecomment-604521023
10071pub fn getStdIn() File {
101 return File{
102 .handle = getStdInHandle(),
103 .capable_io_mode = .blocking,
104 .intended_io_mode = default_mode,
105 };
72 return File{ .handle = getStdInHandle() };
10673}
10774
10875pub fn GenericReader(
lib/std/net.zig+16-63
......@@ -651,7 +651,7 @@ pub const Ip6Address = extern struct {
651651};
652652
653653pub fn connectUnixSocket(path: []const u8) !Stream {
654 const opt_non_block = if (std.io.is_async) os.SOCK.NONBLOCK else 0;
654 const opt_non_block = 0;
655655 const sockfd = try os.socket(
656656 os.AF.UNIX,
657657 os.SOCK.STREAM | os.SOCK.CLOEXEC | opt_non_block,
......@@ -660,17 +660,9 @@ pub fn connectUnixSocket(path: []const u8) !Stream {
660660 errdefer os.closeSocket(sockfd);
661661
662662 var addr = try std.net.Address.initUnix(path);
663 try os.connect(sockfd, &addr.any, addr.getOsSockLen());
663664
664 if (std.io.is_async) {
665 const loop = std.event.Loop.instance orelse return error.WouldBlock;
666 try loop.connect(sockfd, &addr.any, addr.getOsSockLen());
667 } else {
668 try os.connect(sockfd, &addr.any, addr.getOsSockLen());
669 }
670
671 return Stream{
672 .handle = sockfd,
673 };
665 return Stream{ .handle = sockfd };
674666}
675667
676668fn if_nametoindex(name: []const u8) IPv6InterfaceError!u32 {
......@@ -742,18 +734,13 @@ pub fn tcpConnectToHost(allocator: mem.Allocator, name: []const u8, port: u16) T
742734pub const TcpConnectToAddressError = std.os.SocketError || std.os.ConnectError;
743735
744736pub fn tcpConnectToAddress(address: Address) TcpConnectToAddressError!Stream {
745 const nonblock = if (std.io.is_async) os.SOCK.NONBLOCK else 0;
737 const nonblock = 0;
746738 const sock_flags = os.SOCK.STREAM | nonblock |
747739 (if (builtin.target.os.tag == .windows) 0 else os.SOCK.CLOEXEC);
748740 const sockfd = try os.socket(address.any.family, sock_flags, os.IPPROTO.TCP);
749741 errdefer os.closeSocket(sockfd);
750742
751 if (std.io.is_async) {
752 const loop = std.event.Loop.instance orelse return error.WouldBlock;
753 try loop.connect(sockfd, &address.any, address.getOsSockLen());
754 } else {
755 try os.connect(sockfd, &address.any, address.getOsSockLen());
756 }
743 try os.connect(sockfd, &address.any, address.getOsSockLen());
757744
758745 return Stream{ .handle = sockfd };
759746}
......@@ -1618,11 +1605,7 @@ fn resMSendRc(
16181605 if (answers[i].len == 0) {
16191606 var j: usize = 0;
16201607 while (j < ns.len) : (j += 1) {
1621 if (std.io.is_async) {
1622 _ = std.event.Loop.instance.?.sendto(fd, queries[i], os.MSG.NOSIGNAL, &ns[j].any, sl) catch undefined;
1623 } else {
1624 _ = os.sendto(fd, queries[i], os.MSG.NOSIGNAL, &ns[j].any, sl) catch undefined;
1625 }
1608 _ = os.sendto(fd, queries[i], os.MSG.NOSIGNAL, &ns[j].any, sl) catch undefined;
16261609 }
16271610 }
16281611 }
......@@ -1637,10 +1620,7 @@ fn resMSendRc(
16371620
16381621 while (true) {
16391622 var sl_copy = sl;
1640 const rlen = if (std.io.is_async)
1641 std.event.Loop.instance.?.recvfrom(fd, answer_bufs[next], 0, &sa.any, &sl_copy) catch break
1642 else
1643 os.recvfrom(fd, answer_bufs[next], 0, &sa.any, &sl_copy) catch break;
1623 const rlen = os.recvfrom(fd, answer_bufs[next], 0, &sa.any, &sl_copy) catch break;
16441624
16451625 // Ignore non-identifiable packets
16461626 if (rlen < 4) continue;
......@@ -1666,11 +1646,7 @@ fn resMSendRc(
16661646 0, 3 => {},
16671647 2 => if (servfail_retry != 0) {
16681648 servfail_retry -= 1;
1669 if (std.io.is_async) {
1670 _ = std.event.Loop.instance.?.sendto(fd, queries[i], os.MSG.NOSIGNAL, &ns[j].any, sl) catch undefined;
1671 } else {
1672 _ = os.sendto(fd, queries[i], os.MSG.NOSIGNAL, &ns[j].any, sl) catch undefined;
1673 }
1649 _ = os.sendto(fd, queries[i], os.MSG.NOSIGNAL, &ns[j].any, sl) catch undefined;
16741650 },
16751651 else => continue,
16761652 }
......@@ -1778,14 +1754,10 @@ pub const Stream = struct {
17781754
17791755 pub fn read(self: Stream, buffer: []u8) ReadError!usize {
17801756 if (builtin.os.tag == .windows) {
1781 return os.windows.ReadFile(self.handle, buffer, null, io.default_mode);
1757 return os.windows.ReadFile(self.handle, buffer, null);
17821758 }
17831759
1784 if (std.io.is_async) {
1785 return std.event.Loop.instance.?.read(self.handle, buffer, false);
1786 } else {
1787 return os.read(self.handle, buffer);
1788 }
1760 return os.read(self.handle, buffer);
17891761 }
17901762
17911763 pub fn readv(s: Stream, iovecs: []const os.iovec) ReadError!usize {
......@@ -1793,7 +1765,7 @@ pub const Stream = struct {
17931765 // TODO improve this to use ReadFileScatter
17941766 if (iovecs.len == 0) return @as(usize, 0);
17951767 const first = iovecs[0];
1796 return os.windows.ReadFile(s.handle, first.iov_base[0..first.iov_len], null, io.default_mode);
1768 return os.windows.ReadFile(s.handle, first.iov_base[0..first.iov_len], null);
17971769 }
17981770
17991771 return os.readv(s.handle, iovecs);
......@@ -1827,14 +1799,10 @@ pub const Stream = struct {
18271799 /// use non-blocking I/O.
18281800 pub fn write(self: Stream, buffer: []const u8) WriteError!usize {
18291801 if (builtin.os.tag == .windows) {
1830 return os.windows.WriteFile(self.handle, buffer, null, io.default_mode);
1802 return os.windows.WriteFile(self.handle, buffer, null);
18311803 }
18321804
1833 if (std.io.is_async) {
1834 return std.event.Loop.instance.?.write(self.handle, buffer, false);
1835 } else {
1836 return os.write(self.handle, buffer);
1837 }
1805 return os.write(self.handle, buffer);
18381806 }
18391807
18401808 pub fn writeAll(self: Stream, bytes: []const u8) WriteError!void {
......@@ -1847,15 +1815,7 @@ pub const Stream = struct {
18471815 /// See https://github.com/ziglang/zig/issues/7699
18481816 /// See equivalent function: `std.fs.File.writev`.
18491817 pub fn writev(self: Stream, iovecs: []const os.iovec_const) WriteError!usize {
1850 if (std.io.is_async) {
1851 // TODO improve to actually take advantage of writev syscall, if available.
1852 if (iovecs.len == 0) return 0;
1853 const first_buffer = iovecs[0].iov_base[0..iovecs[0].iov_len];
1854 try self.write(first_buffer);
1855 return first_buffer.len;
1856 } else {
1857 return os.writev(self.handle, iovecs);
1858 }
1818 return os.writev(self.handle, iovecs);
18591819 }
18601820
18611821 /// The `iovecs` parameter is mutable because this function needs to mutate the fields in
......@@ -1927,7 +1887,7 @@ pub const StreamServer = struct {
19271887 }
19281888
19291889 pub fn listen(self: *StreamServer, address: Address) !void {
1930 const nonblock = if (std.io.is_async) os.SOCK.NONBLOCK else 0;
1890 const nonblock = 0;
19311891 const sock_flags = os.SOCK.STREAM | os.SOCK.CLOEXEC | nonblock;
19321892 var use_sock_flags: u32 = sock_flags;
19331893 if (self.force_nonblocking) use_sock_flags |= os.SOCK.NONBLOCK;
......@@ -2016,14 +1976,7 @@ pub const StreamServer = struct {
20161976 pub fn accept(self: *StreamServer) AcceptError!Connection {
20171977 var accepted_addr: Address = undefined;
20181978 var adr_len: os.socklen_t = @sizeOf(Address);
2019 const accept_result = blk: {
2020 if (std.io.is_async) {
2021 const loop = std.event.Loop.instance orelse return error.UnexpectedError;
2022 break :blk loop.accept(self.sockfd.?, &accepted_addr.any, &adr_len, os.SOCK.CLOEXEC);
2023 } else {
2024 break :blk os.accept(self.sockfd.?, &accepted_addr.any, &adr_len, os.SOCK.CLOEXEC);
2025 }
2026 };
1979 const accept_result = os.accept(self.sockfd.?, &accepted_addr.any, &adr_len, os.SOCK.CLOEXEC);
20271980
20281981 if (accept_result) |fd| {
20291982 return Connection{
lib/std/net/test.zig-48
......@@ -207,54 +207,6 @@ test "listen on a port, send bytes, receive bytes" {
207207 try testing.expectEqualSlices(u8, "Hello world!", buf[0..n]);
208208}
209209
210test "listen on a port, send bytes, receive bytes, async-only" {
211 if (!std.io.is_async) return error.SkipZigTest;
212
213 if (builtin.os.tag != .linux and !builtin.os.tag.isDarwin()) {
214 // TODO build abstractions for other operating systems
215 return error.SkipZigTest;
216 }
217
218 // TODO doing this at comptime crashed the compiler
219 const localhost = try net.Address.parseIp("127.0.0.1", 0);
220
221 var server = net.StreamServer.init(net.StreamServer.Options{});
222 defer server.deinit();
223 try server.listen(localhost);
224
225 var server_frame = async testServer(&server);
226 var client_frame = async testClient(server.listen_address);
227
228 try await server_frame;
229 try await client_frame;
230}
231
232test "listen on ipv4 try connect on ipv6 then ipv4" {
233 if (!std.io.is_async) return error.SkipZigTest;
234
235 if (builtin.os.tag != .linux and !builtin.os.tag.isDarwin()) {
236 // TODO build abstractions for other operating systems
237 return error.SkipZigTest;
238 }
239
240 // TODO doing this at comptime crashed the compiler
241 const localhost = try net.Address.parseIp("127.0.0.1", 0);
242
243 var server = net.StreamServer.init(net.StreamServer.Options{});
244 defer server.deinit();
245 try server.listen(localhost);
246
247 var server_frame = async testServer(&server);
248 var client_frame = async testClientToHost(
249 testing.allocator,
250 "localhost",
251 server.listen_address.getPort(),
252 );
253
254 try await server_frame;
255 try await client_frame;
256}
257
258210test "listen on an in use port" {
259211 if (builtin.os.tag != .linux and comptime !builtin.os.tag.isDarwin()) {
260212 // TODO build abstractions for other operating systems
lib/std/os.zig+6-29
......@@ -683,11 +683,7 @@ fn getRandomBytesDevURandom(buf: []u8) !void {
683683 return error.NoDevice;
684684 }
685685
686 const file = std.fs.File{
687 .handle = fd,
688 .capable_io_mode = .blocking,
689 .intended_io_mode = .blocking,
690 };
686 const file = std.fs.File{ .handle = fd };
691687 const stream = file.reader();
692688 stream.readNoEof(buf) catch return error.Unexpected;
693689}
......@@ -856,7 +852,7 @@ pub const ReadError = error{
856852pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
857853 if (buf.len == 0) return 0;
858854 if (builtin.os.tag == .windows) {
859 return windows.ReadFile(fd, buf, null, std.io.default_mode);
855 return windows.ReadFile(fd, buf, null);
860856 }
861857 if (builtin.os.tag == .wasi and !builtin.link_libc) {
862858 const iovs = [1]iovec{iovec{
......@@ -995,7 +991,7 @@ pub const PReadError = ReadError || error{Unseekable};
995991pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize {
996992 if (buf.len == 0) return 0;
997993 if (builtin.os.tag == .windows) {
998 return windows.ReadFile(fd, buf, offset, std.io.default_mode);
994 return windows.ReadFile(fd, buf, offset);
999995 }
1000996 if (builtin.os.tag == .wasi and !builtin.link_libc) {
1001997 const iovs = [1]iovec{iovec{
......@@ -1257,7 +1253,7 @@ pub const WriteError = error{
12571253pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
12581254 if (bytes.len == 0) return 0;
12591255 if (builtin.os.tag == .windows) {
1260 return windows.WriteFile(fd, bytes, null, std.io.default_mode);
1256 return windows.WriteFile(fd, bytes, null);
12611257 }
12621258
12631259 if (builtin.os.tag == .wasi and !builtin.link_libc) {
......@@ -1415,7 +1411,7 @@ pub const PWriteError = WriteError || error{Unseekable};
14151411pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
14161412 if (bytes.len == 0) return 0;
14171413 if (builtin.os.tag == .windows) {
1418 return windows.WriteFile(fd, bytes, offset, std.io.default_mode);
1414 return windows.WriteFile(fd, bytes, offset);
14191415 }
14201416 if (builtin.os.tag == .wasi and !builtin.link_libc) {
14211417 const ciovs = [1]iovec_const{iovec_const{
......@@ -1711,7 +1707,6 @@ fn openOptionsFromFlagsWindows(flags: u32) windows.OpenFileOptions {
17111707
17121708 return .{
17131709 .access_mask = access_mask,
1714 .io_mode = .blocking,
17151710 .creation = creation,
17161711 .filter = filter,
17171712 .follow_symlinks = follow_symlinks,
......@@ -2797,7 +2792,6 @@ pub fn renameatW(
27972792 .dir = old_dir_fd,
27982793 .access_mask = windows.SYNCHRONIZE | windows.GENERIC_WRITE | windows.DELETE,
27992794 .creation = windows.FILE_OPEN,
2800 .io_mode = .blocking,
28012795 .filter = .any, // This function is supposed to rename both files and directories.
28022796 .follow_symlinks = false,
28032797 }) catch |err| switch (err) {
......@@ -2962,7 +2956,6 @@ pub fn mkdiratW(dir_fd: fd_t, sub_path_w: []const u16, mode: u32) MakeDirError!v
29622956 .dir = dir_fd,
29632957 .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE,
29642958 .creation = windows.FILE_CREATE,
2965 .io_mode = .blocking,
29662959 .filter = .dir_only,
29672960 }) catch |err| switch (err) {
29682961 error.IsDir => unreachable,
......@@ -3042,7 +3035,6 @@ pub fn mkdirW(dir_path_w: []const u16, mode: u32) MakeDirError!void {
30423035 .dir = std.fs.cwd().fd,
30433036 .access_mask = windows.GENERIC_READ | windows.SYNCHRONIZE,
30443037 .creation = windows.FILE_CREATE,
3045 .io_mode = .blocking,
30463038 .filter = .dir_only,
30473039 }) catch |err| switch (err) {
30483040 error.IsDir => unreachable,
......@@ -5440,7 +5432,6 @@ pub fn realpathW(pathname: []const u16, out_buffer: *[MAX_PATH_BYTES]u8) RealPat
54405432 .access_mask = access_mask,
54415433 .share_access = share_access,
54425434 .creation = creation,
5443 .io_mode = .blocking,
54445435 .filter = .any,
54455436 }) catch |err| switch (err) {
54465437 error.WouldBlock => unreachable,
......@@ -6404,12 +6395,7 @@ pub fn sendfile(
64046395 // manually, the same as ENOSYS.
64056396 break :sf;
64066397 },
6407 .AGAIN => if (std.event.Loop.instance) |loop| {
6408 loop.waitUntilFdWritable(out_fd);
6409 continue;
6410 } else {
6411 return error.WouldBlock;
6412 },
6398 .AGAIN => return error.WouldBlock,
64136399 .IO => return error.InputOutput,
64146400 .PIPE => return error.BrokenPipe,
64156401 .NOMEM => return error.SystemResources,
......@@ -6476,18 +6462,12 @@ pub fn sendfile(
64766462
64776463 .AGAIN => if (amt != 0) {
64786464 return amt;
6479 } else if (std.event.Loop.instance) |loop| {
6480 loop.waitUntilFdWritable(out_fd);
6481 continue;
64826465 } else {
64836466 return error.WouldBlock;
64846467 },
64856468
64866469 .BUSY => if (amt != 0) {
64876470 return amt;
6488 } else if (std.event.Loop.instance) |loop| {
6489 loop.waitUntilFdReadable(in_fd);
6490 continue;
64916471 } else {
64926472 return error.WouldBlock;
64936473 },
......@@ -6550,9 +6530,6 @@ pub fn sendfile(
65506530
65516531 .AGAIN => if (amt != 0) {
65526532 return amt;
6553 } else if (std.event.Loop.instance) |loop| {
6554 loop.waitUntilFdWritable(out_fd);
6555 continue;
65566533 } else {
65576534 return error.WouldBlock;
65586535 },
lib/std/os/windows.zig+50-150
......@@ -49,7 +49,6 @@ pub const OpenFileOptions = struct {
4949 sa: ?*SECURITY_ATTRIBUTES = null,
5050 share_access: ULONG = FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE,
5151 creation: ULONG,
52 io_mode: std.io.ModeOverride,
5352 /// If true, tries to open path as a directory.
5453 /// Defaults to false.
5554 filter: Filter = .file_only,
......@@ -95,7 +94,7 @@ pub fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!HAN
9594 .SecurityQualityOfService = null,
9695 };
9796 var io: IO_STATUS_BLOCK = undefined;
98 const blocking_flag: ULONG = if (options.io_mode == .blocking) FILE_SYNCHRONOUS_IO_NONALERT else 0;
97 const blocking_flag: ULONG = FILE_SYNCHRONOUS_IO_NONALERT;
9998 const file_or_dir_flag: ULONG = switch (options.filter) {
10099 .file_only => FILE_NON_DIRECTORY_FILE,
101100 .dir_only => FILE_DIRECTORY_FILE,
......@@ -119,12 +118,7 @@ pub fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!HAN
119118 0,
120119 );
121120 switch (rc) {
122 .SUCCESS => {
123 if (std.io.is_async and options.io_mode == .evented) {
124 _ = CreateIoCompletionPort(result, std.event.Loop.instance.?.os_data.io_port, undefined, undefined) catch undefined;
125 }
126 return result;
127 },
121 .SUCCESS => return result,
128122 .OBJECT_NAME_INVALID => unreachable,
129123 .OBJECT_NAME_NOT_FOUND => return error.FileNotFound,
130124 .OBJECT_PATH_NOT_FOUND => return error.FileNotFound,
......@@ -457,81 +451,36 @@ pub const ReadFileError = error{
457451
458452/// If buffer's length exceeds what a Windows DWORD integer can hold, it will be broken into
459453/// multiple non-atomic reads.
460pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64, io_mode: std.io.ModeOverride) ReadFileError!usize {
461 if (io_mode != .blocking) {
462 const loop = std.event.Loop.instance.?;
463 // TODO make getting the file position non-blocking
464 const off = if (offset) |o| o else try SetFilePointerEx_CURRENT_get(in_hFile);
465 var resume_node = std.event.Loop.ResumeNode.Basic{
466 .base = .{
467 .id = .Basic,
468 .handle = @frame(),
469 .overlapped = OVERLAPPED{
470 .Internal = 0,
471 .InternalHigh = 0,
472 .DUMMYUNIONNAME = .{
473 .DUMMYSTRUCTNAME = .{
474 .Offset = @as(u32, @truncate(off)),
475 .OffsetHigh = @as(u32, @truncate(off >> 32)),
476 },
454pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64) ReadFileError!usize {
455 while (true) {
456 const want_read_count: DWORD = @min(@as(DWORD, maxInt(DWORD)), buffer.len);
457 var amt_read: DWORD = undefined;
458 var overlapped_data: OVERLAPPED = undefined;
459 const overlapped: ?*OVERLAPPED = if (offset) |off| blk: {
460 overlapped_data = .{
461 .Internal = 0,
462 .InternalHigh = 0,
463 .DUMMYUNIONNAME = .{
464 .DUMMYSTRUCTNAME = .{
465 .Offset = @as(u32, @truncate(off)),
466 .OffsetHigh = @as(u32, @truncate(off >> 32)),
477467 },
478 .hEvent = null,
479468 },
480 },
481 };
482 loop.beginOneEvent();
483 suspend {
484 // TODO handle buffer bigger than DWORD can hold
485 _ = kernel32.ReadFile(in_hFile, buffer.ptr, @as(DWORD, @intCast(buffer.len)), null, &resume_node.base.overlapped);
486 }
487 var bytes_transferred: DWORD = undefined;
488 if (kernel32.GetOverlappedResult(in_hFile, &resume_node.base.overlapped, &bytes_transferred, FALSE) == 0) {
469 .hEvent = null,
470 };
471 break :blk &overlapped_data;
472 } else null;
473 if (kernel32.ReadFile(in_hFile, buffer.ptr, want_read_count, &amt_read, overlapped) == 0) {
489474 switch (kernel32.GetLastError()) {
490475 .IO_PENDING => unreachable,
491 .OPERATION_ABORTED => return error.OperationAborted,
492 .BROKEN_PIPE => return error.BrokenPipe,
476 .OPERATION_ABORTED => continue,
477 .BROKEN_PIPE => return 0,
478 .HANDLE_EOF => return 0,
493479 .NETNAME_DELETED => return error.NetNameDeleted,
494 .HANDLE_EOF => return @as(usize, bytes_transferred),
495480 else => |err| return unexpectedError(err),
496481 }
497482 }
498 if (offset == null) {
499 // TODO make setting the file position non-blocking
500 const new_off = off + bytes_transferred;
501 try SetFilePointerEx_CURRENT(in_hFile, @as(i64, @bitCast(new_off)));
502 }
503 return @as(usize, bytes_transferred);
504 } else {
505 while (true) {
506 const want_read_count: DWORD = @min(@as(DWORD, maxInt(DWORD)), buffer.len);
507 var amt_read: DWORD = undefined;
508 var overlapped_data: OVERLAPPED = undefined;
509 const overlapped: ?*OVERLAPPED = if (offset) |off| blk: {
510 overlapped_data = .{
511 .Internal = 0,
512 .InternalHigh = 0,
513 .DUMMYUNIONNAME = .{
514 .DUMMYSTRUCTNAME = .{
515 .Offset = @as(u32, @truncate(off)),
516 .OffsetHigh = @as(u32, @truncate(off >> 32)),
517 },
518 },
519 .hEvent = null,
520 };
521 break :blk &overlapped_data;
522 } else null;
523 if (kernel32.ReadFile(in_hFile, buffer.ptr, want_read_count, &amt_read, overlapped) == 0) {
524 switch (kernel32.GetLastError()) {
525 .IO_PENDING => unreachable,
526 .OPERATION_ABORTED => continue,
527 .BROKEN_PIPE => return 0,
528 .HANDLE_EOF => return 0,
529 .NETNAME_DELETED => return error.NetNameDeleted,
530 else => |err| return unexpectedError(err),
531 }
532 }
533 return amt_read;
534 }
483 return amt_read;
535484 }
536485}
537486
......@@ -550,85 +499,38 @@ pub fn WriteFile(
550499 handle: HANDLE,
551500 bytes: []const u8,
552501 offset: ?u64,
553 io_mode: std.io.ModeOverride,
554502) WriteFileError!usize {
555 if (std.event.Loop.instance != null and io_mode != .blocking) {
556 const loop = std.event.Loop.instance.?;
557 // TODO make getting the file position non-blocking
558 const off = if (offset) |o| o else try SetFilePointerEx_CURRENT_get(handle);
559 var resume_node = std.event.Loop.ResumeNode.Basic{
560 .base = .{
561 .id = .Basic,
562 .handle = @frame(),
563 .overlapped = OVERLAPPED{
564 .Internal = 0,
565 .InternalHigh = 0,
566 .DUMMYUNIONNAME = .{
567 .DUMMYSTRUCTNAME = .{
568 .Offset = @as(u32, @truncate(off)),
569 .OffsetHigh = @as(u32, @truncate(off >> 32)),
570 },
571 },
572 .hEvent = null,
503 var bytes_written: DWORD = undefined;
504 var overlapped_data: OVERLAPPED = undefined;
505 const overlapped: ?*OVERLAPPED = if (offset) |off| blk: {
506 overlapped_data = .{
507 .Internal = 0,
508 .InternalHigh = 0,
509 .DUMMYUNIONNAME = .{
510 .DUMMYSTRUCTNAME = .{
511 .Offset = @as(u32, @truncate(off)),
512 .OffsetHigh = @as(u32, @truncate(off >> 32)),
573513 },
574514 },
515 .hEvent = null,
575516 };
576 loop.beginOneEvent();
577 suspend {
578 const adjusted_len = math.cast(DWORD, bytes.len) orelse maxInt(DWORD);
579 _ = kernel32.WriteFile(handle, bytes.ptr, adjusted_len, null, &resume_node.base.overlapped);
580 }
581 var bytes_transferred: DWORD = undefined;
582 if (kernel32.GetOverlappedResult(handle, &resume_node.base.overlapped, &bytes_transferred, FALSE) == 0) {
583 switch (kernel32.GetLastError()) {
584 .IO_PENDING => unreachable,
585 .INVALID_USER_BUFFER => return error.SystemResources,
586 .NOT_ENOUGH_MEMORY => return error.SystemResources,
587 .OPERATION_ABORTED => return error.OperationAborted,
588 .NOT_ENOUGH_QUOTA => return error.SystemResources,
589 .BROKEN_PIPE => return error.BrokenPipe,
590 else => |err| return unexpectedError(err),
591 }
592 }
593 if (offset == null) {
594 // TODO make setting the file position non-blocking
595 const new_off = off + bytes_transferred;
596 try SetFilePointerEx_CURRENT(handle, @as(i64, @bitCast(new_off)));
597 }
598 return bytes_transferred;
599 } else {
600 var bytes_written: DWORD = undefined;
601 var overlapped_data: OVERLAPPED = undefined;
602 const overlapped: ?*OVERLAPPED = if (offset) |off| blk: {
603 overlapped_data = .{
604 .Internal = 0,
605 .InternalHigh = 0,
606 .DUMMYUNIONNAME = .{
607 .DUMMYSTRUCTNAME = .{
608 .Offset = @as(u32, @truncate(off)),
609 .OffsetHigh = @as(u32, @truncate(off >> 32)),
610 },
611 },
612 .hEvent = null,
613 };
614 break :blk &overlapped_data;
615 } else null;
616 const adjusted_len = math.cast(u32, bytes.len) orelse maxInt(u32);
617 if (kernel32.WriteFile(handle, bytes.ptr, adjusted_len, &bytes_written, overlapped) == 0) {
618 switch (kernel32.GetLastError()) {
619 .INVALID_USER_BUFFER => return error.SystemResources,
620 .NOT_ENOUGH_MEMORY => return error.SystemResources,
621 .OPERATION_ABORTED => return error.OperationAborted,
622 .NOT_ENOUGH_QUOTA => return error.SystemResources,
623 .IO_PENDING => unreachable,
624 .BROKEN_PIPE => return error.BrokenPipe,
625 .INVALID_HANDLE => return error.NotOpenForWriting,
626 .LOCK_VIOLATION => return error.LockViolation,
627 else => |err| return unexpectedError(err),
628 }
517 break :blk &overlapped_data;
518 } else null;
519 const adjusted_len = math.cast(u32, bytes.len) orelse maxInt(u32);
520 if (kernel32.WriteFile(handle, bytes.ptr, adjusted_len, &bytes_written, overlapped) == 0) {
521 switch (kernel32.GetLastError()) {
522 .INVALID_USER_BUFFER => return error.SystemResources,
523 .NOT_ENOUGH_MEMORY => return error.SystemResources,
524 .OPERATION_ABORTED => return error.OperationAborted,
525 .NOT_ENOUGH_QUOTA => return error.SystemResources,
526 .IO_PENDING => unreachable,
527 .BROKEN_PIPE => return error.BrokenPipe,
528 .INVALID_HANDLE => return error.NotOpenForWriting,
529 .LOCK_VIOLATION => return error.LockViolation,
530 else => |err| return unexpectedError(err),
629531 }
630 return bytes_written;
631532 }
533 return bytes_written;
632534}
633535
634536pub const SetCurrentDirectoryError = error{
......@@ -732,7 +634,6 @@ pub fn CreateSymbolicLink(
732634 .access_mask = SYNCHRONIZE | GENERIC_READ | GENERIC_WRITE,
733635 .dir = dir,
734636 .creation = FILE_CREATE,
735 .io_mode = .blocking,
736637 .filter = if (is_directory) .dir_only else .file_only,
737638 }) catch |err| switch (err) {
738639 error.IsDir => return error.PathAlreadyExists,
......@@ -1256,7 +1157,6 @@ pub fn GetFinalPathNameByHandle(
12561157 .access_mask = SYNCHRONIZE,
12571158 .share_access = FILE_SHARE_READ | FILE_SHARE_WRITE,
12581159 .creation = FILE_OPEN,
1259 .io_mode = .blocking,
12601160 }) catch |err| switch (err) {
12611161 error.IsDir => unreachable,
12621162 error.NotDir => unreachable,
lib/std/pdb.zig+1-1
......@@ -513,7 +513,7 @@ pub const Pdb = struct {
513513 };
514514
515515 pub fn init(allocator: mem.Allocator, path: []const u8) !Pdb {
516 const file = try fs.cwd().openFile(path, .{ .intended_io_mode = .blocking });
516 const file = try fs.cwd().openFile(path, .{});
517517 errdefer file.close();
518518
519519 return Pdb{
lib/std/time.zig-5
......@@ -9,11 +9,6 @@ pub const epoch = @import("time/epoch.zig");
99
1010/// Spurious wakeups are possible and no precision of timing is guaranteed.
1111pub fn sleep(nanoseconds: u64) void {
12 // TODO: opting out of async sleeping?
13 if (std.io.is_async) {
14 return std.event.Loop.instance.?.sleep(nanoseconds);
15 }
16
1712 if (builtin.os.tag == .windows) {
1813 const big_ms_from_ns = nanoseconds / ns_per_ms;
1914 const ms = math.cast(os.windows.DWORD, big_ms_from_ns) orelse math.maxInt(os.windows.DWORD);
lib/std/zig/Server.zig+2-7
......@@ -38,8 +38,6 @@ pub const Message = struct {
3838 /// Trailing:
3939 /// * name: [tests_len]u32
4040 /// - null-terminated string_bytes index
41 /// * async_frame_len: [tests_len]u32,
42 /// - 0 means not async
4341 /// * expected_panic_msg: [tests_len]u32,
4442 /// - null-terminated string_bytes index
4543 /// - 0 means does not expect pani
......@@ -210,7 +208,6 @@ pub fn serveErrorBundle(s: *Server, error_bundle: std.zig.ErrorBundle) !void {
210208
211209pub const TestMetadata = struct {
212210 names: []u32,
213 async_frame_sizes: []u32,
214211 expected_panic_msgs: []u32,
215212 string_bytes: []const u8,
216213};
......@@ -220,17 +217,16 @@ pub fn serveTestMetadata(s: *Server, test_metadata: TestMetadata) !void {
220217 .tests_len = bswap(@as(u32, @intCast(test_metadata.names.len))),
221218 .string_bytes_len = bswap(@as(u32, @intCast(test_metadata.string_bytes.len))),
222219 };
220 const trailing = 2;
223221 const bytes_len = @sizeOf(OutMessage.TestMetadata) +
224 3 * 4 * test_metadata.names.len + test_metadata.string_bytes.len;
222 trailing * @sizeOf(u32) * test_metadata.names.len + test_metadata.string_bytes.len;
225223
226224 if (need_bswap) {
227225 bswap_u32_array(test_metadata.names);
228 bswap_u32_array(test_metadata.async_frame_sizes);
229226 bswap_u32_array(test_metadata.expected_panic_msgs);
230227 }
231228 defer if (need_bswap) {
232229 bswap_u32_array(test_metadata.names);
233 bswap_u32_array(test_metadata.async_frame_sizes);
234230 bswap_u32_array(test_metadata.expected_panic_msgs);
235231 };
236232
......@@ -241,7 +237,6 @@ pub fn serveTestMetadata(s: *Server, test_metadata: TestMetadata) !void {
241237 std.mem.asBytes(&header),
242238 // TODO: implement @ptrCast between slices changing the length
243239 std.mem.sliceAsBytes(test_metadata.names),
244 std.mem.sliceAsBytes(test_metadata.async_frame_sizes),
245240 std.mem.sliceAsBytes(test_metadata.expected_panic_msgs),
246241 test_metadata.string_bytes,
247242 });
lib/std/zig/system/linux.zig+1-1
......@@ -328,7 +328,7 @@ fn CpuinfoParser(comptime impl: anytype) type {
328328}
329329
330330pub fn detectNativeCpuAndFeatures() ?Target.Cpu {
331 var f = fs.openFileAbsolute("/proc/cpuinfo", .{ .intended_io_mode = .blocking }) catch |err| switch (err) {
331 var f = fs.openFileAbsolute("/proc/cpuinfo", .{}) catch |err| switch (err) {
332332 else => return null,
333333 };
334334 defer f.close();
lib/test_runner.zig+2-26
......@@ -4,7 +4,6 @@ const io = std.io;
44const builtin = @import("builtin");
55
66pub const std_options = .{
7 .io_mode = builtin.test_io_mode,
87 .logFn = log,
98};
109
......@@ -65,24 +64,19 @@ fn mainServer() !void {
6564 const test_fns = builtin.test_functions;
6665 const names = try std.testing.allocator.alloc(u32, test_fns.len);
6766 defer std.testing.allocator.free(names);
68 const async_frame_sizes = try std.testing.allocator.alloc(u32, test_fns.len);
69 defer std.testing.allocator.free(async_frame_sizes);
7067 const expected_panic_msgs = try std.testing.allocator.alloc(u32, test_fns.len);
7168 defer std.testing.allocator.free(expected_panic_msgs);
7269
73 for (test_fns, names, async_frame_sizes, expected_panic_msgs) |test_fn, *name, *async_frame_size, *expected_panic_msg| {
70 for (test_fns, names, expected_panic_msgs) |test_fn, *name, *expected_panic_msg| {
7471 name.* = @as(u32, @intCast(string_bytes.items.len));
7572 try string_bytes.ensureUnusedCapacity(std.testing.allocator, test_fn.name.len + 1);
7673 string_bytes.appendSliceAssumeCapacity(test_fn.name);
7774 string_bytes.appendAssumeCapacity(0);
78
79 async_frame_size.* = @as(u32, @intCast(test_fn.async_frame_size orelse 0));
8075 expected_panic_msg.* = 0;
8176 }
8277
8378 try server.serveTestMetadata(.{
8479 .names = names,
85 .async_frame_sizes = async_frame_sizes,
8680 .expected_panic_msgs = expected_panic_msgs,
8781 .string_bytes = string_bytes.items,
8882 });
......@@ -93,8 +87,6 @@ fn mainServer() !void {
9387 log_err_count = 0;
9488 const index = try server.receiveBody_u32();
9589 const test_fn = builtin.test_functions[index];
96 if (test_fn.async_frame_size != null)
97 @panic("TODO test runner implement async tests");
9890 var fail = false;
9991 var skip = false;
10092 var leak = false;
......@@ -163,23 +155,7 @@ fn mainTerminal() void {
163155 if (!have_tty) {
164156 std.debug.print("{d}/{d} {s}... ", .{ i + 1, test_fn_list.len, test_fn.name });
165157 }
166 const result = if (test_fn.async_frame_size) |size| switch (std.options.io_mode) {
167 .evented => blk: {
168 if (async_frame_buffer.len < size) {
169 std.heap.page_allocator.free(async_frame_buffer);
170 async_frame_buffer = std.heap.page_allocator.alignedAlloc(u8, std.Target.stack_align, size) catch @panic("out of memory");
171 }
172 const casted_fn = @as(fn () callconv(.Async) anyerror!void, @ptrCast(test_fn.func));
173 break :blk await @asyncCall(async_frame_buffer, {}, casted_fn, .{});
174 },
175 .blocking => {
176 skip_count += 1;
177 test_node.end();
178 progress.log("SKIP (async test)\n", .{});
179 continue;
180 },
181 } else test_fn.func();
182 if (result) |_| {
158 if (test_fn.func()) |_| {
183159 ok_count += 1;
184160 test_node.end();
185161 if (!have_tty) std.debug.print("OK\n", .{});
src/Builtin.zig-12
......@@ -3,7 +3,6 @@ zig_backend: std.builtin.CompilerBackend,
33output_mode: std.builtin.OutputMode,
44link_mode: std.builtin.LinkMode,
55is_test: bool,
6test_evented_io: bool,
76single_threaded: bool,
87link_libc: bool,
98link_libcpp: bool,
......@@ -222,17 +221,6 @@ pub fn append(opts: @This(), buffer: *std.ArrayList(u8)) Allocator.Error!void {
222221 \\pub var test_functions: []const std.builtin.TestFn = undefined; // overwritten later
223222 \\
224223 );
225 if (opts.test_evented_io) {
226 try buffer.appendSlice(
227 \\pub const test_io_mode = .evented;
228 \\
229 );
230 } else {
231 try buffer.appendSlice(
232 \\pub const test_io_mode = .blocking;
233 \\
234 );
235 }
236224 }
237225}
238226
src/Compilation.zig-2
......@@ -1607,7 +1607,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
16071607 hash.add(options.config.use_lib_llvm);
16081608 hash.add(options.config.dll_export_fns);
16091609 hash.add(options.config.is_test);
1610 hash.add(options.config.test_evented_io);
16111610 hash.addOptionalBytes(options.test_filter);
16121611 hash.addOptionalBytes(options.test_name_prefix);
16131612 hash.add(options.skip_linker_dependencies);
......@@ -2471,7 +2470,6 @@ fn addNonIncrementalStuffToCacheManifest(
24712470 try addModuleTableToCacheHash(gpa, arena, &man.hash, mod.root_mod, mod.main_mod, .{ .files = man });
24722471
24732472 // Synchronize with other matching comments: ZigOnlyHashStuff
2474 man.hash.add(comp.config.test_evented_io);
24752473 man.hash.addOptionalBytes(comp.test_filter);
24762474 man.hash.addOptionalBytes(comp.test_name_prefix);
24772475 man.hash.add(comp.skip_linker_dependencies);
src/Compilation/Config.zig-3
......@@ -54,7 +54,6 @@ import_memory: bool,
5454export_memory: bool,
5555shared_memory: bool,
5656is_test: bool,
57test_evented_io: bool,
5857debug_format: DebugFormat,
5958root_strip: bool,
6059root_error_tracing: bool,
......@@ -104,7 +103,6 @@ pub const Options = struct {
104103 import_memory: ?bool = null,
105104 export_memory: ?bool = null,
106105 shared_memory: ?bool = null,
107 test_evented_io: bool = false,
108106 debug_format: ?DebugFormat = null,
109107 dll_export_fns: ?bool = null,
110108 rdynamic: ?bool = null,
......@@ -477,7 +475,6 @@ pub fn resolve(options: Options) ResolveError!Config {
477475 .output_mode = options.output_mode,
478476 .have_zcu = options.have_zcu,
479477 .is_test = options.is_test,
480 .test_evented_io = options.test_evented_io,
481478 .link_mode = link_mode,
482479 .link_libc = link_libc,
483480 .link_libcpp = link_libcpp,
src/Module.zig-6
......@@ -5237,10 +5237,6 @@ pub fn populateTestFunctions(
52375237 }
52385238 const decl = mod.declPtr(decl_index);
52395239 const test_fn_ty = decl.ty.slicePtrFieldType(mod).childType(mod);
5240 const null_usize = try mod.intern(.{ .opt = .{
5241 .ty = try mod.intern(.{ .opt_type = .usize_type }),
5242 .val = .none,
5243 } });
52445240
52455241 const array_decl_index = d: {
52465242 // Add mod.test_functions to an array decl then make the test_functions
......@@ -5289,8 +5285,6 @@ pub fn populateTestFunctions(
52895285 } }),
52905286 .addr = .{ .decl = test_decl_index },
52915287 } }),
5292 // async_frame_size
5293 null_usize,
52945288 };
52955289 test_fn_val.* = try mod.intern(.{ .aggregate = .{
52965290 .ty = test_fn_ty.toIntern(),
src/Package/Module.zig-1
......@@ -349,7 +349,6 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module {
349349 .output_mode = options.global.output_mode,
350350 .link_mode = options.global.link_mode,
351351 .is_test = options.global.is_test,
352 .test_evented_io = options.global.test_evented_io,
353352 .single_threaded = single_threaded,
354353 .link_libc = options.global.link_libc,
355354 .link_libcpp = options.global.link_libcpp,
src/main.zig-2
......@@ -1322,8 +1322,6 @@ fn buildOutputType(
13221322 create_module.each_lib_rpath = false;
13231323 } else if (mem.eql(u8, arg, "--test-cmd-bin")) {
13241324 try test_exec_args.append(null);
1325 } else if (mem.eql(u8, arg, "--test-evented-io")) {
1326 create_module.opts.test_evented_io = true;
13271325 } else if (mem.eql(u8, arg, "--test-no-exec")) {
13281326 test_no_exec = true;
13291327 } else if (mem.eql(u8, arg, "-ftime-report")) {