mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
std: fix some Io compilation errors
This commit is contained in:
parent
eadfefa002
commit
750b1431bf
@ -263,6 +263,6 @@ pub const StatPathError = File.OpenError || File.StatError;
|
|||||||
/// * On Windows, `sub_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
|
/// * On Windows, `sub_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
|
||||||
/// * On WASI, `sub_path` should be encoded as valid UTF-8.
|
/// * On WASI, `sub_path` should be encoded as valid UTF-8.
|
||||||
/// * On other platforms, `sub_path` is an opaque sequence of bytes with no particular encoding.
|
/// * On other platforms, `sub_path` is an opaque sequence of bytes with no particular encoding.
|
||||||
pub fn statPath(dir: Dir, io: Io, sub_path: []const u8) StatPathError!File.Stat {
|
pub fn statPath(dir: Dir, io: Io, sub_path: []const u8) StatPathError!Stat {
|
||||||
return io.vtable.dirStatPath(io.userdata, dir, sub_path);
|
return io.vtable.dirStatPath(io.userdata, dir, sub_path);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1928,7 +1928,7 @@ test "'.' and '..' in fs.Dir functions" {
|
|||||||
try ctx.dir.writeFile(.{ .sub_path = update_path, .data = "something" });
|
try ctx.dir.writeFile(.{ .sub_path = update_path, .data = "something" });
|
||||||
var dir = ctx.dir.adaptToNewApi();
|
var dir = ctx.dir.adaptToNewApi();
|
||||||
const prev_status = try dir.updateFile(io, file_path, dir, update_path, .{});
|
const prev_status = try dir.updateFile(io, file_path, dir, update_path, .{});
|
||||||
try testing.expectEqual(fs.Dir.PrevStatus.stale, prev_status);
|
try testing.expectEqual(Io.Dir.PrevStatus.stale, prev_status);
|
||||||
|
|
||||||
try ctx.dir.deleteDir(subdir_path);
|
try ctx.dir.deleteDir(subdir_path);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -300,7 +300,7 @@ pub const Connection = struct {
|
|||||||
remote_host: HostName,
|
remote_host: HostName,
|
||||||
port: u16,
|
port: u16,
|
||||||
stream: Io.net.Stream,
|
stream: Io.net.Stream,
|
||||||
) error{ OutOfMemory, TlsInitializationFailed }!*Tls {
|
) !*Tls {
|
||||||
const io = client.io;
|
const io = client.io;
|
||||||
const gpa = client.allocator;
|
const gpa = client.allocator;
|
||||||
const alloc_len = allocLen(client, remote_host.bytes.len);
|
const alloc_len = allocLen(client, remote_host.bytes.len);
|
||||||
@ -320,7 +320,7 @@ pub const Connection = struct {
|
|||||||
const tls: *Tls = @ptrCast(base);
|
const tls: *Tls = @ptrCast(base);
|
||||||
var random_buffer: [176]u8 = undefined;
|
var random_buffer: [176]u8 = undefined;
|
||||||
std.crypto.random.bytes(&random_buffer);
|
std.crypto.random.bytes(&random_buffer);
|
||||||
const now_ts = if (Io.Clock.real.now(io)) |ts| ts.toSeconds() else |_| return error.TlsInitializationFailed;
|
const now_ts = if (Io.Clock.real.now(io)) |ts| ts.toSeconds() else |err| return err;
|
||||||
tls.* = .{
|
tls.* = .{
|
||||||
.connection = .{
|
.connection = .{
|
||||||
.client = client,
|
.client = client,
|
||||||
@ -349,7 +349,11 @@ pub const Connection = struct {
|
|||||||
// the content length which is used to detect truncation attacks.
|
// the content length which is used to detect truncation attacks.
|
||||||
.allow_truncation_attacks = true,
|
.allow_truncation_attacks = true,
|
||||||
},
|
},
|
||||||
) catch return error.TlsInitializationFailed,
|
) catch |err| switch (err) {
|
||||||
|
error.WriteFailed => return tls.connection.stream_writer.err.?,
|
||||||
|
error.ReadFailed => return tls.connection.stream_reader.err.?,
|
||||||
|
else => |e| return e,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
return tls;
|
return tls;
|
||||||
}
|
}
|
||||||
@ -1446,7 +1450,8 @@ pub fn connectTcpOptions(client: *Client, options: ConnectTcpOptions) ConnectTcp
|
|||||||
const tc = Connection.Tls.create(client, proxied_host, proxied_port, stream) catch |err| switch (err) {
|
const tc = Connection.Tls.create(client, proxied_host, proxied_port, stream) catch |err| switch (err) {
|
||||||
error.OutOfMemory => |e| return e,
|
error.OutOfMemory => |e| return e,
|
||||||
error.Unexpected => |e| return e,
|
error.Unexpected => |e| return e,
|
||||||
error.UnsupportedClock => return error.TlsInitializationFailed,
|
error.Canceled => |e| return e,
|
||||||
|
else => return error.TlsInitializationFailed,
|
||||||
};
|
};
|
||||||
client.connection_pool.addUsed(&tc.connection);
|
client.connection_pool.addUsed(&tc.connection);
|
||||||
return &tc.connection;
|
return &tc.connection;
|
||||||
|
|||||||
@ -2459,12 +2459,12 @@ test "timeout (after a relative time)" {
|
|||||||
const margin = 5;
|
const margin = 5;
|
||||||
const ts: linux.kernel_timespec = .{ .sec = 0, .nsec = ms * 1000000 };
|
const ts: linux.kernel_timespec = .{ .sec = 0, .nsec = ms * 1000000 };
|
||||||
|
|
||||||
const started = try std.Io.Timestamp.now(io, .awake);
|
const started = try std.Io.Clock.awake.now(io);
|
||||||
const sqe = try ring.timeout(0x55555555, &ts, 0, 0);
|
const sqe = try ring.timeout(0x55555555, &ts, 0, 0);
|
||||||
try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe.opcode);
|
try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe.opcode);
|
||||||
try testing.expectEqual(@as(u32, 1), try ring.submit());
|
try testing.expectEqual(@as(u32, 1), try ring.submit());
|
||||||
const cqe = try ring.copy_cqe();
|
const cqe = try ring.copy_cqe();
|
||||||
const stopped = try std.Io.Timestamp.now(io, .awake);
|
const stopped = try std.Io.Clock.awake.now(io);
|
||||||
|
|
||||||
try testing.expectEqual(linux.io_uring_cqe{
|
try testing.expectEqual(linux.io_uring_cqe{
|
||||||
.user_data = 0x55555555,
|
.user_data = 0x55555555,
|
||||||
|
|||||||
@ -357,6 +357,7 @@ pub const FChmodAtError = FChmodError || error{
|
|||||||
ProcessFdQuotaExceeded,
|
ProcessFdQuotaExceeded,
|
||||||
/// The procfs fallback was used but the system exceeded it open file limit.
|
/// The procfs fallback was used but the system exceeded it open file limit.
|
||||||
SystemFdQuotaExceeded,
|
SystemFdQuotaExceeded,
|
||||||
|
Canceled,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Changes the `mode` of `path` relative to the directory referred to by
|
/// 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
|
|||||||
error.NameTooLong => unreachable,
|
error.NameTooLong => unreachable,
|
||||||
error.FileNotFound => unreachable,
|
error.FileNotFound => unreachable,
|
||||||
error.InvalidUtf8 => unreachable,
|
error.InvalidUtf8 => unreachable,
|
||||||
|
error.Canceled => return error.Canceled,
|
||||||
else => |e| return e,
|
else => |e| return e,
|
||||||
};
|
};
|
||||||
if ((stat.mode & S.IFMT) == S.IFLNK)
|
if ((stat.mode & S.IFMT) == S.IFLNK)
|
||||||
|
|||||||
@ -204,7 +204,7 @@ test Timer {
|
|||||||
|
|
||||||
var timer = try Timer.start();
|
var timer = try Timer.start();
|
||||||
|
|
||||||
try std.Io.Duration.sleep(.fromMilliseconds(10), io);
|
try std.Io.Clock.Duration.sleep(.{ .clock = .awake, .raw = .fromMilliseconds(10) }, io);
|
||||||
const time_0 = timer.read();
|
const time_0 = timer.read();
|
||||||
try testing.expect(time_0 > 0);
|
try testing.expect(time_0 > 0);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user