Skip to content

Commit

Permalink
rename iovec and iovec_const members
Browse files Browse the repository at this point in the history
  • Loading branch information
clickingbuttons committed Mar 21, 2024
1 parent 806d945 commit 402cc38
Show file tree
Hide file tree
Showing 46 changed files with 330 additions and 330 deletions.
2 changes: 1 addition & 1 deletion lib/compiler/objcopy.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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{.{ .ptr = data.data.ptr, .len = data.data.len }};
try out_file.pwritevAll(&iovec, data.out_offset);
},
.copy_range => |range| {
Expand Down
10 changes: 5 additions & 5 deletions lib/std/array_list.zig
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
fn appendWritev(self: *Self, iov: []std.posix.iovec_const) Allocator.Error!usize {
var written: usize = 0;
for (iov) |v| {
try self.appendSlice(v.iov_base[0..v.iov_len]);
written += v.iov_len;
try self.appendSlice(v.ptr[0..v.len]);
written += v.len;
}
return written;
}
Expand Down Expand Up @@ -948,8 +948,8 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
fn appendWritev(context: WriterContext, iov: []std.posix.iovec_const) Allocator.Error!usize {
var written: usize = 0;
for (iov) |v| {
try context.self.appendSlice(context.allocator, v.iov_base[0..v.iov_len]);
written += v.iov_len;
try context.self.appendSlice(context.allocator, v.ptr[0..v.len]);
written += v.len;
}
return written;
}
Expand All @@ -966,7 +966,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
fn appendWritevFixed(self: *Self, iov: []std.posix.iovec_const) error{OutOfMemory}!usize {
var written: usize = 0;
for (iov) |v| {
const m = v.iov_base[0..v.iov_len];
const m = v.ptr[0..v.len];
const available_capacity = self.capacity - self.items.len;
if (m.len > available_capacity)
return error.OutOfMemory;
Expand Down
2 changes: 1 addition & 1 deletion lib/std/bounded_array.zig
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ pub fn BoundedArrayAligned(
fn appendWritev(self: *Self, iov: []std.posix.iovec_const) error{Overflow}!usize {
var written: usize = 0;
for (iov) |v| {
const m = v.iov_base[0..v.iov_len];
const m = v.ptr[0..v.len];
try self.appendSlice(m);
written += m.len;
}
Expand Down
8 changes: 4 additions & 4 deletions lib/std/compress.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ pub fn HashedReader(
const n_read = try self.child_reader.readv(iov);
var hashed_amt: usize = 0;
for (iov) |v| {
const to_hash = @min(n_read - hashed_amt, v.iov_len);
const to_hash = @min(n_read - hashed_amt, v.len);
if (to_hash == 0) break;
self.hasher.update(v.iov_base[0..to_hash]);
self.hasher.update(v.ptr[0..to_hash]);
hashed_amt += to_hash;
}
return n_read;
Expand Down Expand Up @@ -61,9 +61,9 @@ pub fn HashedWriter(
const n_written = try self.child_writer.writev(iov);
var hashed_amt: usize = 0;
for (iov) |v| {
const to_hash = @min(n_written - hashed_amt, v.iov_len);
const to_hash = @min(n_written - hashed_amt, v.len);
if (to_hash == 0) break;
self.hasher.update(v.iov_base[0..to_hash]);
self.hasher.update(v.ptr[0..to_hash]);
hashed_amt += to_hash;
}
return n_written;
Expand Down
2 changes: 1 addition & 1 deletion lib/std/compress/flate/deflate.zig
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ fn Deflate(comptime container: Container, comptime WriterType: type, comptime Bl
pub fn writev(self: *Self, iov: []std.posix.iovec_const) !usize {
var written: usize = 0;
for (iov) |v| {
const input = v.iov_base[0..v.iov_len];
const input = v.ptr[0..v.len];
var fbs = io.fixedBufferStream(input);
try self.compress(fbs.reader());
written += input.len;
Expand Down
2 changes: 1 addition & 1 deletion lib/std/compress/flate/inflate.zig
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ pub fn Inflate(comptime container: Container, comptime LookaheadType: type, comp
pub fn readv(self: *Self, iovecs: []std.posix.iovec) Error!usize {
if (iovecs.len == 0) return 0;
const first = iovecs[0];
const buffer = first.iov_base[0..first.iov_len];
const buffer = first.ptr[0..first.len];
const out = try self.get(buffer.len);
@memcpy(buffer[0..out.len], out);
return out.len;
Expand Down
2 changes: 1 addition & 1 deletion lib/std/compress/lzma.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn Decompress(comptime ReaderType: type) type {
const writer = self.to_read.writer(self.allocator);
var n_read: usize = 0;
for (iov) |v| {
const output = v.iov_base[0..v.iov_len];
const output = v.ptr[0..v.len];
while (self.to_read.items.len < output.len) {
switch (try self.state.process(self.allocator, self.in_reader, writer, &self.buffer, &self.decoder)) {
.continue_ => {},
Expand Down
2 changes: 1 addition & 1 deletion lib/std/compress/xz.zig
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn Decompress(comptime ReaderType: type) type {
pub fn readv(self: *Self, iov: []std.posix.iovec) Error!usize {
if (iov.len == 0) return 0;
const first = iov[0];
const buffer = first.iov_base[0..first.iov_len];
const buffer = first.ptr[0..first.len];
if (buffer.len == 0)
return 0;

Expand Down
2 changes: 1 addition & 1 deletion lib/std/compress/zstandard.zig
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn Decompressor(comptime ReaderType: type) type {
pub fn readv(self: *Self, iov: []std.posix.iovec) Error!usize {
if (iov.len == 0) return 0;
const first = iov[0];
const buffer = first.iov_base[0..first.iov_len];
const buffer = first.ptr[0..first.len];
if (buffer.len == 0) return 0;

var size: usize = 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/std/compress/zstandard/readers.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub const ReversedByteReader = struct {
fn readvFn(ctx: *ReversedByteReader, iov: []std.posix.iovec) !usize {
if (iov.len == 0) return 0;
const first = iov[0];
const buffer = first.iov_base[0..first.iov_len];
const buffer = first.ptr[0..first.len];
std.debug.assert(buffer.len > 0);
if (ctx.remaining_bytes == 0) return 0;
const byte_index = ctx.remaining_bytes - 1;
Expand Down
4 changes: 2 additions & 2 deletions lib/std/crypto/sha2.zig
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ fn Sha2x32(comptime params: Sha2Params32) type {
fn writev(self: *Self, iov: []std.posix.iovec_const) Error!usize {
var written: usize = 0;
for (iov) |v| {
self.update(v.iov_base[0..v.iov_len]);
written += v.iov_len;
self.update(v.ptr[0..v.len]);
written += v.len;
}
return written;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/std/crypto/siphash.zig
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize)
fn writev(self: *Self, iov: []std.posix.iovec_const) Error!usize {
var written: usize = 0;
for (iov) |v| {
self.update(v.iov_base[0..v.iov_len]);
written += v.iov_len;
self.update(v.ptr[0..v.len]);
written += v.len;
}
return written;
}
Expand Down
54 changes: 27 additions & 27 deletions lib/std/crypto/tls/Client.zig
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ pub fn init(inner_stream: Stream, ca_bundle: Certificate.Bundle, host: []const u
{
var iovecs = [_]std.posix.iovec_const{
.{
.iov_base = &plaintext_header,
.iov_len = plaintext_header.len,
.ptr = &plaintext_header,
.len = plaintext_header.len,
},
.{
.iov_base = host.ptr,
.iov_len = host.len,
.ptr = host.ptr,
.len = host.len,
},
};
try writer.writevAll(&iovecs);
Expand Down Expand Up @@ -591,8 +591,8 @@ pub fn init(inner_stream: Stream, ca_bundle: Certificate.Bundle, host: []const u

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,
.ptr = &both_msgs,
.len = both_msgs.len,
}};
try writer.writevAll(&both_msgs_vec);

Expand Down Expand Up @@ -658,7 +658,7 @@ pub fn writeEnd(c: *Client, bytes: []const u8, end: bool) !usize {
const iovecs = iovecs_buf[0..prepared.iovec_end];

var n_written: usize = 0;
for (iovecs) |iov| n_written += iov.iov_len;
for (iovecs) |iov| n_written += iov.len;

try c.inner_stream.writer().writevAll(iovecs);

Expand All @@ -668,7 +668,7 @@ pub fn writeEnd(c: *Client, bytes: []const u8, end: bool) !usize {
pub fn writev(c: *Client, iovecs: []std.posix.iovec_const) !usize {
if (iovecs.len == 0) return 0;
const first = iovecs[0];
const bytes = first.iov_base[0..first.iov_len];
const bytes = first.ptr[0..first.len];
return try c.writeEnd(bytes, false);
}

Expand Down Expand Up @@ -744,8 +744,8 @@ fn prepareCiphertextRecord(

const record = ciphertext_buf[record_start..ciphertext_end];
iovecs[iovec_end] = .{
.iov_base = record.ptr,
.iov_len = record.len,
.ptr = record.ptr,
.len = record.len,
};
iovec_end += 1;
}
Expand Down Expand Up @@ -783,12 +783,12 @@ pub fn readvAtLeast(c: *Client, iovecs: []std.posix.iovec, len: usize) !usize {
var amt = try c.readvAdvanced(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].ptr += amt;
iovecs[vec_i].len -= amt;
}
}

Expand Down Expand Up @@ -854,12 +854,12 @@ pub fn readvAdvanced(c: *Client, iovecs: []const std.posix.iovec) !usize {

var ask_iovecs_buf: [2]std.posix.iovec = .{
.{
.iov_base = first_iov.ptr,
.iov_len = first_iov.len,
.ptr = first_iov.ptr,
.len = first_iov.len,
},
.{
.iov_base = &in_stack_buffer,
.iov_len = in_stack_buffer.len,
.ptr = &in_stack_buffer,
.len = in_stack_buffer.len,
},
};

Expand Down Expand Up @@ -1228,12 +1228,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.ptr[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) {
Expand All @@ -1252,15 +1252,15 @@ 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.ptr[vp.off..v.len];
}

// After writing to the result of peek(), one can call next() to
// advance the cursor.
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;
}
Expand All @@ -1269,9 +1269,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;
}
};
Expand All @@ -1280,11 +1280,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;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/std/fifo.zig
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ pub fn LinearFifo(
fn readvFn(self: *Self, iov: []std.posix.iovec) error{}!usize {
var n_read: usize = 0;
for (iov) |v| {
const n = self.read(v.iov_base[0..v.iov_len]);
const n = self.read(v.ptr[0..v.len]);
if (n == 0) return n_read;

n_read += n;
Expand Down Expand Up @@ -331,8 +331,8 @@ pub fn LinearFifo(
fn appendWritev(self: *Self, iov: []std.posix.iovec_const) error{OutOfMemory}!usize {
var written: usize = 0;
for (iov) |v| {
try self.write(v.iov_base[0..v.iov_len]);
written += v.iov_len;
try self.write(v.ptr[0..v.len]);
written += v.len;
}
return written;
}
Expand Down
Loading

0 comments on commit 402cc38

Please sign in to comment.