authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-18 16:36:26 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-18 16:36:26 -08:00
log41d1c3d53babe8d7e6bc135ddaa6c6a2b8ef37fa
tree0e47c6aedcdebb60eab0f8b9490acf5aa5cd90fc
parent54e72bcbd5b6baa04fd1c317458f78f55a18a464

add writev


2 files changed, 11 insertions(+), 0 deletions(-)

mod.zig+10
......@@ -2622,6 +2622,10 @@ pub const libc = struct {
26222622 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/write.html
26232623 pub extern fn write(fd: c_int, buf: *const anyopaque, n: usize) isize;
26242624
2625 /// ssize_t writev(int fildes, const struct iovec *iov, int iovcnt);
2626 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/writev.html
2627 pub extern fn writev(fd: c_int, iovec: [*]const struct_iovec, count: c_int) isize;
2628
26252629 /// double y0(double x);
26262630 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/y0.html
26272631 pub extern fn y0(x: f64) f64;
......@@ -3157,3 +3161,9 @@ pub fn write(fd: c_int, buf: []const u8) !usize {
31573161 std.debug.assert(rc >= 0);
31583162 return @intCast(rc);
31593163}
3164pub fn writev(fd: c_int, iovec: []const struct_iovec) !usize {
3165 const rc = libc.writev(fd, iovec.ptr, @intCast(iovec.len));
3166 if (rc == -1) return errno.fromInt(errno.fromLibC());
3167 std.debug.assert(rc >= 0);
3168 return @intCast(rc);
3169}
test.zig+1
......@@ -31,4 +31,5 @@ test {
3131 _ = &linux.memfd_create;
3232 _ = &linux.readlinkat;
3333 _ = &linux.write;
34 _ = &linux.writev;
3435}