diff --git a/lib/compiler/objcopy.zig b/lib/compiler/objcopy.zig index 7772b8f290..ff69c4b287 100644 --- a/lib/compiler/objcopy.zig +++ b/lib/compiler/objcopy.zig @@ -1285,7 +1285,7 @@ const ElfFileHelper = struct { for (consolidated.items) |cmd| { switch (cmd) { .write_data => |data| { - var iovec = [_]std.posix.iovec_const{.{ .iov_base = data.data.ptr, .iov_len = data.data.len }}; + var iovec = [_]std.posix.iovec_const{.{ .base = data.data.ptr, .len = data.data.len }}; try out_file.pwritevAll(&iovec, data.out_offset); }, .copy_range => |range| { diff --git a/lib/std/crypto/tls/Client.zig b/lib/std/crypto/tls/Client.zig index 682c1ffe0e..9a09b21353 100644 --- a/lib/std/crypto/tls/Client.zig +++ b/lib/std/crypto/tls/Client.zig @@ -217,12 +217,12 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In { var iovecs = [_]std.posix.iovec_const{ .{ - .iov_base = &plaintext_header, - .iov_len = plaintext_header.len, + .base = &plaintext_header, + .len = plaintext_header.len, }, .{ - .iov_base = host.ptr, - .iov_len = host.len, + .base = host.ptr, + .len = host.len, }, }; try stream.writevAll(&iovecs); @@ -678,8 +678,8 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In const both_msgs = client_change_cipher_spec_msg ++ finished_msg; var both_msgs_vec = [_]std.posix.iovec_const{.{ - .iov_base = &both_msgs, - .iov_len = both_msgs.len, + .base = &both_msgs, + .len = both_msgs.len, }}; try stream.writevAll(&both_msgs_vec); @@ -776,8 +776,8 @@ pub fn writeEnd(c: *Client, stream: anytype, bytes: []const u8, end: bool) !usiz var total_amt: usize = 0; while (true) { var amt = try stream.writev(iovecs_buf[i..iovec_end]); - while (amt >= iovecs_buf[i].iov_len) { - const encrypted_amt = iovecs_buf[i].iov_len; + while (amt >= iovecs_buf[i].len) { + const encrypted_amt = iovecs_buf[i].len; total_amt += encrypted_amt - overhead_len; amt -= encrypted_amt; i += 1; @@ -789,8 +789,8 @@ pub fn writeEnd(c: *Client, stream: anytype, bytes: []const u8, end: bool) !usiz // not sent; otherwise the caller would not know to retry the call. if (amt == 0 and (!end or i < iovec_end - 1)) return total_amt; } - iovecs_buf[i].iov_base += amt; - iovecs_buf[i].iov_len -= amt; + iovecs_buf[i].base += amt; + iovecs_buf[i].len -= amt; } } @@ -864,8 +864,8 @@ fn prepareCiphertextRecord( const record = ciphertext_buf[record_start..ciphertext_end]; iovecs[iovec_end] = .{ - .iov_base = record.ptr, - .iov_len = record.len, + .base = record.ptr, + .len = record.len, }; iovec_end += 1; } @@ -885,7 +885,7 @@ pub fn eof(c: Client) bool { /// If the number read is less than `len` it means the stream reached the end. /// Reaching the end of the stream is not an error condition. pub fn readAtLeast(c: *Client, stream: anytype, buffer: []u8, len: usize) !usize { - var iovecs = [1]std.posix.iovec{.{ .iov_base = buffer.ptr, .iov_len = buffer.len }}; + var iovecs = [1]std.posix.iovec{.{ .base = buffer.ptr, .len = buffer.len }}; return readvAtLeast(c, stream, &iovecs, len); } @@ -928,12 +928,12 @@ pub fn readvAtLeast(c: *Client, stream: anytype, iovecs: []std.posix.iovec, len: var amt = try c.readvAdvanced(stream, iovecs[vec_i..]); off_i += amt; if (c.eof() or off_i >= len) return off_i; - while (amt >= iovecs[vec_i].iov_len) { - amt -= iovecs[vec_i].iov_len; + while (amt >= iovecs[vec_i].len) { + amt -= iovecs[vec_i].len; vec_i += 1; } - iovecs[vec_i].iov_base += amt; - iovecs[vec_i].iov_len -= amt; + iovecs[vec_i].base += amt; + iovecs[vec_i].len -= amt; } } @@ -1000,12 +1000,12 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.posix.iove var ask_iovecs_buf: [2]std.posix.iovec = .{ .{ - .iov_base = first_iov.ptr, - .iov_len = first_iov.len, + .base = first_iov.ptr, + .len = first_iov.len, }, .{ - .iov_base = &in_stack_buffer, - .iov_len = in_stack_buffer.len, + .base = &in_stack_buffer, + .len = in_stack_buffer.len, }, }; @@ -1364,12 +1364,12 @@ const VecPut = struct { var bytes_i: usize = 0; while (true) { const v = vp.iovecs[vp.idx]; - const dest = v.iov_base[vp.off..v.iov_len]; + const dest = v.base[vp.off..v.len]; const src = bytes[bytes_i..][0..@min(dest.len, bytes.len - bytes_i)]; @memcpy(dest[0..src.len], src); bytes_i += src.len; vp.off += src.len; - if (vp.off >= v.iov_len) { + if (vp.off >= v.len) { vp.off = 0; vp.idx += 1; if (vp.idx >= vp.iovecs.len) { @@ -1388,7 +1388,7 @@ const VecPut = struct { fn peek(vp: VecPut) []u8 { if (vp.idx >= vp.iovecs.len) return &.{}; const v = vp.iovecs[vp.idx]; - return v.iov_base[vp.off..v.iov_len]; + return v.base[vp.off..v.len]; } // After writing to the result of peek(), one can call next() to @@ -1396,7 +1396,7 @@ const VecPut = struct { fn next(vp: *VecPut, len: usize) void { vp.total += len; vp.off += len; - if (vp.off >= vp.iovecs[vp.idx].iov_len) { + if (vp.off >= vp.iovecs[vp.idx].len) { vp.off = 0; vp.idx += 1; } @@ -1405,9 +1405,9 @@ const VecPut = struct { fn freeSize(vp: VecPut) usize { if (vp.idx >= vp.iovecs.len) return 0; var total: usize = 0; - total += vp.iovecs[vp.idx].iov_len - vp.off; + total += vp.iovecs[vp.idx].len - vp.off; if (vp.idx + 1 >= vp.iovecs.len) return total; - for (vp.iovecs[vp.idx + 1 ..]) |v| total += v.iov_len; + for (vp.iovecs[vp.idx + 1 ..]) |v| total += v.len; return total; } }; @@ -1416,11 +1416,11 @@ const VecPut = struct { fn limitVecs(iovecs: []std.posix.iovec, len: usize) []std.posix.iovec { var bytes_left: usize = len; for (iovecs, 0..) |*iovec, vec_i| { - if (bytes_left <= iovec.iov_len) { - iovec.iov_len = bytes_left; + if (bytes_left <= iovec.len) { + iovec.len = bytes_left; return iovecs[0 .. vec_i + 1]; } - bytes_left -= iovec.iov_len; + bytes_left -= iovec.len; } return iovecs; } diff --git a/lib/std/fs/File.zig b/lib/std/fs/File.zig index 0b5058c5fe..42a2ae7132 100644 --- a/lib/std/fs/File.zig +++ b/lib/std/fs/File.zig @@ -1138,7 +1138,7 @@ pub fn readv(self: File, iovecs: []const posix.iovec) ReadError!usize { // TODO improve this to use ReadFileScatter if (iovecs.len == 0) return @as(usize, 0); const first = iovecs[0]; - return windows.ReadFile(self.handle, first.iov_base[0..first.iov_len], null); + return windows.ReadFile(self.handle, first.base[0..first.len], null); } return posix.readv(self.handle, iovecs); @@ -1153,7 +1153,7 @@ pub fn readv(self: File, iovecs: []const posix.iovec) ReadError!usize { /// reads from the underlying OS layer. /// * The OS layer expects pointer addresses to be inside the application's address space /// even if the length is zero. Meanwhile, in Zig, slices may have undefined pointer -/// addresses when the length is zero. So this function modifies the iov_base fields +/// addresses when the length is zero. So this function modifies the base fields /// when the length is zero. /// /// Related open issue: https://github.com/ziglang/zig/issues/7699 @@ -1165,7 +1165,7 @@ pub fn readvAll(self: File, iovecs: []posix.iovec) ReadError!usize { // addresses outside the application's address space. var garbage: [1]u8 = undefined; for (iovecs) |*v| { - if (v.iov_len == 0) v.iov_base = &garbage; + if (v.len == 0) v.base = &garbage; } var i: usize = 0; @@ -1174,15 +1174,15 @@ pub fn readvAll(self: File, iovecs: []posix.iovec) ReadError!usize { var amt = try self.readv(iovecs[i..]); var eof = amt == 0; off += amt; - while (amt >= iovecs[i].iov_len) { - amt -= iovecs[i].iov_len; + while (amt >= iovecs[i].len) { + amt -= iovecs[i].len; i += 1; if (i >= iovecs.len) return off; eof = false; } if (eof) return off; - iovecs[i].iov_base += amt; - iovecs[i].iov_len -= amt; + iovecs[i].base += amt; + iovecs[i].len -= amt; } } @@ -1194,7 +1194,7 @@ pub fn preadv(self: File, iovecs: []const posix.iovec, offset: u64) PReadError!u // TODO improve this to use ReadFileScatter if (iovecs.len == 0) return @as(usize, 0); const first = iovecs[0]; - return windows.ReadFile(self.handle, first.iov_base[0..first.iov_len], offset); + return windows.ReadFile(self.handle, first.base[0..first.len], offset); } return posix.preadv(self.handle, iovecs, offset); @@ -1217,15 +1217,15 @@ pub fn preadvAll(self: File, iovecs: []posix.iovec, offset: u64) PReadError!usiz var amt = try self.preadv(iovecs[i..], offset + off); var eof = amt == 0; off += amt; - while (amt >= iovecs[i].iov_len) { - amt -= iovecs[i].iov_len; + while (amt >= iovecs[i].len) { + amt -= iovecs[i].len; i += 1; if (i >= iovecs.len) return off; eof = false; } if (eof) return off; - iovecs[i].iov_base += amt; - iovecs[i].iov_len -= amt; + iovecs[i].base += amt; + iovecs[i].len -= amt; } } @@ -1273,7 +1273,7 @@ pub fn writev(self: File, iovecs: []const posix.iovec_const) WriteError!usize { // TODO improve this to use WriteFileScatter if (iovecs.len == 0) return @as(usize, 0); const first = iovecs[0]; - return windows.WriteFile(self.handle, first.iov_base[0..first.iov_len], null); + return windows.WriteFile(self.handle, first.base[0..first.len], null); } return posix.writev(self.handle, iovecs); @@ -1284,7 +1284,7 @@ pub fn writev(self: File, iovecs: []const posix.iovec_const) WriteError!usize { /// writes from the underlying OS layer. /// * The OS layer expects pointer addresses to be inside the application's address space /// even if the length is zero. Meanwhile, in Zig, slices may have undefined pointer -/// addresses when the length is zero. So this function modifies the iov_base fields +/// addresses when the length is zero. So this function modifies the base fields /// when the length is zero. /// See https://github.com/ziglang/zig/issues/7699 /// See equivalent function: `std.net.Stream.writevAll`. @@ -1296,19 +1296,19 @@ pub fn writevAll(self: File, iovecs: []posix.iovec_const) WriteError!void { // addresses outside the application's address space. var garbage: [1]u8 = undefined; for (iovecs) |*v| { - if (v.iov_len == 0) v.iov_base = &garbage; + if (v.len == 0) v.base = &garbage; } var i: usize = 0; while (true) { var amt = try self.writev(iovecs[i..]); - while (amt >= iovecs[i].iov_len) { - amt -= iovecs[i].iov_len; + while (amt >= iovecs[i].len) { + amt -= iovecs[i].len; i += 1; if (i >= iovecs.len) return; } - iovecs[i].iov_base += amt; - iovecs[i].iov_len -= amt; + iovecs[i].base += amt; + iovecs[i].len -= amt; } } @@ -1320,7 +1320,7 @@ pub fn pwritev(self: File, iovecs: []posix.iovec_const, offset: u64) PWriteError // TODO improve this to use WriteFileScatter if (iovecs.len == 0) return @as(usize, 0); const first = iovecs[0]; - return windows.WriteFile(self.handle, first.iov_base[0..first.iov_len], offset); + return windows.WriteFile(self.handle, first.base[0..first.len], offset); } return posix.pwritev(self.handle, iovecs, offset); @@ -1339,13 +1339,13 @@ pub fn pwritevAll(self: File, iovecs: []posix.iovec_const, offset: u64) PWriteEr while (true) { var amt = try self.pwritev(iovecs[i..], offset + off); off += amt; - while (amt >= iovecs[i].iov_len) { - amt -= iovecs[i].iov_len; + while (amt >= iovecs[i].len) { + amt -= iovecs[i].len; i += 1; if (i >= iovecs.len) return; } - iovecs[i].iov_base += amt; - iovecs[i].iov_len -= amt; + iovecs[i].base += amt; + iovecs[i].len -= amt; } } @@ -1456,13 +1456,13 @@ fn writeFileAllSendfile(self: File, in_file: File, args: WriteFileOptions) posix var i: usize = 0; while (i < headers.len) { amt = try posix.sendfile(out_fd, in_fd, offset, count, headers[i..], trls, flags); - while (amt >= headers[i].iov_len) { - amt -= headers[i].iov_len; + while (amt >= headers[i].len) { + amt -= headers[i].len; i += 1; if (i >= headers.len) break :hdrs; } - headers[i].iov_base += amt; - headers[i].iov_len -= amt; + headers[i].base += amt; + headers[i].len -= amt; } } if (count == 0) { @@ -1482,13 +1482,13 @@ fn writeFileAllSendfile(self: File, in_file: File, args: WriteFileOptions) posix } var i: usize = 0; while (i < trailers.len) { - while (amt >= trailers[i].iov_len) { - amt -= trailers[i].iov_len; + while (amt >= trailers[i].len) { + amt -= trailers[i].len; i += 1; if (i >= trailers.len) return; } - trailers[i].iov_base += amt; - trailers[i].iov_len -= amt; + trailers[i].base += amt; + trailers[i].len -= amt; amt = try posix.writev(self.handle, trailers[i..]); } } diff --git a/lib/std/fs/test.zig b/lib/std/fs/test.zig index 488632b34c..50dd8df65e 100644 --- a/lib/std/fs/test.zig +++ b/lib/std/fs/test.zig @@ -1276,22 +1276,22 @@ test "writev, readv" { var buf2: [line2.len]u8 = undefined; var write_vecs = [_]posix.iovec_const{ .{ - .iov_base = line1, - .iov_len = line1.len, + .base = line1, + .len = line1.len, }, .{ - .iov_base = line2, - .iov_len = line2.len, + .base = line2, + .len = line2.len, }, }; var read_vecs = [_]posix.iovec{ .{ - .iov_base = &buf2, - .iov_len = buf2.len, + .base = &buf2, + .len = buf2.len, }, .{ - .iov_base = &buf1, - .iov_len = buf1.len, + .base = &buf1, + .len = buf1.len, }, }; @@ -1318,22 +1318,22 @@ test "pwritev, preadv" { var buf2: [line2.len]u8 = undefined; var write_vecs = [_]posix.iovec_const{ .{ - .iov_base = line1, - .iov_len = line1.len, + .base = line1, + .len = line1.len, }, .{ - .iov_base = line2, - .iov_len = line2.len, + .base = line2, + .len = line2.len, }, }; var read_vecs = [_]posix.iovec{ .{ - .iov_base = &buf2, - .iov_len = buf2.len, + .base = &buf2, + .len = buf2.len, }, .{ - .iov_base = &buf1, - .iov_len = buf1.len, + .base = &buf1, + .len = buf1.len, }, }; @@ -1378,12 +1378,12 @@ test "sendfile" { const line2 = "second line\n"; var vecs = [_]posix.iovec_const{ .{ - .iov_base = line1, - .iov_len = line1.len, + .base = line1, + .len = line1.len, }, .{ - .iov_base = line2, - .iov_len = line2.len, + .base = line2, + .len = line2.len, }, }; @@ -1401,20 +1401,20 @@ test "sendfile" { const trailer2 = "second trailer\n"; var hdtr = [_]posix.iovec_const{ .{ - .iov_base = header1, - .iov_len = header1.len, + .base = header1, + .len = header1.len, }, .{ - .iov_base = header2, - .iov_len = header2.len, + .base = header2, + .len = header2.len, }, .{ - .iov_base = trailer1, - .iov_len = trailer1.len, + .base = trailer1, + .len = trailer1.len, }, .{ - .iov_base = trailer2, - .iov_len = trailer2.len, + .base = trailer2, + .len = trailer2.len, }, }; diff --git a/lib/std/http/Client.zig b/lib/std/http/Client.zig index 9da1e428f6..6e95995ee0 100644 --- a/lib/std/http/Client.zig +++ b/lib/std/http/Client.zig @@ -253,7 +253,7 @@ pub const Connection = struct { if (conn.read_end != conn.read_start) return; var iovecs = [1]std.posix.iovec{ - .{ .iov_base = &conn.read_buf, .iov_len = conn.read_buf.len }, + .{ .base = &conn.read_buf, .len = conn.read_buf.len }, }; const nread = try conn.readvDirect(&iovecs); if (nread == 0) return error.EndOfStream; @@ -289,8 +289,8 @@ pub const Connection = struct { } var iovecs = [2]std.posix.iovec{ - .{ .iov_base = buffer.ptr, .iov_len = buffer.len }, - .{ .iov_base = &conn.read_buf, .iov_len = conn.read_buf.len }, + .{ .base = buffer.ptr, .len = buffer.len }, + .{ .base = &conn.read_buf, .len = conn.read_buf.len }, }; const nread = try conn.readvDirect(&iovecs); diff --git a/lib/std/http/Server.zig b/lib/std/http/Server.zig index 5290241b6e..25d3e44253 100644 --- a/lib/std/http/Server.zig +++ b/lib/std/http/Server.zig @@ -442,42 +442,42 @@ pub const Request = struct { var iovecs_len: usize = 0; iovecs[iovecs_len] = .{ - .iov_base = h.items.ptr, - .iov_len = h.items.len, + .base = h.items.ptr, + .len = h.items.len, }; iovecs_len += 1; for (options.extra_headers) |header| { iovecs[iovecs_len] = .{ - .iov_base = header.name.ptr, - .iov_len = header.name.len, + .base = header.name.ptr, + .len = header.name.len, }; iovecs_len += 1; iovecs[iovecs_len] = .{ - .iov_base = ": ", - .iov_len = 2, + .base = ": ", + .len = 2, }; iovecs_len += 1; if (header.value.len != 0) { iovecs[iovecs_len] = .{ - .iov_base = header.value.ptr, - .iov_len = header.value.len, + .base = header.value.ptr, + .len = header.value.len, }; iovecs_len += 1; } iovecs[iovecs_len] = .{ - .iov_base = "\r\n", - .iov_len = 2, + .base = "\r\n", + .len = 2, }; iovecs_len += 1; } iovecs[iovecs_len] = .{ - .iov_base = "\r\n", - .iov_len = 2, + .base = "\r\n", + .len = 2, }; iovecs_len += 1; @@ -492,33 +492,33 @@ pub const Request = struct { ) catch unreachable; iovecs[iovecs_len] = .{ - .iov_base = chunk_header.ptr, - .iov_len = chunk_header.len, + .base = chunk_header.ptr, + .len = chunk_header.len, }; iovecs_len += 1; iovecs[iovecs_len] = .{ - .iov_base = content.ptr, - .iov_len = content.len, + .base = content.ptr, + .len = content.len, }; iovecs_len += 1; iovecs[iovecs_len] = .{ - .iov_base = "\r\n", - .iov_len = 2, + .base = "\r\n", + .len = 2, }; iovecs_len += 1; } iovecs[iovecs_len] = .{ - .iov_base = "0\r\n\r\n", - .iov_len = 5, + .base = "0\r\n\r\n", + .len = 5, }; iovecs_len += 1; } else if (content.len > 0) { iovecs[iovecs_len] = .{ - .iov_base = content.ptr, - .iov_len = content.len, + .base = content.ptr, + .len = content.len, }; iovecs_len += 1; } @@ -912,12 +912,12 @@ pub const Response = struct { const send_buffer_len = r.send_buffer_end - r.send_buffer_start; var iovecs: [2]std.posix.iovec_const = .{ .{ - .iov_base = r.send_buffer.ptr + r.send_buffer_start, - .iov_len = send_buffer_len, + .base = r.send_buffer.ptr + r.send_buffer_start, + .len = send_buffer_len, }, .{ - .iov_base = bytes.ptr, - .iov_len = bytes.len, + .base = bytes.ptr, + .len = bytes.len, }, }; const n = try r.stream.writev(&iovecs); @@ -959,24 +959,24 @@ pub const Response = struct { var iovecs: [5]std.posix.iovec_const = .{ .{ - .iov_base = r.send_buffer.ptr + r.send_buffer_start, - .iov_len = send_buffer_len - r.chunk_len, + .base = r.send_buffer.ptr + r.send_buffer_start, + .len = send_buffer_len - r.chunk_len, }, .{ - .iov_base = chunk_header.ptr, - .iov_len = chunk_header.len, + .base = chunk_header.ptr, + .len = chunk_header.len, }, .{ - .iov_base = r.send_buffer.ptr + r.send_buffer_end - r.chunk_len, - .iov_len = r.chunk_len, + .base = r.send_buffer.ptr + r.send_buffer_end - r.chunk_len, + .len = r.chunk_len, }, .{ - .iov_base = bytes.ptr, - .iov_len = bytes.len, + .base = bytes.ptr, + .len = bytes.len, }, .{ - .iov_base = "\r\n", - .iov_len = 2, + .base = "\r\n", + .len = 2, }, }; // TODO make this writev instead of writevAll, which involves @@ -1042,69 +1042,69 @@ pub const Response = struct { var iovecs_len: usize = 0; iovecs[iovecs_len] = .{ - .iov_base = http_headers.ptr, - .iov_len = http_headers.len, + .base = http_headers.ptr, + .len = http_headers.len, }; iovecs_len += 1; if (r.chunk_len > 0) { iovecs[iovecs_len] = .{ - .iov_base = chunk_header.ptr, - .iov_len = chunk_header.len, + .base = chunk_header.ptr, + .len = chunk_header.len, }; iovecs_len += 1; iovecs[iovecs_len] = .{ - .iov_base = r.send_buffer.ptr + r.send_buffer_end - r.chunk_len, - .iov_len = r.chunk_len, + .base = r.send_buffer.ptr + r.send_buffer_end - r.chunk_len, + .len = r.chunk_len, }; iovecs_len += 1; iovecs[iovecs_len] = .{ - .iov_base = "\r\n", - .iov_len = 2, + .base = "\r\n", + .len = 2, }; iovecs_len += 1; } if (end_trailers) |trailers| { iovecs[iovecs_len] = .{ - .iov_base = "0\r\n", - .iov_len = 3, + .base = "0\r\n", + .len = 3, }; iovecs_len += 1; for (trailers) |trailer| { iovecs[iovecs_len] = .{ - .iov_base = trailer.name.ptr, - .iov_len = trailer.name.len, + .base = trailer.name.ptr, + .len = trailer.name.len, }; iovecs_len += 1; iovecs[iovecs_len] = .{ - .iov_base = ": ", - .iov_len = 2, + .base = ": ", + .len = 2, }; iovecs_len += 1; if (trailer.value.len != 0) { iovecs[iovecs_len] = .{ - .iov_base = trailer.value.ptr, - .iov_len = trailer.value.len, + .base = trailer.value.ptr, + .len = trailer.value.len, }; iovecs_len += 1; } iovecs[iovecs_len] = .{ - .iov_base = "\r\n", - .iov_len = 2, + .base = "\r\n", + .len = 2, }; iovecs_len += 1; } iovecs[iovecs_len] = .{ - .iov_base = "\r\n", - .iov_len = 2, + .base = "\r\n", + .len = 2, }; iovecs_len += 1; } diff --git a/lib/std/net.zig b/lib/std/net.zig index 3126bfa93b..25030fe7aa 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -1826,7 +1826,7 @@ pub const Stream = struct { // TODO improve this to use ReadFileScatter if (iovecs.len == 0) return @as(usize, 0); const first = iovecs[0]; - return windows.ReadFile(s.handle, first.iov_base[0..first.iov_len], null); + return windows.ReadFile(s.handle, first.base[0..first.len], null); } return posix.readv(s.handle, iovecs); @@ -1889,13 +1889,13 @@ pub const Stream = struct { var i: usize = 0; while (true) { var amt = try self.writev(iovecs[i..]); - while (amt >= iovecs[i].iov_len) { - amt -= iovecs[i].iov_len; + while (amt >= iovecs[i].len) { + amt -= iovecs[i].len; i += 1; if (i >= iovecs.len) return; } - iovecs[i].iov_base += amt; - iovecs[i].iov_len -= amt; + iovecs[i].base += amt; + iovecs[i].len -= amt; } } }; diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 93581b1107..eac60e6ace 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -1644,7 +1644,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize var size: i32 = 0; const msg_iovlen = @as(usize, @intCast(msg.msg_hdr.msg_iovlen)); // kernel side this is treated as unsigned for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov| { - if (iov.iov_len > std.math.maxInt(i32) or @addWithOverflow(size, @as(i32, @intCast(iov.iov_len)))[1] != 0) { + if (iov.len > std.math.maxInt(i32) or @addWithOverflow(size, @as(i32, @intCast(iov.len)))[1] != 0) { // batch-send all messages up to the current message if (next_unsent < i) { const batch_size = i - next_unsent; @@ -1660,7 +1660,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize next_unsent = i + 1; break; } - size += iov.iov_len; + size += iov.len; } } if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG.EOR) diff --git a/lib/std/os/linux/IoUring.zig b/lib/std/os/linux/IoUring.zig index 263321bb65..e6aecfe7b4 100644 --- a/lib/std/os/linux/IoUring.zig +++ b/lib/std/os/linux/IoUring.zig @@ -1766,7 +1766,7 @@ test "readv" { try ring.register_files(registered_fds[0..]); var buffer = [_]u8{42} ** 128; - var iovecs = [_]posix.iovec{posix.iovec{ .iov_base = &buffer, .iov_len = buffer.len }}; + var iovecs = [_]posix.iovec{posix.iovec{ .base = &buffer, .len = buffer.len }}; const sqe = try ring.read(0xcccccccc, fd_index, .{ .iovecs = iovecs[0..] }, 0); try testing.expectEqual(linux.IORING_OP.READV, sqe.opcode); sqe.flags |= linux.IOSQE_FIXED_FILE; @@ -1803,11 +1803,11 @@ test "writev/fsync/readv" { const buffer_write = [_]u8{42} ** 128; const iovecs_write = [_]posix.iovec_const{ - posix.iovec_const{ .iov_base = &buffer_write, .iov_len = buffer_write.len }, + posix.iovec_const{ .base = &buffer_write, .len = buffer_write.len }, }; var buffer_read = [_]u8{0} ** 128; var iovecs_read = [_]posix.iovec{ - posix.iovec{ .iov_base = &buffer_read, .iov_len = buffer_read.len }, + posix.iovec{ .base = &buffer_read, .len = buffer_read.len }, }; const sqe_writev = try ring.writev(0xdddddddd, fd, iovecs_write[0..], 17); @@ -1995,8 +1995,8 @@ test "write_fixed/read_fixed" { raw_buffers[0][0.."foobar".len].* = "foobar".*; var buffers = [2]posix.iovec{ - .{ .iov_base = &raw_buffers[0], .iov_len = raw_buffers[0].len }, - .{ .iov_base = &raw_buffers[1], .iov_len = raw_buffers[1].len }, + .{ .base = &raw_buffers[0], .len = raw_buffers[0].len }, + .{ .base = &raw_buffers[1], .len = raw_buffers[1].len }, }; ring.register_buffers(&buffers) catch |err| switch (err) { error.SystemResources => { @@ -2022,18 +2022,18 @@ test "write_fixed/read_fixed" { try testing.expectEqual(linux.io_uring_cqe{ .user_data = 0x45454545, - .res = @as(i32, @intCast(buffers[0].iov_len)), + .res = @as(i32, @intCast(buffers[0].len)), .flags = 0, }, cqe_write); try testing.expectEqual(linux.io_uring_cqe{ .user_data = 0x12121212, - .res = @as(i32, @intCast(buffers[1].iov_len)), + .res = @as(i32, @intCast(buffers[1].len)), .flags = 0, }, cqe_read); - try testing.expectEqualSlices(u8, "\x00\x00\x00", buffers[1].iov_base[0..3]); - try testing.expectEqualSlices(u8, "foobar", buffers[1].iov_base[3..9]); - try testing.expectEqualSlices(u8, "zz", buffers[1].iov_base[9..11]); + try testing.expectEqualSlices(u8, "\x00\x00\x00", buffers[1].base[0..3]); + try testing.expectEqualSlices(u8, "foobar", buffers[1].base[3..9]); + try testing.expectEqualSlices(u8, "zz", buffers[1].base[9..11]); } test "openat" { @@ -2189,7 +2189,7 @@ test "sendmsg/recvmsg" { const buffer_send = [_]u8{42} ** 128; const iovecs_send = [_]posix.iovec_const{ - posix.iovec_const{ .iov_base = &buffer_send, .iov_len = buffer_send.len }, + posix.iovec_const{ .base = &buffer_send, .len = buffer_send.len }, }; const msg_send: posix.msghdr_const = .{ .name = &address_server.any, @@ -2207,7 +2207,7 @@ test "sendmsg/recvmsg" { var buffer_recv = [_]u8{0} ** 128; var iovecs_recv = [_]posix.iovec{ - posix.iovec{ .iov_base = &buffer_recv, .iov_len = buffer_recv.len }, + posix.iovec{ .base = &buffer_recv, .len = buffer_recv.len }, }; const addr = [_]u8{0} ** 4; var address_recv = net.Address.initIp4(addr, 0); diff --git a/lib/std/os/linux/io_uring_sqe.zig b/lib/std/os/linux/io_uring_sqe.zig index 7306cf8eed..71be7a1f99 100644 --- a/lib/std/os/linux/io_uring_sqe.zig +++ b/lib/std/os/linux/io_uring_sqe.zig @@ -117,12 +117,12 @@ pub const io_uring_sqe = extern struct { } pub fn prep_read_fixed(sqe: *linux.io_uring_sqe, fd: linux.fd_t, buffer: *std.posix.iovec, offset: u64, buffer_index: u16) void { - sqe.prep_rw(.READ_FIXED, fd, @intFromPtr(buffer.iov_base), buffer.iov_len, offset); + sqe.prep_rw(.READ_FIXED, fd, @intFromPtr(buffer.base), buffer.len, offset); sqe.buf_index = buffer_index; } pub fn prep_write_fixed(sqe: *linux.io_uring_sqe, fd: linux.fd_t, buffer: *std.posix.iovec, offset: u64, buffer_index: u16) void { - sqe.prep_rw(.WRITE_FIXED, fd, @intFromPtr(buffer.iov_base), buffer.iov_len, offset); + sqe.prep_rw(.WRITE_FIXED, fd, @intFromPtr(buffer.base), buffer.len, offset); sqe.buf_index = buffer_index; } diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 9b6a38eb45..73634ab1c7 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -173,13 +173,13 @@ pub const W_OK = system.W_OK; pub const X_OK = system.X_OK; pub const iovec = extern struct { - iov_base: [*]u8, - iov_len: usize, + base: [*]u8, + len: usize, }; pub const iovec_const = extern struct { - iov_base: [*]const u8, - iov_len: usize, + base: [*]const u8, + len: usize, }; pub const ACCMODE = enum(u2) { @@ -796,8 +796,8 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { } if (native_os == .wasi and !builtin.link_libc) { const iovs = [1]iovec{iovec{ - .iov_base = buf.ptr, - .iov_len = buf.len, + .base = buf.ptr, + .len = buf.len, }}; var nread: usize = undefined; @@ -865,7 +865,7 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize { // TODO improve this to use ReadFileScatter if (iov.len == 0) return 0; const first = iov[0]; - return read(fd, first.iov_base[0..first.iov_len]); + return read(fd, first.base[0..first.len]); } if (native_os == .wasi and !builtin.link_libc) { var nread: usize = undefined; @@ -932,8 +932,8 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { } if (native_os == .wasi and !builtin.link_libc) { const iovs = [1]iovec{iovec{ - .iov_base = buf.ptr, - .iov_len = buf.len, + .base = buf.ptr, + .len = buf.len, }}; var nread: usize = undefined; @@ -1077,7 +1077,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { // So we simply read into the first vector only. if (iov.len == 0) return 0; const first = iov[0]; - return pread(fd, first.iov_base[0..first.iov_len], offset); + return pread(fd, first.base[0..first.len], offset); } if (native_os == .wasi and !builtin.link_libc) { var nread: usize = undefined; @@ -1186,8 +1186,8 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { if (native_os == .wasi and !builtin.link_libc) { const ciovs = [_]iovec_const{iovec_const{ - .iov_base = bytes.ptr, - .iov_len = bytes.len, + .base = bytes.ptr, + .len = bytes.len, }}; var nwritten: usize = undefined; switch (wasi.fd_write(fd, &ciovs, ciovs.len, &nwritten)) { @@ -1263,7 +1263,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize { // TODO improve this to use WriteFileScatter if (iov.len == 0) return 0; const first = iov[0]; - return write(fd, first.iov_base[0..first.iov_len]); + return write(fd, first.base[0..first.len]); } if (native_os == .wasi and !builtin.link_libc) { var nwritten: usize = undefined; @@ -1340,8 +1340,8 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { } if (native_os == .wasi and !builtin.link_libc) { const ciovs = [1]iovec_const{iovec_const{ - .iov_base = bytes.ptr, - .iov_len = bytes.len, + .base = bytes.ptr, + .len = bytes.len, }}; var nwritten: usize = undefined; @@ -1432,7 +1432,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz // So we simply write the first vector only. if (iov.len == 0) return 0; const first = iov[0]; - return pwrite(fd, first.iov_base[0..first.iov_len], offset); + return pwrite(fd, first.base[0..first.len], offset); } if (native_os == .wasi and !builtin.link_libc) { var nwritten: usize = undefined; @@ -6361,7 +6361,7 @@ pub fn sendfile( fn count_iovec_bytes(iovs: []const iovec_const) usize { var count: usize = 0; for (iovs) |iov| { - count += iov.iov_len; + count += iov.len; } return count; } diff --git a/lib/std/posix/test.zig b/lib/std/posix/test.zig index 1847ceb8a1..45cbd36f2e 100644 --- a/lib/std/posix/test.zig +++ b/lib/std/posix/test.zig @@ -939,7 +939,7 @@ test "writev longer than IOV_MAX" { var file = try tmp.dir.createFile("pwritev", .{}); defer file.close(); - const iovecs = [_]posix.iovec_const{.{ .iov_base = "a", .iov_len = 1 }} ** (posix.IOV_MAX + 1); + const iovecs = [_]posix.iovec_const{.{ .base = "a", .len = 1 }} ** (posix.IOV_MAX + 1); const amt = try file.writev(&iovecs); try testing.expectEqual(@as(usize, posix.IOV_MAX), amt); } diff --git a/lib/std/zig/Server.zig b/lib/std/zig/Server.zig index bf5fdba231..10e14a55fc 100644 --- a/lib/std/zig/Server.zig +++ b/lib/std/zig/Server.zig @@ -149,13 +149,13 @@ pub fn serveMessage( var iovecs: [10]std.posix.iovec_const = undefined; const header_le = bswap(header); iovecs[0] = .{ - .iov_base = @as([*]const u8, @ptrCast(&header_le)), - .iov_len = @sizeOf(OutMessage.Header), + .base = @as([*]const u8, @ptrCast(&header_le)), + .len = @sizeOf(OutMessage.Header), }; for (bufs, iovecs[1 .. bufs.len + 1]) |buf, *iovec| { iovec.* = .{ - .iov_base = buf.ptr, - .iov_len = buf.len, + .base = buf.ptr, + .len = buf.len, }; } try s.out.writevAll(iovecs[0 .. bufs.len + 1]); diff --git a/src/Compilation.zig b/src/Compilation.zig index 3532a9d5b5..0a6c0e2e4d 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -2811,8 +2811,8 @@ fn addBuf(bufs_list: []std.posix.iovec_const, bufs_len: *usize, buf: []const u8) const i = bufs_len.*; bufs_len.* = i + 1; bufs_list[i] = .{ - .iov_base = buf.ptr, - .iov_len = buf.len, + .base = buf.ptr, + .len = buf.len, }; } @@ -3800,8 +3800,8 @@ fn docsCopyModule(comp: *Compilation, module: *Package.Module, name: []const u8, }; var header_and_trailer: [2]std.posix.iovec_const = .{ - .{ .iov_base = header_bytes.ptr, .iov_len = header_bytes.len }, - .{ .iov_base = padding.ptr, .iov_len = padding.len }, + .{ .base = header_bytes.ptr, .len = header_bytes.len }, + .{ .base = padding.ptr, .len = padding.len }, }; try tar_file.writeFileAll(file, .{ diff --git a/src/Module.zig b/src/Module.zig index 004ee89e91..146e4e92a0 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -2336,24 +2336,24 @@ pub fn astGenFile(mod: *Module, file: *File) !void { }; var iovecs = [_]std.posix.iovec_const{ .{ - .iov_base = @as([*]const u8, @ptrCast(&header)), - .iov_len = @sizeOf(Zir.Header), + .base = @as([*]const u8, @ptrCast(&header)), + .len = @sizeOf(Zir.Header), }, .{ - .iov_base = @as([*]const u8, @ptrCast(file.zir.instructions.items(.tag).ptr)), - .iov_len = file.zir.instructions.len, + .base = @as([*]const u8, @ptrCast(file.zir.instructions.items(.tag).ptr)), + .len = file.zir.instructions.len, }, .{ - .iov_base = data_ptr, - .iov_len = file.zir.instructions.len * 8, + .base = data_ptr, + .len = file.zir.instructions.len * 8, }, .{ - .iov_base = file.zir.string_bytes.ptr, - .iov_len = file.zir.string_bytes.len, + .base = file.zir.string_bytes.ptr, + .len = file.zir.string_bytes.len, }, .{ - .iov_base = @as([*]const u8, @ptrCast(file.zir.extra.ptr)), - .iov_len = file.zir.extra.len * 4, + .base = @as([*]const u8, @ptrCast(file.zir.extra.ptr)), + .len = file.zir.extra.len * 4, }, }; cache_file.writevAll(&iovecs) catch |err| { @@ -2424,20 +2424,20 @@ fn loadZirCacheBody(gpa: Allocator, header: Zir.Header, cache_file: std.fs.File) var iovecs = [_]std.posix.iovec{ .{ - .iov_base = @as([*]u8, @ptrCast(zir.instructions.items(.tag).ptr)), - .iov_len = header.instructions_len, + .base = @as([*]u8, @ptrCast(zir.instructions.items(.tag).ptr)), + .len = header.instructions_len, }, .{ - .iov_base = data_ptr, - .iov_len = header.instructions_len * 8, + .base = data_ptr, + .len = header.instructions_len * 8, }, .{ - .iov_base = zir.string_bytes.ptr, - .iov_len = header.string_bytes_len, + .base = zir.string_bytes.ptr, + .len = header.string_bytes_len, }, .{ - .iov_base = @as([*]u8, @ptrCast(zir.extra.ptr)), - .iov_len = header.extra_len * 4, + .base = @as([*]u8, @ptrCast(zir.extra.ptr)), + .len = header.extra_len * 4, }, }; const amt_read = try cache_file.readvAll(&iovecs); diff --git a/src/link/C.zig b/src/link/C.zig index 8bff6d9fce..63faf827b0 100644 --- a/src/link/C.zig +++ b/src/link/C.zig @@ -483,15 +483,15 @@ pub fn flushModule(self: *C, arena: Allocator, prog_node: *std.Progress.Node) !v } f.all_buffers.items[ctypes_index] = .{ - .iov_base = if (f.ctypes_buf.items.len > 0) f.ctypes_buf.items.ptr else "", - .iov_len = f.ctypes_buf.items.len, + .base = if (f.ctypes_buf.items.len > 0) f.ctypes_buf.items.ptr else "", + .len = f.ctypes_buf.items.len, }; f.file_size += f.ctypes_buf.items.len; const lazy_fwd_decl_len = self.lazy_fwd_decl_buf.items.len; f.all_buffers.items[lazy_index] = .{ - .iov_base = if (lazy_fwd_decl_len > 0) self.lazy_fwd_decl_buf.items.ptr else "", - .iov_len = lazy_fwd_decl_len, + .base = if (lazy_fwd_decl_len > 0) self.lazy_fwd_decl_buf.items.ptr else "", + .len = lazy_fwd_decl_len, }; f.file_size += lazy_fwd_decl_len; @@ -527,7 +527,7 @@ const Flush = struct { fn appendBufAssumeCapacity(f: *Flush, buf: []const u8) void { if (buf.len == 0) return; - f.all_buffers.appendAssumeCapacity(.{ .iov_base = buf.ptr, .iov_len = buf.len }); + f.all_buffers.appendAssumeCapacity(.{ .base = buf.ptr, .len = buf.len }); f.file_size += buf.len; } @@ -747,8 +747,8 @@ pub fn flushEmitH(zcu: *Zcu) !void { var file_size: u64 = zig_h.len; if (zig_h.len != 0) { all_buffers.appendAssumeCapacity(.{ - .iov_base = zig_h, - .iov_len = zig_h.len, + .base = zig_h, + .len = zig_h.len, }); } @@ -757,8 +757,8 @@ pub fn flushEmitH(zcu: *Zcu) !void { const buf = decl_emit_h.fwd_decl.items; if (buf.len != 0) { all_buffers.appendAssumeCapacity(.{ - .iov_base = buf.ptr, - .iov_len = buf.len, + .base = buf.ptr, + .len = buf.len, }); file_size += buf.len; } diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig index 5f82c924c7..8bfaef61db 100644 --- a/src/link/Dwarf.zig +++ b/src/link/Dwarf.zig @@ -2120,32 +2120,32 @@ fn pwriteDbgLineNops( var padding_left = prev_padding_size; if (padding_left % 2 != 0) { vecs[vec_index] = .{ - .iov_base = &three_byte_nop, - .iov_len = three_byte_nop.len, + .base = &three_byte_nop, + .len = three_byte_nop.len, }; vec_index += 1; padding_left -= three_byte_nop.len; } while (padding_left > page_of_nops.len) { vecs[vec_index] = .{ - .iov_base = &page_of_nops, - .iov_len = page_of_nops.len, + .base = &page_of_nops, + .len = page_of_nops.len, }; vec_index += 1; padding_left -= page_of_nops.len; } if (padding_left > 0) { vecs[vec_index] = .{ - .iov_base = &page_of_nops, - .iov_len = padding_left, + .base = &page_of_nops, + .len = padding_left, }; vec_index += 1; } } vecs[vec_index] = .{ - .iov_base = buf.ptr, - .iov_len = buf.len, + .base = buf.ptr, + .len = buf.len, }; if (buf.len > 0) vec_index += 1; @@ -2153,24 +2153,24 @@ fn pwriteDbgLineNops( var padding_left = next_padding_size; if (padding_left % 2 != 0) { vecs[vec_index] = .{ - .iov_base = &three_byte_nop, - .iov_len = three_byte_nop.len, + .base = &three_byte_nop, + .len = three_byte_nop.len, }; vec_index += 1; padding_left -= three_byte_nop.len; } while (padding_left > page_of_nops.len) { vecs[vec_index] = .{ - .iov_base = &page_of_nops, - .iov_len = page_of_nops.len, + .base = &page_of_nops, + .len = page_of_nops.len, }; vec_index += 1; padding_left -= page_of_nops.len; } if (padding_left > 0) { vecs[vec_index] = .{ - .iov_base = &page_of_nops, - .iov_len = padding_left, + .base = &page_of_nops, + .len = padding_left, }; vec_index += 1; } @@ -2237,24 +2237,24 @@ fn pwriteDbgInfoNops( var padding_left = prev_padding_size; while (padding_left > page_of_nops.len) { vecs[vec_index] = .{ - .iov_base = &page_of_nops, - .iov_len = page_of_nops.len, + .base = &page_of_nops, + .len = page_of_nops.len, }; vec_index += 1; padding_left -= page_of_nops.len; } if (padding_left > 0) { vecs[vec_index] = .{ - .iov_base = &page_of_nops, - .iov_len = padding_left, + .base = &page_of_nops, + .len = padding_left, }; vec_index += 1; } } vecs[vec_index] = .{ - .iov_base = buf.ptr, - .iov_len = buf.len, + .base = buf.ptr, + .len = buf.len, }; if (buf.len > 0) vec_index += 1; @@ -2262,16 +2262,16 @@ fn pwriteDbgInfoNops( var padding_left = next_padding_size; while (padding_left > page_of_nops.len) { vecs[vec_index] = .{ - .iov_base = &page_of_nops, - .iov_len = page_of_nops.len, + .base = &page_of_nops, + .len = page_of_nops.len, }; vec_index += 1; padding_left -= page_of_nops.len; } if (padding_left > 0) { vecs[vec_index] = .{ - .iov_base = &page_of_nops, - .iov_len = padding_left, + .base = &page_of_nops, + .len = padding_left, }; vec_index += 1; } @@ -2280,8 +2280,8 @@ fn pwriteDbgInfoNops( if (trailing_zero) { var zbuf = [1]u8{0}; vecs[vec_index] = .{ - .iov_base = &zbuf, - .iov_len = zbuf.len, + .base = &zbuf, + .len = zbuf.len, }; vec_index += 1; } diff --git a/src/link/Elf/ZigObject.zig b/src/link/Elf/ZigObject.zig index 98af014068..b27601b420 100644 --- a/src/link/Elf/ZigObject.zig +++ b/src/link/Elf/ZigObject.zig @@ -965,12 +965,12 @@ fn updateDeclCode( switch (builtin.os.tag) { .linux => { var code_vec: [1]std.posix.iovec_const = .{.{ - .iov_base = code.ptr, - .iov_len = code.len, + .base = code.ptr, + .len = code.len, }}; var remote_vec: [1]std.posix.iovec_const = .{.{ - .iov_base = @as([*]u8, @ptrFromInt(@as(usize, @intCast(sym.address(.{}, elf_file))))), - .iov_len = code.len, + .base = @as([*]u8, @ptrFromInt(@as(usize, @intCast(sym.address(.{}, elf_file))))), + .len = code.len, }}; const rc = std.os.linux.process_vm_writev(pid, &code_vec, &remote_vec, 0); switch (std.os.linux.E.init(rc)) { diff --git a/src/link/Elf/synthetic_sections.zig b/src/link/Elf/synthetic_sections.zig index 59adc7d40e..5a96650bc5 100644 --- a/src/link/Elf/synthetic_sections.zig +++ b/src/link/Elf/synthetic_sections.zig @@ -314,12 +314,12 @@ pub const ZigGotSection = struct { switch (builtin.os.tag) { .linux => { var local_vec: [1]std.posix.iovec_const = .{.{ - .iov_base = &buf, - .iov_len = buf.len, + .base = &buf, + .len = buf.len, }}; var remote_vec: [1]std.posix.iovec_const = .{.{ - .iov_base = @as([*]u8, @ptrFromInt(@as(usize, @intCast(vaddr)))), - .iov_len = buf.len, + .base = @as([*]u8, @ptrFromInt(@as(usize, @intCast(vaddr)))), + .len = buf.len, }}; const rc = std.os.linux.process_vm_writev(pid, &local_vec, &remote_vec, 0); switch (std.os.linux.E.init(rc)) { diff --git a/src/link/Plan9.zig b/src/link/Plan9.zig index 323cc8c4a9..a45142a12e 100644 --- a/src/link/Plan9.zig +++ b/src/link/Plan9.zig @@ -728,7 +728,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node const hdr_size = if (self.sixtyfour_bit) @as(usize, 40) else 32; const hdr_slice: []u8 = hdr_buf[0..hdr_size]; var foff = hdr_size; - iovecs[0] = .{ .iov_base = hdr_slice.ptr, .iov_len = hdr_slice.len }; + iovecs[0] = .{ .base = hdr_slice.ptr, .len = hdr_slice.len }; var iovecs_i: usize = 1; var text_i: u64 = 0; @@ -757,7 +757,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node linecount = out.end_line; } foff += out.code.len; - iovecs[iovecs_i] = .{ .iov_base = out.code.ptr, .iov_len = out.code.len }; + iovecs[iovecs_i] = .{ .base = out.code.ptr, .len = out.code.len }; iovecs_i += 1; const off = self.getAddr(text_i, .t); text_i += out.code.len; @@ -787,7 +787,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node const text_atom = if (meta.text_state != .unused) self.getAtomPtr(meta.text_atom) else continue; const code = text_atom.code.getOwnedCode().?; foff += code.len; - iovecs[iovecs_i] = .{ .iov_base = code.ptr, .iov_len = code.len }; + iovecs[iovecs_i] = .{ .base = code.ptr, .len = code.len }; iovecs_i += 1; const off = self.getAddr(text_i, .t); text_i += code.len; @@ -812,7 +812,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node } } // global offset table is in data - iovecs[iovecs_i] = .{ .iov_base = got_table.ptr, .iov_len = got_table.len }; + iovecs[iovecs_i] = .{ .base = got_table.ptr, .len = got_table.len }; iovecs_i += 1; // data var data_i: u64 = got_size; @@ -824,7 +824,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node const code = entry.value_ptr.*; foff += code.len; - iovecs[iovecs_i] = .{ .iov_base = code.ptr, .iov_len = code.len }; + iovecs[iovecs_i] = .{ .base = code.ptr, .len = code.len }; iovecs_i += 1; const off = self.getAddr(data_i, .d); data_i += code.len; @@ -847,7 +847,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node const code = atom.code.getOwnedCode().?; // unnamed consts must own their code log.debug("write unnamed const: ({s})", .{self.syms.items[atom.sym_index.?].name}); foff += code.len; - iovecs[iovecs_i] = .{ .iov_base = code.ptr, .iov_len = code.len }; + iovecs[iovecs_i] = .{ .base = code.ptr, .len = code.len }; iovecs_i += 1; const off = self.getAddr(data_i, .d); data_i += code.len; @@ -868,7 +868,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node const code = atom.code.getOwnedCode().?; log.debug("write anon decl: {s}", .{self.syms.items[atom.sym_index.?].name}); foff += code.len; - iovecs[iovecs_i] = .{ .iov_base = code.ptr, .iov_len = code.len }; + iovecs[iovecs_i] = .{ .base = code.ptr, .len = code.len }; iovecs_i += 1; const off = self.getAddr(data_i, .d); data_i += code.len; @@ -888,7 +888,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node const data_atom = if (meta.rodata_state != .unused) self.getAtomPtr(meta.rodata_atom) else continue; const code = data_atom.code.getOwnedCode().?; // lazy symbols must own their code foff += code.len; - iovecs[iovecs_i] = .{ .iov_base = code.ptr, .iov_len = code.len }; + iovecs[iovecs_i] = .{ .base = code.ptr, .len = code.len }; iovecs_i += 1; const off = self.getAddr(data_i, .d); data_i += code.len; @@ -929,9 +929,9 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node const syms = try sym_buf.toOwnedSlice(); defer gpa.free(syms); assert(2 + self.atomCount() - self.externCount() == iovecs_i); // we didn't write all the decls - iovecs[iovecs_i] = .{ .iov_base = syms.ptr, .iov_len = syms.len }; + iovecs[iovecs_i] = .{ .base = syms.ptr, .len = syms.len }; iovecs_i += 1; - iovecs[iovecs_i] = .{ .iov_base = linecountinfo.items.ptr, .iov_len = linecountinfo.items.len }; + iovecs[iovecs_i] = .{ .base = linecountinfo.items.ptr, .len = linecountinfo.items.len }; iovecs_i += 1; // generate the header self.hdr = .{ diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 10f00d8992..e82395ecea 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -3047,8 +3047,8 @@ fn writeToFile( // finally, write the entire binary into the file. var iovec = [_]std.posix.iovec_const{.{ - .iov_base = binary_bytes.items.ptr, - .iov_len = binary_bytes.items.len, + .base = binary_bytes.items.ptr, + .len = binary_bytes.items.len, }}; try wasm.base.file.?.writevAll(&iovec); }