authorgravatar for seda18@rolmail.netDavid Senoner <seda18@rolmail.net> 2026-04-18 07:30:43+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-18 07:30:43+02:00
log21914c7c01d8d1071034153451414719906167b8
treee3707276bf48238119cbd2872faab430d9669434
parentff612334fa8af05c42b71f784dff521899026f97

ziglibc: migrate tee linux syscall (#31911)

Add the Linux syscall wrapper for `tee`. Migrate the `tee` syscall from musl libc to zig libc. langref: note `ssize_t` and `isize` are ABI compatible Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31911 Reviewed-by: Andrew Kelley <andrew@ziglang.org> Co-authored-by: David Senoner <seda18@rolmail.net> Co-committed-by: David Senoner <seda18@rolmail.net>

5 files changed, 16 insertions(+), 10 deletions(-)

doc/langref.html.in+1-1
......@@ -525,7 +525,7 @@
525525 </tr>
526526 <tr>
527527 <th scope="row">{#syntax#}isize{#endsyntax#}</th>
528 <td><code class="c">intptr_t</code></td>
528 <td><code class="c">intptr_t</code>, <code class="c">ssize_t</code></td>
529529 <td>signed pointer sized integer</td>
530530 </tr>
531531 <tr>
lib/c/fcntl.zig+5
......@@ -12,6 +12,7 @@ comptime {
1212 symbol(&fallocateLinux, "fallocate");
1313 symbol(&posix_fadviseLinux, "posix_fadvise");
1414 symbol(&posix_fallocateLinux, "posix_fallocate");
15 symbol(&teeLinux, "tee");
1516 }
1617}
1718
......@@ -26,3 +27,7 @@ fn posix_fadviseLinux(fd: c_int, offset: off_t, len: off_t, advice: c_int) callc
2627fn posix_fallocateLinux(fd: c_int, offset: off_t, len: off_t) callconv(.c) c_int {
2728 return errno(linux.fallocate(fd, 0, offset, len));
2829}
30
31fn teeLinux(src: c_int, dest: c_int, len: usize, flags: c_uint) callconv(.c) isize {
32 return errno(linux.tee(src, dest, len, flags));
33}
lib/libc/musl/src/linux/tee.c deleted-8
......@@ -1,8 +0,0 @@
1#define _GNU_SOURCE
2#include <fcntl.h>
3#include "syscall.h"
4
5ssize_t tee(int src, int dest, size_t len, unsigned flags)
6{
7 return syscall(SYS_tee, src, dest, len, flags);
8}
lib/std/os/linux.zig+10
......@@ -2981,6 +2981,16 @@ pub fn map_shadow_stack(addr: usize, size: usize, flags: u32) usize {
29812981 return syscall3(.map_shadow_stack, addr, size, flags);
29822982}
29832983
2984pub fn tee(src: fd_t, dest: fd_t, len: usize, flags: u32) usize {
2985 return syscall4(
2986 .tee,
2987 @as(u32, @bitCast(src)),
2988 @as(u32, @bitCast(dest)),
2989 len,
2990 flags,
2991 );
2992}
2993
29842994pub const Sysinfo = switch (native_abi) {
29852995 .gnux32, .muslx32 => extern struct {
29862996 /// Seconds since boot
src/libs/musl.zig-1
......@@ -745,7 +745,6 @@ const src_files = [_][]const u8{
745745 "musl/src/linux/sync_file_range.c",
746746 "musl/src/linux/syncfs.c",
747747 "musl/src/linux/sysinfo.c",
748 "musl/src/linux/tee.c",
749748 "musl/src/linux/timerfd.c",
750749 "musl/src/linux/unshare.c",
751750 "musl/src/linux/utimes.c",