authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-08 22:37:39-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-29 06:20:49-07:00
log750b1431bf34b238bd991b2ee3b50e81ff20b667
treee99550f5c65f7b014baf7d9b56332c774daca3da
parenteadfefa002b642d1b9173fa7d9a281a70a61e233

std: fix some Io compilation errors


6 files changed, 16 insertions(+), 9 deletions(-)

lib/std/Io/Dir.zig+1-1
...@@ -263,6 +263,6 @@ pub const StatPathError = File.OpenError || File.StatError;...@@ -263,6 +263,6 @@ pub const StatPathError = File.OpenError || File.StatError;
263/// * On Windows, `sub_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).263/// * On Windows, `sub_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
264/// * On WASI, `sub_path` should be encoded as valid UTF-8.264/// * On WASI, `sub_path` should be encoded as valid UTF-8.
265/// * On other platforms, `sub_path` is an opaque sequence of bytes with no particular encoding.265/// * On other platforms, `sub_path` is an opaque sequence of bytes with no particular encoding.
266pub fn statPath(dir: Dir, io: Io, sub_path: []const u8) StatPathError!File.Stat {266pub fn statPath(dir: Dir, io: Io, sub_path: []const u8) StatPathError!Stat {
267 return io.vtable.dirStatPath(io.userdata, dir, sub_path);267 return io.vtable.dirStatPath(io.userdata, dir, sub_path);
268}268}
lib/std/fs/test.zig+1-1
...@@ -1928,7 +1928,7 @@ test "'.' and '..' in fs.Dir functions" {...@@ -1928,7 +1928,7 @@ test "'.' and '..' in fs.Dir functions" {
1928 try ctx.dir.writeFile(.{ .sub_path = update_path, .data = "something" });1928 try ctx.dir.writeFile(.{ .sub_path = update_path, .data = "something" });
1929 var dir = ctx.dir.adaptToNewApi();1929 var dir = ctx.dir.adaptToNewApi();
1930 const prev_status = try dir.updateFile(io, file_path, dir, update_path, .{});1930 const prev_status = try dir.updateFile(io, file_path, dir, update_path, .{});
1931 try testing.expectEqual(fs.Dir.PrevStatus.stale, prev_status);1931 try testing.expectEqual(Io.Dir.PrevStatus.stale, prev_status);
19321932
1933 try ctx.dir.deleteDir(subdir_path);1933 try ctx.dir.deleteDir(subdir_path);
1934 }1934 }
lib/std/http/Client.zig+9-4
...@@ -300,7 +300,7 @@ pub const Connection = struct {...@@ -300,7 +300,7 @@ pub const Connection = struct {
300 remote_host: HostName,300 remote_host: HostName,
301 port: u16,301 port: u16,
302 stream: Io.net.Stream,302 stream: Io.net.Stream,
303 ) error{ OutOfMemory, TlsInitializationFailed }!*Tls {303 ) !*Tls {
304 const io = client.io;304 const io = client.io;
305 const gpa = client.allocator;305 const gpa = client.allocator;
306 const alloc_len = allocLen(client, remote_host.bytes.len);306 const alloc_len = allocLen(client, remote_host.bytes.len);
...@@ -320,7 +320,7 @@ pub const Connection = struct {...@@ -320,7 +320,7 @@ pub const Connection = struct {
320 const tls: *Tls = @ptrCast(base);320 const tls: *Tls = @ptrCast(base);
321 var random_buffer: [176]u8 = undefined;321 var random_buffer: [176]u8 = undefined;
322 std.crypto.random.bytes(&random_buffer);322 std.crypto.random.bytes(&random_buffer);
323 const now_ts = if (Io.Clock.real.now(io)) |ts| ts.toSeconds() else |_| return error.TlsInitializationFailed;323 const now_ts = if (Io.Clock.real.now(io)) |ts| ts.toSeconds() else |err| return err;
324 tls.* = .{324 tls.* = .{
325 .connection = .{325 .connection = .{
326 .client = client,326 .client = client,
...@@ -349,7 +349,11 @@ pub const Connection = struct {...@@ -349,7 +349,11 @@ pub const Connection = struct {
349 // the content length which is used to detect truncation attacks.349 // the content length which is used to detect truncation attacks.
350 .allow_truncation_attacks = true,350 .allow_truncation_attacks = true,
351 },351 },
352 ) catch return error.TlsInitializationFailed,352 ) catch |err| switch (err) {
353 error.WriteFailed => return tls.connection.stream_writer.err.?,
354 error.ReadFailed => return tls.connection.stream_reader.err.?,
355 else => |e| return e,
356 },
353 };357 };
354 return tls;358 return tls;
355 }359 }
...@@ -1446,7 +1450,8 @@ pub fn connectTcpOptions(client: *Client, options: ConnectTcpOptions) ConnectTcp...@@ -1446,7 +1450,8 @@ pub fn connectTcpOptions(client: *Client, options: ConnectTcpOptions) ConnectTcp
1446 const tc = Connection.Tls.create(client, proxied_host, proxied_port, stream) catch |err| switch (err) {1450 const tc = Connection.Tls.create(client, proxied_host, proxied_port, stream) catch |err| switch (err) {
1447 error.OutOfMemory => |e| return e,1451 error.OutOfMemory => |e| return e,
1448 error.Unexpected => |e| return e,1452 error.Unexpected => |e| return e,
1449 error.UnsupportedClock => return error.TlsInitializationFailed,1453 error.Canceled => |e| return e,
1454 else => return error.TlsInitializationFailed,
1450 };1455 };
1451 client.connection_pool.addUsed(&tc.connection);1456 client.connection_pool.addUsed(&tc.connection);
1452 return &tc.connection;1457 return &tc.connection;
lib/std/os/linux/IoUring.zig+2-2
...@@ -2459,12 +2459,12 @@ test "timeout (after a relative time)" {...@@ -2459,12 +2459,12 @@ test "timeout (after a relative time)" {
2459 const margin = 5;2459 const margin = 5;
2460 const ts: linux.kernel_timespec = .{ .sec = 0, .nsec = ms * 1000000 };2460 const ts: linux.kernel_timespec = .{ .sec = 0, .nsec = ms * 1000000 };
24612461
2462 const started = try std.Io.Timestamp.now(io, .awake);2462 const started = try std.Io.Clock.awake.now(io);
2463 const sqe = try ring.timeout(0x55555555, &ts, 0, 0);2463 const sqe = try ring.timeout(0x55555555, &ts, 0, 0);
2464 try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe.opcode);2464 try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe.opcode);
2465 try testing.expectEqual(@as(u32, 1), try ring.submit());2465 try testing.expectEqual(@as(u32, 1), try ring.submit());
2466 const cqe = try ring.copy_cqe();2466 const cqe = try ring.copy_cqe();
2467 const stopped = try std.Io.Timestamp.now(io, .awake);2467 const stopped = try std.Io.Clock.awake.now(io);
24682468
2469 try testing.expectEqual(linux.io_uring_cqe{2469 try testing.expectEqual(linux.io_uring_cqe{
2470 .user_data = 0x55555555,2470 .user_data = 0x55555555,
lib/std/posix.zig+2
...@@ -357,6 +357,7 @@ pub const FChmodAtError = FChmodError || error{...@@ -357,6 +357,7 @@ pub const FChmodAtError = FChmodError || error{
357 ProcessFdQuotaExceeded,357 ProcessFdQuotaExceeded,
358 /// The procfs fallback was used but the system exceeded it open file limit.358 /// The procfs fallback was used but the system exceeded it open file limit.
359 SystemFdQuotaExceeded,359 SystemFdQuotaExceeded,
360 Canceled,
360};361};
361362
362/// Changes the `mode` of `path` relative to the directory referred to by363/// Changes the `mode` of `path` relative to the directory referred to by
...@@ -487,6 +488,7 @@ fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr...@@ -487,6 +488,7 @@ fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr
487 error.NameTooLong => unreachable,488 error.NameTooLong => unreachable,
488 error.FileNotFound => unreachable,489 error.FileNotFound => unreachable,
489 error.InvalidUtf8 => unreachable,490 error.InvalidUtf8 => unreachable,
491 error.Canceled => return error.Canceled,
490 else => |e| return e,492 else => |e| return e,
491 };493 };
492 if ((stat.mode & S.IFMT) == S.IFLNK)494 if ((stat.mode & S.IFMT) == S.IFLNK)
lib/std/time.zig+1-1
...@@ -204,7 +204,7 @@ test Timer {...@@ -204,7 +204,7 @@ test Timer {
204204
205 var timer = try Timer.start();205 var timer = try Timer.start();
206206
207 try std.Io.Duration.sleep(.fromMilliseconds(10), io);207 try std.Io.Clock.Duration.sleep(.{ .clock = .awake, .raw = .fromMilliseconds(10) }, io);
208 const time_0 = timer.read();208 const time_0 = timer.read();
209 try testing.expect(time_0 > 0);209 try testing.expect(time_0 > 0);
210210