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 {...@@ -2622,6 +2622,10 @@ pub const libc = struct {
2622 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/write.html2622 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/write.html
2623 pub extern fn write(fd: c_int, buf: *const anyopaque, n: usize) isize;2623 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
2625 /// double y0(double x);2629 /// double y0(double x);
2626 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/y0.html2630 /// https://pubs.opengroup.org/onlinepubs/9699919799.orig/functions/y0.html
2627 pub extern fn y0(x: f64) f64;2631 pub extern fn y0(x: f64) f64;
...@@ -3157,3 +3161,9 @@ pub fn write(fd: c_int, buf: []const u8) !usize {...@@ -3157,3 +3161,9 @@ pub fn write(fd: c_int, buf: []const u8) !usize {
3157 std.debug.assert(rc >= 0);3161 std.debug.assert(rc >= 0);
3158 return @intCast(rc);3162 return @intCast(rc);
3159}3163}
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 {...@@ -31,4 +31,5 @@ test {
31 _ = &linux.memfd_create;31 _ = &linux.memfd_create;
32 _ = &linux.readlinkat;32 _ = &linux.readlinkat;
33 _ = &linux.write;33 _ = &linux.write;
34 _ = &linux.writev;
34}35}