authorgravatar for truemedian@gmail.comNameless <truemedian@gmail.com> 2024-04-26 12:57:03-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-04-28 00:20:30-07:00
logaecd9cc6d152443dc7c02dfe373be654d8adae64
tree6789f01a30b6a86720cb4914079376538fd365c5
parentc231d94960ec2cecbea0de877f645ba5d439fd13

std.posix.iovec: use .base and .len instead of .iov_base and .iov_len


21 files changed, 270 insertions(+), 270 deletions(-)

lib/compiler/objcopy.zig+1-1
...@@ -1285,7 +1285,7 @@ const ElfFileHelper = struct {...@@ -1285,7 +1285,7 @@ const ElfFileHelper = struct {
1285 for (consolidated.items) |cmd| {1285 for (consolidated.items) |cmd| {
1286 switch (cmd) {1286 switch (cmd) {
1287 .write_data => |data| {1287 .write_data => |data| {
1288 var iovec = [_]std.posix.iovec_const{.{ .iov_base = data.data.ptr, .iov_len = data.data.len }};1288 var iovec = [_]std.posix.iovec_const{.{ .base = data.data.ptr, .len = data.data.len }};
1289 try out_file.pwritevAll(&iovec, data.out_offset);1289 try out_file.pwritevAll(&iovec, data.out_offset);
1290 },1290 },
1291 .copy_range => |range| {1291 .copy_range => |range| {
lib/std/crypto/tls/Client.zig+30-30
...@@ -217,12 +217,12 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In...@@ -217,12 +217,12 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In
217 {217 {
218 var iovecs = [_]std.posix.iovec_const{218 var iovecs = [_]std.posix.iovec_const{
219 .{219 .{
220 .iov_base = &plaintext_header,220 .base = &plaintext_header,
221 .iov_len = plaintext_header.len,221 .len = plaintext_header.len,
222 },222 },
223 .{223 .{
224 .iov_base = host.ptr,224 .base = host.ptr,
225 .iov_len = host.len,225 .len = host.len,
226 },226 },
227 };227 };
228 try stream.writevAll(&iovecs);228 try stream.writevAll(&iovecs);
...@@ -678,8 +678,8 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In...@@ -678,8 +678,8 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In
678678
679 const both_msgs = client_change_cipher_spec_msg ++ finished_msg;679 const both_msgs = client_change_cipher_spec_msg ++ finished_msg;
680 var both_msgs_vec = [_]std.posix.iovec_const{.{680 var both_msgs_vec = [_]std.posix.iovec_const{.{
681 .iov_base = &both_msgs,681 .base = &both_msgs,
682 .iov_len = both_msgs.len,682 .len = both_msgs.len,
683 }};683 }};
684 try stream.writevAll(&both_msgs_vec);684 try stream.writevAll(&both_msgs_vec);
685685
...@@ -776,8 +776,8 @@ pub fn writeEnd(c: *Client, stream: anytype, bytes: []const u8, end: bool) !usiz...@@ -776,8 +776,8 @@ pub fn writeEnd(c: *Client, stream: anytype, bytes: []const u8, end: bool) !usiz
776 var total_amt: usize = 0;776 var total_amt: usize = 0;
777 while (true) {777 while (true) {
778 var amt = try stream.writev(iovecs_buf[i..iovec_end]);778 var amt = try stream.writev(iovecs_buf[i..iovec_end]);
779 while (amt >= iovecs_buf[i].iov_len) {779 while (amt >= iovecs_buf[i].len) {
780 const encrypted_amt = iovecs_buf[i].iov_len;780 const encrypted_amt = iovecs_buf[i].len;
781 total_amt += encrypted_amt - overhead_len;781 total_amt += encrypted_amt - overhead_len;
782 amt -= encrypted_amt;782 amt -= encrypted_amt;
783 i += 1;783 i += 1;
...@@ -789,8 +789,8 @@ pub fn writeEnd(c: *Client, stream: anytype, bytes: []const u8, end: bool) !usiz...@@ -789,8 +789,8 @@ pub fn writeEnd(c: *Client, stream: anytype, bytes: []const u8, end: bool) !usiz
789 // not sent; otherwise the caller would not know to retry the call.789 // not sent; otherwise the caller would not know to retry the call.
790 if (amt == 0 and (!end or i < iovec_end - 1)) return total_amt;790 if (amt == 0 and (!end or i < iovec_end - 1)) return total_amt;
791 }791 }
792 iovecs_buf[i].iov_base += amt;792 iovecs_buf[i].base += amt;
793 iovecs_buf[i].iov_len -= amt;793 iovecs_buf[i].len -= amt;
794 }794 }
795}795}
796796
...@@ -864,8 +864,8 @@ fn prepareCiphertextRecord(...@@ -864,8 +864,8 @@ fn prepareCiphertextRecord(
864864
865 const record = ciphertext_buf[record_start..ciphertext_end];865 const record = ciphertext_buf[record_start..ciphertext_end];
866 iovecs[iovec_end] = .{866 iovecs[iovec_end] = .{
867 .iov_base = record.ptr,867 .base = record.ptr,
868 .iov_len = record.len,868 .len = record.len,
869 };869 };
870 iovec_end += 1;870 iovec_end += 1;
871 }871 }
...@@ -885,7 +885,7 @@ pub fn eof(c: Client) bool {...@@ -885,7 +885,7 @@ pub fn eof(c: Client) bool {
885/// If the number read is less than `len` it means the stream reached the end.885/// If the number read is less than `len` it means the stream reached the end.
886/// Reaching the end of the stream is not an error condition.886/// Reaching the end of the stream is not an error condition.
887pub fn readAtLeast(c: *Client, stream: anytype, buffer: []u8, len: usize) !usize {887pub fn readAtLeast(c: *Client, stream: anytype, buffer: []u8, len: usize) !usize {
888 var iovecs = [1]std.posix.iovec{.{ .iov_base = buffer.ptr, .iov_len = buffer.len }};888 var iovecs = [1]std.posix.iovec{.{ .base = buffer.ptr, .len = buffer.len }};
889 return readvAtLeast(c, stream, &iovecs, len);889 return readvAtLeast(c, stream, &iovecs, len);
890}890}
891891
...@@ -928,12 +928,12 @@ pub fn readvAtLeast(c: *Client, stream: anytype, iovecs: []std.posix.iovec, len:...@@ -928,12 +928,12 @@ pub fn readvAtLeast(c: *Client, stream: anytype, iovecs: []std.posix.iovec, len:
928 var amt = try c.readvAdvanced(stream, iovecs[vec_i..]);928 var amt = try c.readvAdvanced(stream, iovecs[vec_i..]);
929 off_i += amt;929 off_i += amt;
930 if (c.eof() or off_i >= len) return off_i;930 if (c.eof() or off_i >= len) return off_i;
931 while (amt >= iovecs[vec_i].iov_len) {931 while (amt >= iovecs[vec_i].len) {
932 amt -= iovecs[vec_i].iov_len;932 amt -= iovecs[vec_i].len;
933 vec_i += 1;933 vec_i += 1;
934 }934 }
935 iovecs[vec_i].iov_base += amt;935 iovecs[vec_i].base += amt;
936 iovecs[vec_i].iov_len -= amt;936 iovecs[vec_i].len -= amt;
937 }937 }
938}938}
939939
...@@ -1000,12 +1000,12 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.posix.iove...@@ -1000,12 +1000,12 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.posix.iove
10001000
1001 var ask_iovecs_buf: [2]std.posix.iovec = .{1001 var ask_iovecs_buf: [2]std.posix.iovec = .{
1002 .{1002 .{
1003 .iov_base = first_iov.ptr,1003 .base = first_iov.ptr,
1004 .iov_len = first_iov.len,1004 .len = first_iov.len,
1005 },1005 },
1006 .{1006 .{
1007 .iov_base = &in_stack_buffer,1007 .base = &in_stack_buffer,
1008 .iov_len = in_stack_buffer.len,1008 .len = in_stack_buffer.len,
1009 },1009 },
1010 };1010 };
10111011
...@@ -1364,12 +1364,12 @@ const VecPut = struct {...@@ -1364,12 +1364,12 @@ const VecPut = struct {
1364 var bytes_i: usize = 0;1364 var bytes_i: usize = 0;
1365 while (true) {1365 while (true) {
1366 const v = vp.iovecs[vp.idx];1366 const v = vp.iovecs[vp.idx];
1367 const dest = v.iov_base[vp.off..v.iov_len];1367 const dest = v.base[vp.off..v.len];
1368 const src = bytes[bytes_i..][0..@min(dest.len, bytes.len - bytes_i)];1368 const src = bytes[bytes_i..][0..@min(dest.len, bytes.len - bytes_i)];
1369 @memcpy(dest[0..src.len], src);1369 @memcpy(dest[0..src.len], src);
1370 bytes_i += src.len;1370 bytes_i += src.len;
1371 vp.off += src.len;1371 vp.off += src.len;
1372 if (vp.off >= v.iov_len) {1372 if (vp.off >= v.len) {
1373 vp.off = 0;1373 vp.off = 0;
1374 vp.idx += 1;1374 vp.idx += 1;
1375 if (vp.idx >= vp.iovecs.len) {1375 if (vp.idx >= vp.iovecs.len) {
...@@ -1388,7 +1388,7 @@ const VecPut = struct {...@@ -1388,7 +1388,7 @@ const VecPut = struct {
1388 fn peek(vp: VecPut) []u8 {1388 fn peek(vp: VecPut) []u8 {
1389 if (vp.idx >= vp.iovecs.len) return &.{};1389 if (vp.idx >= vp.iovecs.len) return &.{};
1390 const v = vp.iovecs[vp.idx];1390 const v = vp.iovecs[vp.idx];
1391 return v.iov_base[vp.off..v.iov_len];1391 return v.base[vp.off..v.len];
1392 }1392 }
13931393
1394 // After writing to the result of peek(), one can call next() to1394 // After writing to the result of peek(), one can call next() to
...@@ -1396,7 +1396,7 @@ const VecPut = struct {...@@ -1396,7 +1396,7 @@ const VecPut = struct {
1396 fn next(vp: *VecPut, len: usize) void {1396 fn next(vp: *VecPut, len: usize) void {
1397 vp.total += len;1397 vp.total += len;
1398 vp.off += len;1398 vp.off += len;
1399 if (vp.off >= vp.iovecs[vp.idx].iov_len) {1399 if (vp.off >= vp.iovecs[vp.idx].len) {
1400 vp.off = 0;1400 vp.off = 0;
1401 vp.idx += 1;1401 vp.idx += 1;
1402 }1402 }
...@@ -1405,9 +1405,9 @@ const VecPut = struct {...@@ -1405,9 +1405,9 @@ const VecPut = struct {
1405 fn freeSize(vp: VecPut) usize {1405 fn freeSize(vp: VecPut) usize {
1406 if (vp.idx >= vp.iovecs.len) return 0;1406 if (vp.idx >= vp.iovecs.len) return 0;
1407 var total: usize = 0;1407 var total: usize = 0;
1408 total += vp.iovecs[vp.idx].iov_len - vp.off;1408 total += vp.iovecs[vp.idx].len - vp.off;
1409 if (vp.idx + 1 >= vp.iovecs.len) return total;1409 if (vp.idx + 1 >= vp.iovecs.len) return total;
1410 for (vp.iovecs[vp.idx + 1 ..]) |v| total += v.iov_len;1410 for (vp.iovecs[vp.idx + 1 ..]) |v| total += v.len;
1411 return total;1411 return total;
1412 }1412 }
1413};1413};
...@@ -1416,11 +1416,11 @@ const VecPut = struct {...@@ -1416,11 +1416,11 @@ const VecPut = struct {
1416fn limitVecs(iovecs: []std.posix.iovec, len: usize) []std.posix.iovec {1416fn limitVecs(iovecs: []std.posix.iovec, len: usize) []std.posix.iovec {
1417 var bytes_left: usize = len;1417 var bytes_left: usize = len;
1418 for (iovecs, 0..) |*iovec, vec_i| {1418 for (iovecs, 0..) |*iovec, vec_i| {
1419 if (bytes_left <= iovec.iov_len) {1419 if (bytes_left <= iovec.len) {
1420 iovec.iov_len = bytes_left;1420 iovec.len = bytes_left;
1421 return iovecs[0 .. vec_i + 1];1421 return iovecs[0 .. vec_i + 1];
1422 }1422 }
1423 bytes_left -= iovec.iov_len;1423 bytes_left -= iovec.len;
1424 }1424 }
1425 return iovecs;1425 return iovecs;
1426}1426}
lib/std/fs/File.zig+32-32
...@@ -1138,7 +1138,7 @@ pub fn readv(self: File, iovecs: []const posix.iovec) ReadError!usize {...@@ -1138,7 +1138,7 @@ pub fn readv(self: File, iovecs: []const posix.iovec) ReadError!usize {
1138 // TODO improve this to use ReadFileScatter1138 // TODO improve this to use ReadFileScatter
1139 if (iovecs.len == 0) return @as(usize, 0);1139 if (iovecs.len == 0) return @as(usize, 0);
1140 const first = iovecs[0];1140 const first = iovecs[0];
1141 return windows.ReadFile(self.handle, first.iov_base[0..first.iov_len], null);1141 return windows.ReadFile(self.handle, first.base[0..first.len], null);
1142 }1142 }
11431143
1144 return posix.readv(self.handle, iovecs);1144 return posix.readv(self.handle, iovecs);
...@@ -1153,7 +1153,7 @@ pub fn readv(self: File, iovecs: []const posix.iovec) ReadError!usize {...@@ -1153,7 +1153,7 @@ pub fn readv(self: File, iovecs: []const posix.iovec) ReadError!usize {
1153/// reads from the underlying OS layer.1153/// reads from the underlying OS layer.
1154/// * The OS layer expects pointer addresses to be inside the application's address space1154/// * The OS layer expects pointer addresses to be inside the application's address space
1155/// even if the length is zero. Meanwhile, in Zig, slices may have undefined pointer1155/// even if the length is zero. Meanwhile, in Zig, slices may have undefined pointer
1156/// addresses when the length is zero. So this function modifies the iov_base fields1156/// addresses when the length is zero. So this function modifies the base fields
1157/// when the length is zero.1157/// when the length is zero.
1158///1158///
1159/// Related open issue: https://github.com/ziglang/zig/issues/76991159/// Related open issue: https://github.com/ziglang/zig/issues/7699
...@@ -1165,7 +1165,7 @@ pub fn readvAll(self: File, iovecs: []posix.iovec) ReadError!usize {...@@ -1165,7 +1165,7 @@ pub fn readvAll(self: File, iovecs: []posix.iovec) ReadError!usize {
1165 // addresses outside the application's address space.1165 // addresses outside the application's address space.
1166 var garbage: [1]u8 = undefined;1166 var garbage: [1]u8 = undefined;
1167 for (iovecs) |*v| {1167 for (iovecs) |*v| {
1168 if (v.iov_len == 0) v.iov_base = &garbage;1168 if (v.len == 0) v.base = &garbage;
1169 }1169 }
11701170
1171 var i: usize = 0;1171 var i: usize = 0;
...@@ -1174,15 +1174,15 @@ pub fn readvAll(self: File, iovecs: []posix.iovec) ReadError!usize {...@@ -1174,15 +1174,15 @@ pub fn readvAll(self: File, iovecs: []posix.iovec) ReadError!usize {
1174 var amt = try self.readv(iovecs[i..]);1174 var amt = try self.readv(iovecs[i..]);
1175 var eof = amt == 0;1175 var eof = amt == 0;
1176 off += amt;1176 off += amt;
1177 while (amt >= iovecs[i].iov_len) {1177 while (amt >= iovecs[i].len) {
1178 amt -= iovecs[i].iov_len;1178 amt -= iovecs[i].len;
1179 i += 1;1179 i += 1;
1180 if (i >= iovecs.len) return off;1180 if (i >= iovecs.len) return off;
1181 eof = false;1181 eof = false;
1182 }1182 }
1183 if (eof) return off;1183 if (eof) return off;
1184 iovecs[i].iov_base += amt;1184 iovecs[i].base += amt;
1185 iovecs[i].iov_len -= amt;1185 iovecs[i].len -= amt;
1186 }1186 }
1187}1187}
11881188
...@@ -1194,7 +1194,7 @@ pub fn preadv(self: File, iovecs: []const posix.iovec, offset: u64) PReadError!u...@@ -1194,7 +1194,7 @@ pub fn preadv(self: File, iovecs: []const posix.iovec, offset: u64) PReadError!u
1194 // TODO improve this to use ReadFileScatter1194 // TODO improve this to use ReadFileScatter
1195 if (iovecs.len == 0) return @as(usize, 0);1195 if (iovecs.len == 0) return @as(usize, 0);
1196 const first = iovecs[0];1196 const first = iovecs[0];
1197 return windows.ReadFile(self.handle, first.iov_base[0..first.iov_len], offset);1197 return windows.ReadFile(self.handle, first.base[0..first.len], offset);
1198 }1198 }
11991199
1200 return posix.preadv(self.handle, iovecs, offset);1200 return posix.preadv(self.handle, iovecs, offset);
...@@ -1217,15 +1217,15 @@ pub fn preadvAll(self: File, iovecs: []posix.iovec, offset: u64) PReadError!usiz...@@ -1217,15 +1217,15 @@ pub fn preadvAll(self: File, iovecs: []posix.iovec, offset: u64) PReadError!usiz
1217 var amt = try self.preadv(iovecs[i..], offset + off);1217 var amt = try self.preadv(iovecs[i..], offset + off);
1218 var eof = amt == 0;1218 var eof = amt == 0;
1219 off += amt;1219 off += amt;
1220 while (amt >= iovecs[i].iov_len) {1220 while (amt >= iovecs[i].len) {
1221 amt -= iovecs[i].iov_len;1221 amt -= iovecs[i].len;
1222 i += 1;1222 i += 1;
1223 if (i >= iovecs.len) return off;1223 if (i >= iovecs.len) return off;
1224 eof = false;1224 eof = false;
1225 }1225 }
1226 if (eof) return off;1226 if (eof) return off;
1227 iovecs[i].iov_base += amt;1227 iovecs[i].base += amt;
1228 iovecs[i].iov_len -= amt;1228 iovecs[i].len -= amt;
1229 }1229 }
1230}1230}
12311231
...@@ -1273,7 +1273,7 @@ pub fn writev(self: File, iovecs: []const posix.iovec_const) WriteError!usize {...@@ -1273,7 +1273,7 @@ pub fn writev(self: File, iovecs: []const posix.iovec_const) WriteError!usize {
1273 // TODO improve this to use WriteFileScatter1273 // TODO improve this to use WriteFileScatter
1274 if (iovecs.len == 0) return @as(usize, 0);1274 if (iovecs.len == 0) return @as(usize, 0);
1275 const first = iovecs[0];1275 const first = iovecs[0];
1276 return windows.WriteFile(self.handle, first.iov_base[0..first.iov_len], null);1276 return windows.WriteFile(self.handle, first.base[0..first.len], null);
1277 }1277 }
12781278
1279 return posix.writev(self.handle, iovecs);1279 return posix.writev(self.handle, iovecs);
...@@ -1284,7 +1284,7 @@ pub fn writev(self: File, iovecs: []const posix.iovec_const) WriteError!usize {...@@ -1284,7 +1284,7 @@ pub fn writev(self: File, iovecs: []const posix.iovec_const) WriteError!usize {
1284/// writes from the underlying OS layer.1284/// writes from the underlying OS layer.
1285/// * The OS layer expects pointer addresses to be inside the application's address space1285/// * The OS layer expects pointer addresses to be inside the application's address space
1286/// even if the length is zero. Meanwhile, in Zig, slices may have undefined pointer1286/// even if the length is zero. Meanwhile, in Zig, slices may have undefined pointer
1287/// addresses when the length is zero. So this function modifies the iov_base fields1287/// addresses when the length is zero. So this function modifies the base fields
1288/// when the length is zero.1288/// when the length is zero.
1289/// See https://github.com/ziglang/zig/issues/76991289/// See https://github.com/ziglang/zig/issues/7699
1290/// See equivalent function: `std.net.Stream.writevAll`.1290/// See equivalent function: `std.net.Stream.writevAll`.
...@@ -1296,19 +1296,19 @@ pub fn writevAll(self: File, iovecs: []posix.iovec_const) WriteError!void {...@@ -1296,19 +1296,19 @@ pub fn writevAll(self: File, iovecs: []posix.iovec_const) WriteError!void {
1296 // addresses outside the application's address space.1296 // addresses outside the application's address space.
1297 var garbage: [1]u8 = undefined;1297 var garbage: [1]u8 = undefined;
1298 for (iovecs) |*v| {1298 for (iovecs) |*v| {
1299 if (v.iov_len == 0) v.iov_base = &garbage;1299 if (v.len == 0) v.base = &garbage;
1300 }1300 }
13011301
1302 var i: usize = 0;1302 var i: usize = 0;
1303 while (true) {1303 while (true) {
1304 var amt = try self.writev(iovecs[i..]);1304 var amt = try self.writev(iovecs[i..]);
1305 while (amt >= iovecs[i].iov_len) {1305 while (amt >= iovecs[i].len) {
1306 amt -= iovecs[i].iov_len;1306 amt -= iovecs[i].len;
1307 i += 1;1307 i += 1;
1308 if (i >= iovecs.len) return;1308 if (i >= iovecs.len) return;
1309 }1309 }
1310 iovecs[i].iov_base += amt;1310 iovecs[i].base += amt;
1311 iovecs[i].iov_len -= amt;1311 iovecs[i].len -= amt;
1312 }1312 }
1313}1313}
13141314
...@@ -1320,7 +1320,7 @@ pub fn pwritev(self: File, iovecs: []posix.iovec_const, offset: u64) PWriteError...@@ -1320,7 +1320,7 @@ pub fn pwritev(self: File, iovecs: []posix.iovec_const, offset: u64) PWriteError
1320 // TODO improve this to use WriteFileScatter1320 // TODO improve this to use WriteFileScatter
1321 if (iovecs.len == 0) return @as(usize, 0);1321 if (iovecs.len == 0) return @as(usize, 0);
1322 const first = iovecs[0];1322 const first = iovecs[0];
1323 return windows.WriteFile(self.handle, first.iov_base[0..first.iov_len], offset);1323 return windows.WriteFile(self.handle, first.base[0..first.len], offset);
1324 }1324 }
13251325
1326 return posix.pwritev(self.handle, iovecs, offset);1326 return posix.pwritev(self.handle, iovecs, offset);
...@@ -1339,13 +1339,13 @@ pub fn pwritevAll(self: File, iovecs: []posix.iovec_const, offset: u64) PWriteEr...@@ -1339,13 +1339,13 @@ pub fn pwritevAll(self: File, iovecs: []posix.iovec_const, offset: u64) PWriteEr
1339 while (true) {1339 while (true) {
1340 var amt = try self.pwritev(iovecs[i..], offset + off);1340 var amt = try self.pwritev(iovecs[i..], offset + off);
1341 off += amt;1341 off += amt;
1342 while (amt >= iovecs[i].iov_len) {1342 while (amt >= iovecs[i].len) {
1343 amt -= iovecs[i].iov_len;1343 amt -= iovecs[i].len;
1344 i += 1;1344 i += 1;
1345 if (i >= iovecs.len) return;1345 if (i >= iovecs.len) return;
1346 }1346 }
1347 iovecs[i].iov_base += amt;1347 iovecs[i].base += amt;
1348 iovecs[i].iov_len -= amt;1348 iovecs[i].len -= amt;
1349 }1349 }
1350}1350}
13511351
...@@ -1456,13 +1456,13 @@ fn writeFileAllSendfile(self: File, in_file: File, args: WriteFileOptions) posix...@@ -1456,13 +1456,13 @@ fn writeFileAllSendfile(self: File, in_file: File, args: WriteFileOptions) posix
1456 var i: usize = 0;1456 var i: usize = 0;
1457 while (i < headers.len) {1457 while (i < headers.len) {
1458 amt = try posix.sendfile(out_fd, in_fd, offset, count, headers[i..], trls, flags);1458 amt = try posix.sendfile(out_fd, in_fd, offset, count, headers[i..], trls, flags);
1459 while (amt >= headers[i].iov_len) {1459 while (amt >= headers[i].len) {
1460 amt -= headers[i].iov_len;1460 amt -= headers[i].len;
1461 i += 1;1461 i += 1;
1462 if (i >= headers.len) break :hdrs;1462 if (i >= headers.len) break :hdrs;
1463 }1463 }
1464 headers[i].iov_base += amt;1464 headers[i].base += amt;
1465 headers[i].iov_len -= amt;1465 headers[i].len -= amt;
1466 }1466 }
1467 }1467 }
1468 if (count == 0) {1468 if (count == 0) {
...@@ -1482,13 +1482,13 @@ fn writeFileAllSendfile(self: File, in_file: File, args: WriteFileOptions) posix...@@ -1482,13 +1482,13 @@ fn writeFileAllSendfile(self: File, in_file: File, args: WriteFileOptions) posix
1482 }1482 }
1483 var i: usize = 0;1483 var i: usize = 0;
1484 while (i < trailers.len) {1484 while (i < trailers.len) {
1485 while (amt >= trailers[i].iov_len) {1485 while (amt >= trailers[i].len) {
1486 amt -= trailers[i].iov_len;1486 amt -= trailers[i].len;
1487 i += 1;1487 i += 1;
1488 if (i >= trailers.len) return;1488 if (i >= trailers.len) return;
1489 }1489 }
1490 trailers[i].iov_base += amt;1490 trailers[i].base += amt;
1491 trailers[i].iov_len -= amt;1491 trailers[i].len -= amt;
1492 amt = try posix.writev(self.handle, trailers[i..]);1492 amt = try posix.writev(self.handle, trailers[i..]);
1493 }1493 }
1494}1494}
lib/std/fs/test.zig+28-28
...@@ -1276,22 +1276,22 @@ test "writev, readv" {...@@ -1276,22 +1276,22 @@ test "writev, readv" {
1276 var buf2: [line2.len]u8 = undefined;1276 var buf2: [line2.len]u8 = undefined;
1277 var write_vecs = [_]posix.iovec_const{1277 var write_vecs = [_]posix.iovec_const{
1278 .{1278 .{
1279 .iov_base = line1,1279 .base = line1,
1280 .iov_len = line1.len,1280 .len = line1.len,
1281 },1281 },
1282 .{1282 .{
1283 .iov_base = line2,1283 .base = line2,
1284 .iov_len = line2.len,1284 .len = line2.len,
1285 },1285 },
1286 };1286 };
1287 var read_vecs = [_]posix.iovec{1287 var read_vecs = [_]posix.iovec{
1288 .{1288 .{
1289 .iov_base = &buf2,1289 .base = &buf2,
1290 .iov_len = buf2.len,1290 .len = buf2.len,
1291 },1291 },
1292 .{1292 .{
1293 .iov_base = &buf1,1293 .base = &buf1,
1294 .iov_len = buf1.len,1294 .len = buf1.len,
1295 },1295 },
1296 };1296 };
12971297
...@@ -1318,22 +1318,22 @@ test "pwritev, preadv" {...@@ -1318,22 +1318,22 @@ test "pwritev, preadv" {
1318 var buf2: [line2.len]u8 = undefined;1318 var buf2: [line2.len]u8 = undefined;
1319 var write_vecs = [_]posix.iovec_const{1319 var write_vecs = [_]posix.iovec_const{
1320 .{1320 .{
1321 .iov_base = line1,1321 .base = line1,
1322 .iov_len = line1.len,1322 .len = line1.len,
1323 },1323 },
1324 .{1324 .{
1325 .iov_base = line2,1325 .base = line2,
1326 .iov_len = line2.len,1326 .len = line2.len,
1327 },1327 },
1328 };1328 };
1329 var read_vecs = [_]posix.iovec{1329 var read_vecs = [_]posix.iovec{
1330 .{1330 .{
1331 .iov_base = &buf2,1331 .base = &buf2,
1332 .iov_len = buf2.len,1332 .len = buf2.len,
1333 },1333 },
1334 .{1334 .{
1335 .iov_base = &buf1,1335 .base = &buf1,
1336 .iov_len = buf1.len,1336 .len = buf1.len,
1337 },1337 },
1338 };1338 };
13391339
...@@ -1378,12 +1378,12 @@ test "sendfile" {...@@ -1378,12 +1378,12 @@ test "sendfile" {
1378 const line2 = "second line\n";1378 const line2 = "second line\n";
1379 var vecs = [_]posix.iovec_const{1379 var vecs = [_]posix.iovec_const{
1380 .{1380 .{
1381 .iov_base = line1,1381 .base = line1,
1382 .iov_len = line1.len,1382 .len = line1.len,
1383 },1383 },
1384 .{1384 .{
1385 .iov_base = line2,1385 .base = line2,
1386 .iov_len = line2.len,1386 .len = line2.len,
1387 },1387 },
1388 };1388 };
13891389
...@@ -1401,20 +1401,20 @@ test "sendfile" {...@@ -1401,20 +1401,20 @@ test "sendfile" {
1401 const trailer2 = "second trailer\n";1401 const trailer2 = "second trailer\n";
1402 var hdtr = [_]posix.iovec_const{1402 var hdtr = [_]posix.iovec_const{
1403 .{1403 .{
1404 .iov_base = header1,1404 .base = header1,
1405 .iov_len = header1.len,1405 .len = header1.len,
1406 },1406 },
1407 .{1407 .{
1408 .iov_base = header2,1408 .base = header2,
1409 .iov_len = header2.len,1409 .len = header2.len,
1410 },1410 },
1411 .{1411 .{
1412 .iov_base = trailer1,1412 .base = trailer1,
1413 .iov_len = trailer1.len,1413 .len = trailer1.len,
1414 },1414 },
1415 .{1415 .{
1416 .iov_base = trailer2,1416 .base = trailer2,
1417 .iov_len = trailer2.len,1417 .len = trailer2.len,
1418 },1418 },
1419 };1419 };
14201420
lib/std/http/Client.zig+3-3
...@@ -253,7 +253,7 @@ pub const Connection = struct {...@@ -253,7 +253,7 @@ pub const Connection = struct {
253 if (conn.read_end != conn.read_start) return;253 if (conn.read_end != conn.read_start) return;
254254
255 var iovecs = [1]std.posix.iovec{255 var iovecs = [1]std.posix.iovec{
256 .{ .iov_base = &conn.read_buf, .iov_len = conn.read_buf.len },256 .{ .base = &conn.read_buf, .len = conn.read_buf.len },
257 };257 };
258 const nread = try conn.readvDirect(&iovecs);258 const nread = try conn.readvDirect(&iovecs);
259 if (nread == 0) return error.EndOfStream;259 if (nread == 0) return error.EndOfStream;
...@@ -289,8 +289,8 @@ pub const Connection = struct {...@@ -289,8 +289,8 @@ pub const Connection = struct {
289 }289 }
290290
291 var iovecs = [2]std.posix.iovec{291 var iovecs = [2]std.posix.iovec{
292 .{ .iov_base = buffer.ptr, .iov_len = buffer.len },292 .{ .base = buffer.ptr, .len = buffer.len },
293 .{ .iov_base = &conn.read_buf, .iov_len = conn.read_buf.len },293 .{ .base = &conn.read_buf, .len = conn.read_buf.len },
294 };294 };
295 const nread = try conn.readvDirect(&iovecs);295 const nread = try conn.readvDirect(&iovecs);
296296
lib/std/http/Server.zig+56-56
...@@ -442,42 +442,42 @@ pub const Request = struct {...@@ -442,42 +442,42 @@ pub const Request = struct {
442 var iovecs_len: usize = 0;442 var iovecs_len: usize = 0;
443443
444 iovecs[iovecs_len] = .{444 iovecs[iovecs_len] = .{
445 .iov_base = h.items.ptr,445 .base = h.items.ptr,
446 .iov_len = h.items.len,446 .len = h.items.len,
447 };447 };
448 iovecs_len += 1;448 iovecs_len += 1;
449449
450 for (options.extra_headers) |header| {450 for (options.extra_headers) |header| {
451 iovecs[iovecs_len] = .{451 iovecs[iovecs_len] = .{
452 .iov_base = header.name.ptr,452 .base = header.name.ptr,
453 .iov_len = header.name.len,453 .len = header.name.len,
454 };454 };
455 iovecs_len += 1;455 iovecs_len += 1;
456456
457 iovecs[iovecs_len] = .{457 iovecs[iovecs_len] = .{
458 .iov_base = ": ",458 .base = ": ",
459 .iov_len = 2,459 .len = 2,
460 };460 };
461 iovecs_len += 1;461 iovecs_len += 1;
462462
463 if (header.value.len != 0) {463 if (header.value.len != 0) {
464 iovecs[iovecs_len] = .{464 iovecs[iovecs_len] = .{
465 .iov_base = header.value.ptr,465 .base = header.value.ptr,
466 .iov_len = header.value.len,466 .len = header.value.len,
467 };467 };
468 iovecs_len += 1;468 iovecs_len += 1;
469 }469 }
470470
471 iovecs[iovecs_len] = .{471 iovecs[iovecs_len] = .{
472 .iov_base = "\r\n",472 .base = "\r\n",
473 .iov_len = 2,473 .len = 2,
474 };474 };
475 iovecs_len += 1;475 iovecs_len += 1;
476 }476 }
477477
478 iovecs[iovecs_len] = .{478 iovecs[iovecs_len] = .{
479 .iov_base = "\r\n",479 .base = "\r\n",
480 .iov_len = 2,480 .len = 2,
481 };481 };
482 iovecs_len += 1;482 iovecs_len += 1;
483483
...@@ -492,33 +492,33 @@ pub const Request = struct {...@@ -492,33 +492,33 @@ pub const Request = struct {
492 ) catch unreachable;492 ) catch unreachable;
493493
494 iovecs[iovecs_len] = .{494 iovecs[iovecs_len] = .{
495 .iov_base = chunk_header.ptr,495 .base = chunk_header.ptr,
496 .iov_len = chunk_header.len,496 .len = chunk_header.len,
497 };497 };
498 iovecs_len += 1;498 iovecs_len += 1;
499499
500 iovecs[iovecs_len] = .{500 iovecs[iovecs_len] = .{
501 .iov_base = content.ptr,501 .base = content.ptr,
502 .iov_len = content.len,502 .len = content.len,
503 };503 };
504 iovecs_len += 1;504 iovecs_len += 1;
505505
506 iovecs[iovecs_len] = .{506 iovecs[iovecs_len] = .{
507 .iov_base = "\r\n",507 .base = "\r\n",
508 .iov_len = 2,508 .len = 2,
509 };509 };
510 iovecs_len += 1;510 iovecs_len += 1;
511 }511 }
512512
513 iovecs[iovecs_len] = .{513 iovecs[iovecs_len] = .{
514 .iov_base = "0\r\n\r\n",514 .base = "0\r\n\r\n",
515 .iov_len = 5,515 .len = 5,
516 };516 };
517 iovecs_len += 1;517 iovecs_len += 1;
518 } else if (content.len > 0) {518 } else if (content.len > 0) {
519 iovecs[iovecs_len] = .{519 iovecs[iovecs_len] = .{
520 .iov_base = content.ptr,520 .base = content.ptr,
521 .iov_len = content.len,521 .len = content.len,
522 };522 };
523 iovecs_len += 1;523 iovecs_len += 1;
524 }524 }
...@@ -912,12 +912,12 @@ pub const Response = struct {...@@ -912,12 +912,12 @@ pub const Response = struct {
912 const send_buffer_len = r.send_buffer_end - r.send_buffer_start;912 const send_buffer_len = r.send_buffer_end - r.send_buffer_start;
913 var iovecs: [2]std.posix.iovec_const = .{913 var iovecs: [2]std.posix.iovec_const = .{
914 .{914 .{
915 .iov_base = r.send_buffer.ptr + r.send_buffer_start,915 .base = r.send_buffer.ptr + r.send_buffer_start,
916 .iov_len = send_buffer_len,916 .len = send_buffer_len,
917 },917 },
918 .{918 .{
919 .iov_base = bytes.ptr,919 .base = bytes.ptr,
920 .iov_len = bytes.len,920 .len = bytes.len,
921 },921 },
922 };922 };
923 const n = try r.stream.writev(&iovecs);923 const n = try r.stream.writev(&iovecs);
...@@ -959,24 +959,24 @@ pub const Response = struct {...@@ -959,24 +959,24 @@ pub const Response = struct {
959959
960 var iovecs: [5]std.posix.iovec_const = .{960 var iovecs: [5]std.posix.iovec_const = .{
961 .{961 .{
962 .iov_base = r.send_buffer.ptr + r.send_buffer_start,962 .base = r.send_buffer.ptr + r.send_buffer_start,
963 .iov_len = send_buffer_len - r.chunk_len,963 .len = send_buffer_len - r.chunk_len,
964 },964 },
965 .{965 .{
966 .iov_base = chunk_header.ptr,966 .base = chunk_header.ptr,
967 .iov_len = chunk_header.len,967 .len = chunk_header.len,
968 },968 },
969 .{969 .{
970 .iov_base = r.send_buffer.ptr + r.send_buffer_end - r.chunk_len,970 .base = r.send_buffer.ptr + r.send_buffer_end - r.chunk_len,
971 .iov_len = r.chunk_len,971 .len = r.chunk_len,
972 },972 },
973 .{973 .{
974 .iov_base = bytes.ptr,974 .base = bytes.ptr,
975 .iov_len = bytes.len,975 .len = bytes.len,
976 },976 },
977 .{977 .{
978 .iov_base = "\r\n",978 .base = "\r\n",
979 .iov_len = 2,979 .len = 2,
980 },980 },
981 };981 };
982 // TODO make this writev instead of writevAll, which involves982 // TODO make this writev instead of writevAll, which involves
...@@ -1042,69 +1042,69 @@ pub const Response = struct {...@@ -1042,69 +1042,69 @@ pub const Response = struct {
1042 var iovecs_len: usize = 0;1042 var iovecs_len: usize = 0;
10431043
1044 iovecs[iovecs_len] = .{1044 iovecs[iovecs_len] = .{
1045 .iov_base = http_headers.ptr,1045 .base = http_headers.ptr,
1046 .iov_len = http_headers.len,1046 .len = http_headers.len,
1047 };1047 };
1048 iovecs_len += 1;1048 iovecs_len += 1;
10491049
1050 if (r.chunk_len > 0) {1050 if (r.chunk_len > 0) {
1051 iovecs[iovecs_len] = .{1051 iovecs[iovecs_len] = .{
1052 .iov_base = chunk_header.ptr,1052 .base = chunk_header.ptr,
1053 .iov_len = chunk_header.len,1053 .len = chunk_header.len,
1054 };1054 };
1055 iovecs_len += 1;1055 iovecs_len += 1;
10561056
1057 iovecs[iovecs_len] = .{1057 iovecs[iovecs_len] = .{
1058 .iov_base = r.send_buffer.ptr + r.send_buffer_end - r.chunk_len,1058 .base = r.send_buffer.ptr + r.send_buffer_end - r.chunk_len,
1059 .iov_len = r.chunk_len,1059 .len = r.chunk_len,
1060 };1060 };
1061 iovecs_len += 1;1061 iovecs_len += 1;
10621062
1063 iovecs[iovecs_len] = .{1063 iovecs[iovecs_len] = .{
1064 .iov_base = "\r\n",1064 .base = "\r\n",
1065 .iov_len = 2,1065 .len = 2,
1066 };1066 };
1067 iovecs_len += 1;1067 iovecs_len += 1;
1068 }1068 }
10691069
1070 if (end_trailers) |trailers| {1070 if (end_trailers) |trailers| {
1071 iovecs[iovecs_len] = .{1071 iovecs[iovecs_len] = .{
1072 .iov_base = "0\r\n",1072 .base = "0\r\n",
1073 .iov_len = 3,1073 .len = 3,
1074 };1074 };
1075 iovecs_len += 1;1075 iovecs_len += 1;
10761076
1077 for (trailers) |trailer| {1077 for (trailers) |trailer| {
1078 iovecs[iovecs_len] = .{1078 iovecs[iovecs_len] = .{
1079 .iov_base = trailer.name.ptr,1079 .base = trailer.name.ptr,
1080 .iov_len = trailer.name.len,1080 .len = trailer.name.len,
1081 };1081 };
1082 iovecs_len += 1;1082 iovecs_len += 1;
10831083
1084 iovecs[iovecs_len] = .{1084 iovecs[iovecs_len] = .{
1085 .iov_base = ": ",1085 .base = ": ",
1086 .iov_len = 2,1086 .len = 2,
1087 };1087 };
1088 iovecs_len += 1;1088 iovecs_len += 1;
10891089
1090 if (trailer.value.len != 0) {1090 if (trailer.value.len != 0) {
1091 iovecs[iovecs_len] = .{1091 iovecs[iovecs_len] = .{
1092 .iov_base = trailer.value.ptr,1092 .base = trailer.value.ptr,
1093 .iov_len = trailer.value.len,1093 .len = trailer.value.len,
1094 };1094 };
1095 iovecs_len += 1;1095 iovecs_len += 1;
1096 }1096 }
10971097
1098 iovecs[iovecs_len] = .{1098 iovecs[iovecs_len] = .{
1099 .iov_base = "\r\n",1099 .base = "\r\n",
1100 .iov_len = 2,1100 .len = 2,
1101 };1101 };
1102 iovecs_len += 1;1102 iovecs_len += 1;
1103 }1103 }
11041104
1105 iovecs[iovecs_len] = .{1105 iovecs[iovecs_len] = .{
1106 .iov_base = "\r\n",1106 .base = "\r\n",
1107 .iov_len = 2,1107 .len = 2,
1108 };1108 };
1109 iovecs_len += 1;1109 iovecs_len += 1;
1110 }1110 }
lib/std/net.zig+5-5
...@@ -1826,7 +1826,7 @@ pub const Stream = struct {...@@ -1826,7 +1826,7 @@ pub const Stream = struct {
1826 // TODO improve this to use ReadFileScatter1826 // TODO improve this to use ReadFileScatter
1827 if (iovecs.len == 0) return @as(usize, 0);1827 if (iovecs.len == 0) return @as(usize, 0);
1828 const first = iovecs[0];1828 const first = iovecs[0];
1829 return windows.ReadFile(s.handle, first.iov_base[0..first.iov_len], null);1829 return windows.ReadFile(s.handle, first.base[0..first.len], null);
1830 }1830 }
18311831
1832 return posix.readv(s.handle, iovecs);1832 return posix.readv(s.handle, iovecs);
...@@ -1889,13 +1889,13 @@ pub const Stream = struct {...@@ -1889,13 +1889,13 @@ pub const Stream = struct {
1889 var i: usize = 0;1889 var i: usize = 0;
1890 while (true) {1890 while (true) {
1891 var amt = try self.writev(iovecs[i..]);1891 var amt = try self.writev(iovecs[i..]);
1892 while (amt >= iovecs[i].iov_len) {1892 while (amt >= iovecs[i].len) {
1893 amt -= iovecs[i].iov_len;1893 amt -= iovecs[i].len;
1894 i += 1;1894 i += 1;
1895 if (i >= iovecs.len) return;1895 if (i >= iovecs.len) return;
1896 }1896 }
1897 iovecs[i].iov_base += amt;1897 iovecs[i].base += amt;
1898 iovecs[i].iov_len -= amt;1898 iovecs[i].len -= amt;
1899 }1899 }
1900 }1900 }
1901};1901};
lib/std/os/linux.zig+2-2
...@@ -1644,7 +1644,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize...@@ -1644,7 +1644,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
1644 var size: i32 = 0;1644 var size: i32 = 0;
1645 const msg_iovlen = @as(usize, @intCast(msg.msg_hdr.msg_iovlen)); // kernel side this is treated as unsigned1645 const msg_iovlen = @as(usize, @intCast(msg.msg_hdr.msg_iovlen)); // kernel side this is treated as unsigned
1646 for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov| {1646 for (msg.msg_hdr.msg_iov[0..msg_iovlen]) |iov| {
1647 if (iov.iov_len > std.math.maxInt(i32) or @addWithOverflow(size, @as(i32, @intCast(iov.iov_len)))[1] != 0) {1647 if (iov.len > std.math.maxInt(i32) or @addWithOverflow(size, @as(i32, @intCast(iov.len)))[1] != 0) {
1648 // batch-send all messages up to the current message1648 // batch-send all messages up to the current message
1649 if (next_unsent < i) {1649 if (next_unsent < i) {
1650 const batch_size = i - next_unsent;1650 const batch_size = i - next_unsent;
...@@ -1660,7 +1660,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize...@@ -1660,7 +1660,7 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
1660 next_unsent = i + 1;1660 next_unsent = i + 1;
1661 break;1661 break;
1662 }1662 }
1663 size += iov.iov_len;1663 size += iov.len;
1664 }1664 }
1665 }1665 }
1666 if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG.EOR)1666 if (next_unsent < kvlen or next_unsent == 0) { // want to make sure at least one syscall occurs (e.g. to trigger MSG.EOR)
lib/std/os/linux/IoUring.zig+12-12
...@@ -1766,7 +1766,7 @@ test "readv" {...@@ -1766,7 +1766,7 @@ test "readv" {
1766 try ring.register_files(registered_fds[0..]);1766 try ring.register_files(registered_fds[0..]);
17671767
1768 var buffer = [_]u8{42} ** 128;1768 var buffer = [_]u8{42} ** 128;
1769 var iovecs = [_]posix.iovec{posix.iovec{ .iov_base = &buffer, .iov_len = buffer.len }};1769 var iovecs = [_]posix.iovec{posix.iovec{ .base = &buffer, .len = buffer.len }};
1770 const sqe = try ring.read(0xcccccccc, fd_index, .{ .iovecs = iovecs[0..] }, 0);1770 const sqe = try ring.read(0xcccccccc, fd_index, .{ .iovecs = iovecs[0..] }, 0);
1771 try testing.expectEqual(linux.IORING_OP.READV, sqe.opcode);1771 try testing.expectEqual(linux.IORING_OP.READV, sqe.opcode);
1772 sqe.flags |= linux.IOSQE_FIXED_FILE;1772 sqe.flags |= linux.IOSQE_FIXED_FILE;
...@@ -1803,11 +1803,11 @@ test "writev/fsync/readv" {...@@ -1803,11 +1803,11 @@ test "writev/fsync/readv" {
18031803
1804 const buffer_write = [_]u8{42} ** 128;1804 const buffer_write = [_]u8{42} ** 128;
1805 const iovecs_write = [_]posix.iovec_const{1805 const iovecs_write = [_]posix.iovec_const{
1806 posix.iovec_const{ .iov_base = &buffer_write, .iov_len = buffer_write.len },1806 posix.iovec_const{ .base = &buffer_write, .len = buffer_write.len },
1807 };1807 };
1808 var buffer_read = [_]u8{0} ** 128;1808 var buffer_read = [_]u8{0} ** 128;
1809 var iovecs_read = [_]posix.iovec{1809 var iovecs_read = [_]posix.iovec{
1810 posix.iovec{ .iov_base = &buffer_read, .iov_len = buffer_read.len },1810 posix.iovec{ .base = &buffer_read, .len = buffer_read.len },
1811 };1811 };
18121812
1813 const sqe_writev = try ring.writev(0xdddddddd, fd, iovecs_write[0..], 17);1813 const sqe_writev = try ring.writev(0xdddddddd, fd, iovecs_write[0..], 17);
...@@ -1995,8 +1995,8 @@ test "write_fixed/read_fixed" {...@@ -1995,8 +1995,8 @@ test "write_fixed/read_fixed" {
1995 raw_buffers[0][0.."foobar".len].* = "foobar".*;1995 raw_buffers[0][0.."foobar".len].* = "foobar".*;
19961996
1997 var buffers = [2]posix.iovec{1997 var buffers = [2]posix.iovec{
1998 .{ .iov_base = &raw_buffers[0], .iov_len = raw_buffers[0].len },1998 .{ .base = &raw_buffers[0], .len = raw_buffers[0].len },
1999 .{ .iov_base = &raw_buffers[1], .iov_len = raw_buffers[1].len },1999 .{ .base = &raw_buffers[1], .len = raw_buffers[1].len },
2000 };2000 };
2001 ring.register_buffers(&buffers) catch |err| switch (err) {2001 ring.register_buffers(&buffers) catch |err| switch (err) {
2002 error.SystemResources => {2002 error.SystemResources => {
...@@ -2022,18 +2022,18 @@ test "write_fixed/read_fixed" {...@@ -2022,18 +2022,18 @@ test "write_fixed/read_fixed" {
20222022
2023 try testing.expectEqual(linux.io_uring_cqe{2023 try testing.expectEqual(linux.io_uring_cqe{
2024 .user_data = 0x45454545,2024 .user_data = 0x45454545,
2025 .res = @as(i32, @intCast(buffers[0].iov_len)),2025 .res = @as(i32, @intCast(buffers[0].len)),
2026 .flags = 0,2026 .flags = 0,
2027 }, cqe_write);2027 }, cqe_write);
2028 try testing.expectEqual(linux.io_uring_cqe{2028 try testing.expectEqual(linux.io_uring_cqe{
2029 .user_data = 0x12121212,2029 .user_data = 0x12121212,
2030 .res = @as(i32, @intCast(buffers[1].iov_len)),2030 .res = @as(i32, @intCast(buffers[1].len)),
2031 .flags = 0,2031 .flags = 0,
2032 }, cqe_read);2032 }, cqe_read);
20332033
2034 try testing.expectEqualSlices(u8, "\x00\x00\x00", buffers[1].iov_base[0..3]);2034 try testing.expectEqualSlices(u8, "\x00\x00\x00", buffers[1].base[0..3]);
2035 try testing.expectEqualSlices(u8, "foobar", buffers[1].iov_base[3..9]);2035 try testing.expectEqualSlices(u8, "foobar", buffers[1].base[3..9]);
2036 try testing.expectEqualSlices(u8, "zz", buffers[1].iov_base[9..11]);2036 try testing.expectEqualSlices(u8, "zz", buffers[1].base[9..11]);
2037}2037}
20382038
2039test "openat" {2039test "openat" {
...@@ -2189,7 +2189,7 @@ test "sendmsg/recvmsg" {...@@ -2189,7 +2189,7 @@ test "sendmsg/recvmsg" {
21892189
2190 const buffer_send = [_]u8{42} ** 128;2190 const buffer_send = [_]u8{42} ** 128;
2191 const iovecs_send = [_]posix.iovec_const{2191 const iovecs_send = [_]posix.iovec_const{
2192 posix.iovec_const{ .iov_base = &buffer_send, .iov_len = buffer_send.len },2192 posix.iovec_const{ .base = &buffer_send, .len = buffer_send.len },
2193 };2193 };
2194 const msg_send: posix.msghdr_const = .{2194 const msg_send: posix.msghdr_const = .{
2195 .name = &address_server.any,2195 .name = &address_server.any,
...@@ -2207,7 +2207,7 @@ test "sendmsg/recvmsg" {...@@ -2207,7 +2207,7 @@ test "sendmsg/recvmsg" {
22072207
2208 var buffer_recv = [_]u8{0} ** 128;2208 var buffer_recv = [_]u8{0} ** 128;
2209 var iovecs_recv = [_]posix.iovec{2209 var iovecs_recv = [_]posix.iovec{
2210 posix.iovec{ .iov_base = &buffer_recv, .iov_len = buffer_recv.len },2210 posix.iovec{ .base = &buffer_recv, .len = buffer_recv.len },
2211 };2211 };
2212 const addr = [_]u8{0} ** 4;2212 const addr = [_]u8{0} ** 4;
2213 var address_recv = net.Address.initIp4(addr, 0);2213 var address_recv = net.Address.initIp4(addr, 0);
lib/std/os/linux/io_uring_sqe.zig+2-2
...@@ -117,12 +117,12 @@ pub const io_uring_sqe = extern struct {...@@ -117,12 +117,12 @@ pub const io_uring_sqe = extern struct {
117 }117 }
118118
119 pub fn prep_read_fixed(sqe: *linux.io_uring_sqe, fd: linux.fd_t, buffer: *std.posix.iovec, offset: u64, buffer_index: u16) void {119 pub fn prep_read_fixed(sqe: *linux.io_uring_sqe, fd: linux.fd_t, buffer: *std.posix.iovec, offset: u64, buffer_index: u16) void {
120 sqe.prep_rw(.READ_FIXED, fd, @intFromPtr(buffer.iov_base), buffer.iov_len, offset);120 sqe.prep_rw(.READ_FIXED, fd, @intFromPtr(buffer.base), buffer.len, offset);
121 sqe.buf_index = buffer_index;121 sqe.buf_index = buffer_index;
122 }122 }
123123
124 pub fn prep_write_fixed(sqe: *linux.io_uring_sqe, fd: linux.fd_t, buffer: *std.posix.iovec, offset: u64, buffer_index: u16) void {124 pub fn prep_write_fixed(sqe: *linux.io_uring_sqe, fd: linux.fd_t, buffer: *std.posix.iovec, offset: u64, buffer_index: u16) void {
125 sqe.prep_rw(.WRITE_FIXED, fd, @intFromPtr(buffer.iov_base), buffer.iov_len, offset);125 sqe.prep_rw(.WRITE_FIXED, fd, @intFromPtr(buffer.base), buffer.len, offset);
126 sqe.buf_index = buffer_index;126 sqe.buf_index = buffer_index;
127 }127 }
128128
lib/std/posix.zig+17-17
...@@ -173,13 +173,13 @@ pub const W_OK = system.W_OK;...@@ -173,13 +173,13 @@ pub const W_OK = system.W_OK;
173pub const X_OK = system.X_OK;173pub const X_OK = system.X_OK;
174174
175pub const iovec = extern struct {175pub const iovec = extern struct {
176 iov_base: [*]u8,176 base: [*]u8,
177 iov_len: usize,177 len: usize,
178};178};
179179
180pub const iovec_const = extern struct {180pub const iovec_const = extern struct {
181 iov_base: [*]const u8,181 base: [*]const u8,
182 iov_len: usize,182 len: usize,
183};183};
184184
185pub const ACCMODE = enum(u2) {185pub const ACCMODE = enum(u2) {
...@@ -796,8 +796,8 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {...@@ -796,8 +796,8 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize {
796 }796 }
797 if (native_os == .wasi and !builtin.link_libc) {797 if (native_os == .wasi and !builtin.link_libc) {
798 const iovs = [1]iovec{iovec{798 const iovs = [1]iovec{iovec{
799 .iov_base = buf.ptr,799 .base = buf.ptr,
800 .iov_len = buf.len,800 .len = buf.len,
801 }};801 }};
802802
803 var nread: usize = undefined;803 var nread: usize = undefined;
...@@ -865,7 +865,7 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize {...@@ -865,7 +865,7 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize {
865 // TODO improve this to use ReadFileScatter865 // TODO improve this to use ReadFileScatter
866 if (iov.len == 0) return 0;866 if (iov.len == 0) return 0;
867 const first = iov[0];867 const first = iov[0];
868 return read(fd, first.iov_base[0..first.iov_len]);868 return read(fd, first.base[0..first.len]);
869 }869 }
870 if (native_os == .wasi and !builtin.link_libc) {870 if (native_os == .wasi and !builtin.link_libc) {
871 var nread: usize = undefined;871 var nread: usize = undefined;
...@@ -932,8 +932,8 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize {...@@ -932,8 +932,8 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize {
932 }932 }
933 if (native_os == .wasi and !builtin.link_libc) {933 if (native_os == .wasi and !builtin.link_libc) {
934 const iovs = [1]iovec{iovec{934 const iovs = [1]iovec{iovec{
935 .iov_base = buf.ptr,935 .base = buf.ptr,
936 .iov_len = buf.len,936 .len = buf.len,
937 }};937 }};
938938
939 var nread: usize = undefined;939 var nread: usize = undefined;
...@@ -1077,7 +1077,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {...@@ -1077,7 +1077,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize {
1077 // So we simply read into the first vector only.1077 // So we simply read into the first vector only.
1078 if (iov.len == 0) return 0;1078 if (iov.len == 0) return 0;
1079 const first = iov[0];1079 const first = iov[0];
1080 return pread(fd, first.iov_base[0..first.iov_len], offset);1080 return pread(fd, first.base[0..first.len], offset);
1081 }1081 }
1082 if (native_os == .wasi and !builtin.link_libc) {1082 if (native_os == .wasi and !builtin.link_libc) {
1083 var nread: usize = undefined;1083 var nread: usize = undefined;
...@@ -1186,8 +1186,8 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {...@@ -1186,8 +1186,8 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize {
11861186
1187 if (native_os == .wasi and !builtin.link_libc) {1187 if (native_os == .wasi and !builtin.link_libc) {
1188 const ciovs = [_]iovec_const{iovec_const{1188 const ciovs = [_]iovec_const{iovec_const{
1189 .iov_base = bytes.ptr,1189 .base = bytes.ptr,
1190 .iov_len = bytes.len,1190 .len = bytes.len,
1191 }};1191 }};
1192 var nwritten: usize = undefined;1192 var nwritten: usize = undefined;
1193 switch (wasi.fd_write(fd, &ciovs, ciovs.len, &nwritten)) {1193 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 {...@@ -1263,7 +1263,7 @@ pub fn writev(fd: fd_t, iov: []const iovec_const) WriteError!usize {
1263 // TODO improve this to use WriteFileScatter1263 // TODO improve this to use WriteFileScatter
1264 if (iov.len == 0) return 0;1264 if (iov.len == 0) return 0;
1265 const first = iov[0];1265 const first = iov[0];
1266 return write(fd, first.iov_base[0..first.iov_len]);1266 return write(fd, first.base[0..first.len]);
1267 }1267 }
1268 if (native_os == .wasi and !builtin.link_libc) {1268 if (native_os == .wasi and !builtin.link_libc) {
1269 var nwritten: usize = undefined;1269 var nwritten: usize = undefined;
...@@ -1340,8 +1340,8 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {...@@ -1340,8 +1340,8 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize {
1340 }1340 }
1341 if (native_os == .wasi and !builtin.link_libc) {1341 if (native_os == .wasi and !builtin.link_libc) {
1342 const ciovs = [1]iovec_const{iovec_const{1342 const ciovs = [1]iovec_const{iovec_const{
1343 .iov_base = bytes.ptr,1343 .base = bytes.ptr,
1344 .iov_len = bytes.len,1344 .len = bytes.len,
1345 }};1345 }};
13461346
1347 var nwritten: usize = undefined;1347 var nwritten: usize = undefined;
...@@ -1432,7 +1432,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz...@@ -1432,7 +1432,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz
1432 // So we simply write the first vector only.1432 // So we simply write the first vector only.
1433 if (iov.len == 0) return 0;1433 if (iov.len == 0) return 0;
1434 const first = iov[0];1434 const first = iov[0];
1435 return pwrite(fd, first.iov_base[0..first.iov_len], offset);1435 return pwrite(fd, first.base[0..first.len], offset);
1436 }1436 }
1437 if (native_os == .wasi and !builtin.link_libc) {1437 if (native_os == .wasi and !builtin.link_libc) {
1438 var nwritten: usize = undefined;1438 var nwritten: usize = undefined;
...@@ -6361,7 +6361,7 @@ pub fn sendfile(...@@ -6361,7 +6361,7 @@ pub fn sendfile(
6361fn count_iovec_bytes(iovs: []const iovec_const) usize {6361fn count_iovec_bytes(iovs: []const iovec_const) usize {
6362 var count: usize = 0;6362 var count: usize = 0;
6363 for (iovs) |iov| {6363 for (iovs) |iov| {
6364 count += iov.iov_len;6364 count += iov.len;
6365 }6365 }
6366 return count;6366 return count;
6367}6367}
lib/std/posix/test.zig+1-1
...@@ -939,7 +939,7 @@ test "writev longer than IOV_MAX" {...@@ -939,7 +939,7 @@ test "writev longer than IOV_MAX" {
939 var file = try tmp.dir.createFile("pwritev", .{});939 var file = try tmp.dir.createFile("pwritev", .{});
940 defer file.close();940 defer file.close();
941941
942 const iovecs = [_]posix.iovec_const{.{ .iov_base = "a", .iov_len = 1 }} ** (posix.IOV_MAX + 1);942 const iovecs = [_]posix.iovec_const{.{ .base = "a", .len = 1 }} ** (posix.IOV_MAX + 1);
943 const amt = try file.writev(&iovecs);943 const amt = try file.writev(&iovecs);
944 try testing.expectEqual(@as(usize, posix.IOV_MAX), amt);944 try testing.expectEqual(@as(usize, posix.IOV_MAX), amt);
945}945}
lib/std/zig/Server.zig+4-4
...@@ -149,13 +149,13 @@ pub fn serveMessage(...@@ -149,13 +149,13 @@ pub fn serveMessage(
149 var iovecs: [10]std.posix.iovec_const = undefined;149 var iovecs: [10]std.posix.iovec_const = undefined;
150 const header_le = bswap(header);150 const header_le = bswap(header);
151 iovecs[0] = .{151 iovecs[0] = .{
152 .iov_base = @as([*]const u8, @ptrCast(&header_le)),152 .base = @as([*]const u8, @ptrCast(&header_le)),
153 .iov_len = @sizeOf(OutMessage.Header),153 .len = @sizeOf(OutMessage.Header),
154 };154 };
155 for (bufs, iovecs[1 .. bufs.len + 1]) |buf, *iovec| {155 for (bufs, iovecs[1 .. bufs.len + 1]) |buf, *iovec| {
156 iovec.* = .{156 iovec.* = .{
157 .iov_base = buf.ptr,157 .base = buf.ptr,
158 .iov_len = buf.len,158 .len = buf.len,
159 };159 };
160 }160 }
161 try s.out.writevAll(iovecs[0 .. bufs.len + 1]);161 try s.out.writevAll(iovecs[0 .. bufs.len + 1]);
src/Compilation.zig+4-4
...@@ -2811,8 +2811,8 @@ fn addBuf(bufs_list: []std.posix.iovec_const, bufs_len: *usize, buf: []const u8)...@@ -2811,8 +2811,8 @@ fn addBuf(bufs_list: []std.posix.iovec_const, bufs_len: *usize, buf: []const u8)
2811 const i = bufs_len.*;2811 const i = bufs_len.*;
2812 bufs_len.* = i + 1;2812 bufs_len.* = i + 1;
2813 bufs_list[i] = .{2813 bufs_list[i] = .{
2814 .iov_base = buf.ptr,2814 .base = buf.ptr,
2815 .iov_len = buf.len,2815 .len = buf.len,
2816 };2816 };
2817}2817}
28182818
...@@ -3800,8 +3800,8 @@ fn docsCopyModule(comp: *Compilation, module: *Package.Module, name: []const u8,...@@ -3800,8 +3800,8 @@ fn docsCopyModule(comp: *Compilation, module: *Package.Module, name: []const u8,
3800 };3800 };
38013801
3802 var header_and_trailer: [2]std.posix.iovec_const = .{3802 var header_and_trailer: [2]std.posix.iovec_const = .{
3803 .{ .iov_base = header_bytes.ptr, .iov_len = header_bytes.len },3803 .{ .base = header_bytes.ptr, .len = header_bytes.len },
3804 .{ .iov_base = padding.ptr, .iov_len = padding.len },3804 .{ .base = padding.ptr, .len = padding.len },
3805 };3805 };
38063806
3807 try tar_file.writeFileAll(file, .{3807 try tar_file.writeFileAll(file, .{
src/Module.zig+18-18
...@@ -2336,24 +2336,24 @@ pub fn astGenFile(mod: *Module, file: *File) !void {...@@ -2336,24 +2336,24 @@ pub fn astGenFile(mod: *Module, file: *File) !void {
2336 };2336 };
2337 var iovecs = [_]std.posix.iovec_const{2337 var iovecs = [_]std.posix.iovec_const{
2338 .{2338 .{
2339 .iov_base = @as([*]const u8, @ptrCast(&header)),2339 .base = @as([*]const u8, @ptrCast(&header)),
2340 .iov_len = @sizeOf(Zir.Header),2340 .len = @sizeOf(Zir.Header),
2341 },2341 },
2342 .{2342 .{
2343 .iov_base = @as([*]const u8, @ptrCast(file.zir.instructions.items(.tag).ptr)),2343 .base = @as([*]const u8, @ptrCast(file.zir.instructions.items(.tag).ptr)),
2344 .iov_len = file.zir.instructions.len,2344 .len = file.zir.instructions.len,
2345 },2345 },
2346 .{2346 .{
2347 .iov_base = data_ptr,2347 .base = data_ptr,
2348 .iov_len = file.zir.instructions.len * 8,2348 .len = file.zir.instructions.len * 8,
2349 },2349 },
2350 .{2350 .{
2351 .iov_base = file.zir.string_bytes.ptr,2351 .base = file.zir.string_bytes.ptr,
2352 .iov_len = file.zir.string_bytes.len,2352 .len = file.zir.string_bytes.len,
2353 },2353 },
2354 .{2354 .{
2355 .iov_base = @as([*]const u8, @ptrCast(file.zir.extra.ptr)),2355 .base = @as([*]const u8, @ptrCast(file.zir.extra.ptr)),
2356 .iov_len = file.zir.extra.len * 4,2356 .len = file.zir.extra.len * 4,
2357 },2357 },
2358 };2358 };
2359 cache_file.writevAll(&iovecs) catch |err| {2359 cache_file.writevAll(&iovecs) catch |err| {
...@@ -2424,20 +2424,20 @@ fn loadZirCacheBody(gpa: Allocator, header: Zir.Header, cache_file: std.fs.File)...@@ -2424,20 +2424,20 @@ fn loadZirCacheBody(gpa: Allocator, header: Zir.Header, cache_file: std.fs.File)
24242424
2425 var iovecs = [_]std.posix.iovec{2425 var iovecs = [_]std.posix.iovec{
2426 .{2426 .{
2427 .iov_base = @as([*]u8, @ptrCast(zir.instructions.items(.tag).ptr)),2427 .base = @as([*]u8, @ptrCast(zir.instructions.items(.tag).ptr)),
2428 .iov_len = header.instructions_len,2428 .len = header.instructions_len,
2429 },2429 },
2430 .{2430 .{
2431 .iov_base = data_ptr,2431 .base = data_ptr,
2432 .iov_len = header.instructions_len * 8,2432 .len = header.instructions_len * 8,
2433 },2433 },
2434 .{2434 .{
2435 .iov_base = zir.string_bytes.ptr,2435 .base = zir.string_bytes.ptr,
2436 .iov_len = header.string_bytes_len,2436 .len = header.string_bytes_len,
2437 },2437 },
2438 .{2438 .{
2439 .iov_base = @as([*]u8, @ptrCast(zir.extra.ptr)),2439 .base = @as([*]u8, @ptrCast(zir.extra.ptr)),
2440 .iov_len = header.extra_len * 4,2440 .len = header.extra_len * 4,
2441 },2441 },
2442 };2442 };
2443 const amt_read = try cache_file.readvAll(&iovecs);2443 const amt_read = try cache_file.readvAll(&iovecs);
src/link/C.zig+9-9
...@@ -483,15 +483,15 @@ pub fn flushModule(self: *C, arena: Allocator, prog_node: *std.Progress.Node) !v...@@ -483,15 +483,15 @@ pub fn flushModule(self: *C, arena: Allocator, prog_node: *std.Progress.Node) !v
483 }483 }
484484
485 f.all_buffers.items[ctypes_index] = .{485 f.all_buffers.items[ctypes_index] = .{
486 .iov_base = if (f.ctypes_buf.items.len > 0) f.ctypes_buf.items.ptr else "",486 .base = if (f.ctypes_buf.items.len > 0) f.ctypes_buf.items.ptr else "",
487 .iov_len = f.ctypes_buf.items.len,487 .len = f.ctypes_buf.items.len,
488 };488 };
489 f.file_size += f.ctypes_buf.items.len;489 f.file_size += f.ctypes_buf.items.len;
490490
491 const lazy_fwd_decl_len = self.lazy_fwd_decl_buf.items.len;491 const lazy_fwd_decl_len = self.lazy_fwd_decl_buf.items.len;
492 f.all_buffers.items[lazy_index] = .{492 f.all_buffers.items[lazy_index] = .{
493 .iov_base = if (lazy_fwd_decl_len > 0) self.lazy_fwd_decl_buf.items.ptr else "",493 .base = if (lazy_fwd_decl_len > 0) self.lazy_fwd_decl_buf.items.ptr else "",
494 .iov_len = lazy_fwd_decl_len,494 .len = lazy_fwd_decl_len,
495 };495 };
496 f.file_size += lazy_fwd_decl_len;496 f.file_size += lazy_fwd_decl_len;
497497
...@@ -527,7 +527,7 @@ const Flush = struct {...@@ -527,7 +527,7 @@ const Flush = struct {
527527
528 fn appendBufAssumeCapacity(f: *Flush, buf: []const u8) void {528 fn appendBufAssumeCapacity(f: *Flush, buf: []const u8) void {
529 if (buf.len == 0) return;529 if (buf.len == 0) return;
530 f.all_buffers.appendAssumeCapacity(.{ .iov_base = buf.ptr, .iov_len = buf.len });530 f.all_buffers.appendAssumeCapacity(.{ .base = buf.ptr, .len = buf.len });
531 f.file_size += buf.len;531 f.file_size += buf.len;
532 }532 }
533533
...@@ -747,8 +747,8 @@ pub fn flushEmitH(zcu: *Zcu) !void {...@@ -747,8 +747,8 @@ pub fn flushEmitH(zcu: *Zcu) !void {
747 var file_size: u64 = zig_h.len;747 var file_size: u64 = zig_h.len;
748 if (zig_h.len != 0) {748 if (zig_h.len != 0) {
749 all_buffers.appendAssumeCapacity(.{749 all_buffers.appendAssumeCapacity(.{
750 .iov_base = zig_h,750 .base = zig_h,
751 .iov_len = zig_h.len,751 .len = zig_h.len,
752 });752 });
753 }753 }
754754
...@@ -757,8 +757,8 @@ pub fn flushEmitH(zcu: *Zcu) !void {...@@ -757,8 +757,8 @@ pub fn flushEmitH(zcu: *Zcu) !void {
757 const buf = decl_emit_h.fwd_decl.items;757 const buf = decl_emit_h.fwd_decl.items;
758 if (buf.len != 0) {758 if (buf.len != 0) {
759 all_buffers.appendAssumeCapacity(.{759 all_buffers.appendAssumeCapacity(.{
760 .iov_base = buf.ptr,760 .base = buf.ptr,
761 .iov_len = buf.len,761 .len = buf.len,
762 });762 });
763 file_size += buf.len;763 file_size += buf.len;
764 }764 }
src/link/Dwarf.zig+26-26
...@@ -2120,32 +2120,32 @@ fn pwriteDbgLineNops(...@@ -2120,32 +2120,32 @@ fn pwriteDbgLineNops(
2120 var padding_left = prev_padding_size;2120 var padding_left = prev_padding_size;
2121 if (padding_left % 2 != 0) {2121 if (padding_left % 2 != 0) {
2122 vecs[vec_index] = .{2122 vecs[vec_index] = .{
2123 .iov_base = &three_byte_nop,2123 .base = &three_byte_nop,
2124 .iov_len = three_byte_nop.len,2124 .len = three_byte_nop.len,
2125 };2125 };
2126 vec_index += 1;2126 vec_index += 1;
2127 padding_left -= three_byte_nop.len;2127 padding_left -= three_byte_nop.len;
2128 }2128 }
2129 while (padding_left > page_of_nops.len) {2129 while (padding_left > page_of_nops.len) {
2130 vecs[vec_index] = .{2130 vecs[vec_index] = .{
2131 .iov_base = &page_of_nops,2131 .base = &page_of_nops,
2132 .iov_len = page_of_nops.len,2132 .len = page_of_nops.len,
2133 };2133 };
2134 vec_index += 1;2134 vec_index += 1;
2135 padding_left -= page_of_nops.len;2135 padding_left -= page_of_nops.len;
2136 }2136 }
2137 if (padding_left > 0) {2137 if (padding_left > 0) {
2138 vecs[vec_index] = .{2138 vecs[vec_index] = .{
2139 .iov_base = &page_of_nops,2139 .base = &page_of_nops,
2140 .iov_len = padding_left,2140 .len = padding_left,
2141 };2141 };
2142 vec_index += 1;2142 vec_index += 1;
2143 }2143 }
2144 }2144 }
21452145
2146 vecs[vec_index] = .{2146 vecs[vec_index] = .{
2147 .iov_base = buf.ptr,2147 .base = buf.ptr,
2148 .iov_len = buf.len,2148 .len = buf.len,
2149 };2149 };
2150 if (buf.len > 0) vec_index += 1;2150 if (buf.len > 0) vec_index += 1;
21512151
...@@ -2153,24 +2153,24 @@ fn pwriteDbgLineNops(...@@ -2153,24 +2153,24 @@ fn pwriteDbgLineNops(
2153 var padding_left = next_padding_size;2153 var padding_left = next_padding_size;
2154 if (padding_left % 2 != 0) {2154 if (padding_left % 2 != 0) {
2155 vecs[vec_index] = .{2155 vecs[vec_index] = .{
2156 .iov_base = &three_byte_nop,2156 .base = &three_byte_nop,
2157 .iov_len = three_byte_nop.len,2157 .len = three_byte_nop.len,
2158 };2158 };
2159 vec_index += 1;2159 vec_index += 1;
2160 padding_left -= three_byte_nop.len;2160 padding_left -= three_byte_nop.len;
2161 }2161 }
2162 while (padding_left > page_of_nops.len) {2162 while (padding_left > page_of_nops.len) {
2163 vecs[vec_index] = .{2163 vecs[vec_index] = .{
2164 .iov_base = &page_of_nops,2164 .base = &page_of_nops,
2165 .iov_len = page_of_nops.len,2165 .len = page_of_nops.len,
2166 };2166 };
2167 vec_index += 1;2167 vec_index += 1;
2168 padding_left -= page_of_nops.len;2168 padding_left -= page_of_nops.len;
2169 }2169 }
2170 if (padding_left > 0) {2170 if (padding_left > 0) {
2171 vecs[vec_index] = .{2171 vecs[vec_index] = .{
2172 .iov_base = &page_of_nops,2172 .base = &page_of_nops,
2173 .iov_len = padding_left,2173 .len = padding_left,
2174 };2174 };
2175 vec_index += 1;2175 vec_index += 1;
2176 }2176 }
...@@ -2237,24 +2237,24 @@ fn pwriteDbgInfoNops(...@@ -2237,24 +2237,24 @@ fn pwriteDbgInfoNops(
2237 var padding_left = prev_padding_size;2237 var padding_left = prev_padding_size;
2238 while (padding_left > page_of_nops.len) {2238 while (padding_left > page_of_nops.len) {
2239 vecs[vec_index] = .{2239 vecs[vec_index] = .{
2240 .iov_base = &page_of_nops,2240 .base = &page_of_nops,
2241 .iov_len = page_of_nops.len,2241 .len = page_of_nops.len,
2242 };2242 };
2243 vec_index += 1;2243 vec_index += 1;
2244 padding_left -= page_of_nops.len;2244 padding_left -= page_of_nops.len;
2245 }2245 }
2246 if (padding_left > 0) {2246 if (padding_left > 0) {
2247 vecs[vec_index] = .{2247 vecs[vec_index] = .{
2248 .iov_base = &page_of_nops,2248 .base = &page_of_nops,
2249 .iov_len = padding_left,2249 .len = padding_left,
2250 };2250 };
2251 vec_index += 1;2251 vec_index += 1;
2252 }2252 }
2253 }2253 }
22542254
2255 vecs[vec_index] = .{2255 vecs[vec_index] = .{
2256 .iov_base = buf.ptr,2256 .base = buf.ptr,
2257 .iov_len = buf.len,2257 .len = buf.len,
2258 };2258 };
2259 if (buf.len > 0) vec_index += 1;2259 if (buf.len > 0) vec_index += 1;
22602260
...@@ -2262,16 +2262,16 @@ fn pwriteDbgInfoNops(...@@ -2262,16 +2262,16 @@ fn pwriteDbgInfoNops(
2262 var padding_left = next_padding_size;2262 var padding_left = next_padding_size;
2263 while (padding_left > page_of_nops.len) {2263 while (padding_left > page_of_nops.len) {
2264 vecs[vec_index] = .{2264 vecs[vec_index] = .{
2265 .iov_base = &page_of_nops,2265 .base = &page_of_nops,
2266 .iov_len = page_of_nops.len,2266 .len = page_of_nops.len,
2267 };2267 };
2268 vec_index += 1;2268 vec_index += 1;
2269 padding_left -= page_of_nops.len;2269 padding_left -= page_of_nops.len;
2270 }2270 }
2271 if (padding_left > 0) {2271 if (padding_left > 0) {
2272 vecs[vec_index] = .{2272 vecs[vec_index] = .{
2273 .iov_base = &page_of_nops,2273 .base = &page_of_nops,
2274 .iov_len = padding_left,2274 .len = padding_left,
2275 };2275 };
2276 vec_index += 1;2276 vec_index += 1;
2277 }2277 }
...@@ -2280,8 +2280,8 @@ fn pwriteDbgInfoNops(...@@ -2280,8 +2280,8 @@ fn pwriteDbgInfoNops(
2280 if (trailing_zero) {2280 if (trailing_zero) {
2281 var zbuf = [1]u8{0};2281 var zbuf = [1]u8{0};
2282 vecs[vec_index] = .{2282 vecs[vec_index] = .{
2283 .iov_base = &zbuf,2283 .base = &zbuf,
2284 .iov_len = zbuf.len,2284 .len = zbuf.len,
2285 };2285 };
2286 vec_index += 1;2286 vec_index += 1;
2287 }2287 }
src/link/Elf/ZigObject.zig+4-4
...@@ -965,12 +965,12 @@ fn updateDeclCode(...@@ -965,12 +965,12 @@ fn updateDeclCode(
965 switch (builtin.os.tag) {965 switch (builtin.os.tag) {
966 .linux => {966 .linux => {
967 var code_vec: [1]std.posix.iovec_const = .{.{967 var code_vec: [1]std.posix.iovec_const = .{.{
968 .iov_base = code.ptr,968 .base = code.ptr,
969 .iov_len = code.len,969 .len = code.len,
970 }};970 }};
971 var remote_vec: [1]std.posix.iovec_const = .{.{971 var remote_vec: [1]std.posix.iovec_const = .{.{
972 .iov_base = @as([*]u8, @ptrFromInt(@as(usize, @intCast(sym.address(.{}, elf_file))))),972 .base = @as([*]u8, @ptrFromInt(@as(usize, @intCast(sym.address(.{}, elf_file))))),
973 .iov_len = code.len,973 .len = code.len,
974 }};974 }};
975 const rc = std.os.linux.process_vm_writev(pid, &code_vec, &remote_vec, 0);975 const rc = std.os.linux.process_vm_writev(pid, &code_vec, &remote_vec, 0);
976 switch (std.os.linux.E.init(rc)) {976 switch (std.os.linux.E.init(rc)) {
src/link/Elf/synthetic_sections.zig+4-4
...@@ -314,12 +314,12 @@ pub const ZigGotSection = struct {...@@ -314,12 +314,12 @@ pub const ZigGotSection = struct {
314 switch (builtin.os.tag) {314 switch (builtin.os.tag) {
315 .linux => {315 .linux => {
316 var local_vec: [1]std.posix.iovec_const = .{.{316 var local_vec: [1]std.posix.iovec_const = .{.{
317 .iov_base = &buf,317 .base = &buf,
318 .iov_len = buf.len,318 .len = buf.len,
319 }};319 }};
320 var remote_vec: [1]std.posix.iovec_const = .{.{320 var remote_vec: [1]std.posix.iovec_const = .{.{
321 .iov_base = @as([*]u8, @ptrFromInt(@as(usize, @intCast(vaddr)))),321 .base = @as([*]u8, @ptrFromInt(@as(usize, @intCast(vaddr)))),
322 .iov_len = buf.len,322 .len = buf.len,
323 }};323 }};
324 const rc = std.os.linux.process_vm_writev(pid, &local_vec, &remote_vec, 0);324 const rc = std.os.linux.process_vm_writev(pid, &local_vec, &remote_vec, 0);
325 switch (std.os.linux.E.init(rc)) {325 switch (std.os.linux.E.init(rc)) {
src/link/Plan9.zig+10-10
...@@ -728,7 +728,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node...@@ -728,7 +728,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node
728 const hdr_size = if (self.sixtyfour_bit) @as(usize, 40) else 32;728 const hdr_size = if (self.sixtyfour_bit) @as(usize, 40) else 32;
729 const hdr_slice: []u8 = hdr_buf[0..hdr_size];729 const hdr_slice: []u8 = hdr_buf[0..hdr_size];
730 var foff = hdr_size;730 var foff = hdr_size;
731 iovecs[0] = .{ .iov_base = hdr_slice.ptr, .iov_len = hdr_slice.len };731 iovecs[0] = .{ .base = hdr_slice.ptr, .len = hdr_slice.len };
732 var iovecs_i: usize = 1;732 var iovecs_i: usize = 1;
733 var text_i: u64 = 0;733 var text_i: u64 = 0;
734734
...@@ -757,7 +757,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node...@@ -757,7 +757,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node
757 linecount = out.end_line;757 linecount = out.end_line;
758 }758 }
759 foff += out.code.len;759 foff += out.code.len;
760 iovecs[iovecs_i] = .{ .iov_base = out.code.ptr, .iov_len = out.code.len };760 iovecs[iovecs_i] = .{ .base = out.code.ptr, .len = out.code.len };
761 iovecs_i += 1;761 iovecs_i += 1;
762 const off = self.getAddr(text_i, .t);762 const off = self.getAddr(text_i, .t);
763 text_i += out.code.len;763 text_i += out.code.len;
...@@ -787,7 +787,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node...@@ -787,7 +787,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node
787 const text_atom = if (meta.text_state != .unused) self.getAtomPtr(meta.text_atom) else continue;787 const text_atom = if (meta.text_state != .unused) self.getAtomPtr(meta.text_atom) else continue;
788 const code = text_atom.code.getOwnedCode().?;788 const code = text_atom.code.getOwnedCode().?;
789 foff += code.len;789 foff += code.len;
790 iovecs[iovecs_i] = .{ .iov_base = code.ptr, .iov_len = code.len };790 iovecs[iovecs_i] = .{ .base = code.ptr, .len = code.len };
791 iovecs_i += 1;791 iovecs_i += 1;
792 const off = self.getAddr(text_i, .t);792 const off = self.getAddr(text_i, .t);
793 text_i += code.len;793 text_i += code.len;
...@@ -812,7 +812,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node...@@ -812,7 +812,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node
812 }812 }
813 }813 }
814 // global offset table is in data814 // global offset table is in data
815 iovecs[iovecs_i] = .{ .iov_base = got_table.ptr, .iov_len = got_table.len };815 iovecs[iovecs_i] = .{ .base = got_table.ptr, .len = got_table.len };
816 iovecs_i += 1;816 iovecs_i += 1;
817 // data817 // data
818 var data_i: u64 = got_size;818 var data_i: u64 = got_size;
...@@ -824,7 +824,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node...@@ -824,7 +824,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node
824 const code = entry.value_ptr.*;824 const code = entry.value_ptr.*;
825825
826 foff += code.len;826 foff += code.len;
827 iovecs[iovecs_i] = .{ .iov_base = code.ptr, .iov_len = code.len };827 iovecs[iovecs_i] = .{ .base = code.ptr, .len = code.len };
828 iovecs_i += 1;828 iovecs_i += 1;
829 const off = self.getAddr(data_i, .d);829 const off = self.getAddr(data_i, .d);
830 data_i += code.len;830 data_i += code.len;
...@@ -847,7 +847,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node...@@ -847,7 +847,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node
847 const code = atom.code.getOwnedCode().?; // unnamed consts must own their code847 const code = atom.code.getOwnedCode().?; // unnamed consts must own their code
848 log.debug("write unnamed const: ({s})", .{self.syms.items[atom.sym_index.?].name});848 log.debug("write unnamed const: ({s})", .{self.syms.items[atom.sym_index.?].name});
849 foff += code.len;849 foff += code.len;
850 iovecs[iovecs_i] = .{ .iov_base = code.ptr, .iov_len = code.len };850 iovecs[iovecs_i] = .{ .base = code.ptr, .len = code.len };
851 iovecs_i += 1;851 iovecs_i += 1;
852 const off = self.getAddr(data_i, .d);852 const off = self.getAddr(data_i, .d);
853 data_i += code.len;853 data_i += code.len;
...@@ -868,7 +868,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node...@@ -868,7 +868,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node
868 const code = atom.code.getOwnedCode().?;868 const code = atom.code.getOwnedCode().?;
869 log.debug("write anon decl: {s}", .{self.syms.items[atom.sym_index.?].name});869 log.debug("write anon decl: {s}", .{self.syms.items[atom.sym_index.?].name});
870 foff += code.len;870 foff += code.len;
871 iovecs[iovecs_i] = .{ .iov_base = code.ptr, .iov_len = code.len };871 iovecs[iovecs_i] = .{ .base = code.ptr, .len = code.len };
872 iovecs_i += 1;872 iovecs_i += 1;
873 const off = self.getAddr(data_i, .d);873 const off = self.getAddr(data_i, .d);
874 data_i += code.len;874 data_i += code.len;
...@@ -888,7 +888,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node...@@ -888,7 +888,7 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node
888 const data_atom = if (meta.rodata_state != .unused) self.getAtomPtr(meta.rodata_atom) else continue;888 const data_atom = if (meta.rodata_state != .unused) self.getAtomPtr(meta.rodata_atom) else continue;
889 const code = data_atom.code.getOwnedCode().?; // lazy symbols must own their code889 const code = data_atom.code.getOwnedCode().?; // lazy symbols must own their code
890 foff += code.len;890 foff += code.len;
891 iovecs[iovecs_i] = .{ .iov_base = code.ptr, .iov_len = code.len };891 iovecs[iovecs_i] = .{ .base = code.ptr, .len = code.len };
892 iovecs_i += 1;892 iovecs_i += 1;
893 const off = self.getAddr(data_i, .d);893 const off = self.getAddr(data_i, .d);
894 data_i += code.len;894 data_i += code.len;
...@@ -929,9 +929,9 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node...@@ -929,9 +929,9 @@ pub fn flushModule(self: *Plan9, arena: Allocator, prog_node: *std.Progress.Node
929 const syms = try sym_buf.toOwnedSlice();929 const syms = try sym_buf.toOwnedSlice();
930 defer gpa.free(syms);930 defer gpa.free(syms);
931 assert(2 + self.atomCount() - self.externCount() == iovecs_i); // we didn't write all the decls931 assert(2 + self.atomCount() - self.externCount() == iovecs_i); // we didn't write all the decls
932 iovecs[iovecs_i] = .{ .iov_base = syms.ptr, .iov_len = syms.len };932 iovecs[iovecs_i] = .{ .base = syms.ptr, .len = syms.len };
933 iovecs_i += 1;933 iovecs_i += 1;
934 iovecs[iovecs_i] = .{ .iov_base = linecountinfo.items.ptr, .iov_len = linecountinfo.items.len };934 iovecs[iovecs_i] = .{ .base = linecountinfo.items.ptr, .len = linecountinfo.items.len };
935 iovecs_i += 1;935 iovecs_i += 1;
936 // generate the header936 // generate the header
937 self.hdr = .{937 self.hdr = .{
src/link/Wasm.zig+2-2
...@@ -3047,8 +3047,8 @@ fn writeToFile(...@@ -3047,8 +3047,8 @@ fn writeToFile(
30473047
3048 // finally, write the entire binary into the file.3048 // finally, write the entire binary into the file.
3049 var iovec = [_]std.posix.iovec_const{.{3049 var iovec = [_]std.posix.iovec_const{.{
3050 .iov_base = binary_bytes.items.ptr,3050 .base = binary_bytes.items.ptr,
3051 .iov_len = binary_bytes.items.len,3051 .len = binary_bytes.items.len,
3052 }};3052 }};
3053 try wasm.base.file.?.writevAll(&iovec);3053 try wasm.base.file.?.writevAll(&iovec);
3054}3054}