authorgravatar for jo.sh@tutanota.comJosh Megnauth <jo.sh@tutanota.com> 2026-03-29 19:56:28-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-04-02 15:13:39+02:00
log56507ecf9849719356bb36ed8e5dc539cd060a36
tree7d054d765cd7b151043e265114a33e0d55bb2566
parent746dd51fafa8cdc8d98500af3b3b4b659c1aef92

libzigc: stropts/isastream

`isastream` is an old, deprecated function for the STREAMS framework. Linux doesn't even support this natively, and so the musl implementation just returns 0 (not a STREAMS file) for valid file descriptors or -1 (for bad file descriptors).

4 files changed, 18 insertions(+), 8 deletions(-)

lib/c.zig+1
......@@ -73,6 +73,7 @@ comptime {
7373 _ = @import("c/stdlib.zig");
7474 _ = @import("c/string.zig");
7575 _ = @import("c/strings.zig");
76 _ = @import("c/stropts.zig");
7677
7778 _ = @import("c/sys/capability.zig");
7879 _ = @import("c/sys/file.zig");
lib/c/stropts.zig created+17
......@@ -0,0 +1,17 @@
1const builtin = @import("builtin");
2
3const std = @import("std");
4const linux = std.os.linux;
5
6const symbol = @import("../c.zig").symbol;
7const errno = @import("../c.zig").errno;
8
9comptime {
10 if (builtin.target.isMuslLibC()) {
11 symbol(&isastream, "isastream");
12 }
13}
14
15fn isastream(fd: c_int) callconv(.c) c_int {
16 return if (errno(linux.fcntl(fd, linux.F.GETFD, 0)) < 0) -1 else 0;
17}
lib/libc/musl/src/legacy/isastream.c deleted-7
......@@ -1,7 +0,0 @@
1#include <stropts.h>
2#include <fcntl.h>
3
4int isastream(int fd)
5{
6 return fcntl(fd, F_GETFD) < 0 ? -1 : 0;
7}
src/libs/musl.zig-1
......@@ -691,7 +691,6 @@ const src_files = [_][]const u8{
691691 "musl/src/legacy/getpagesize.c",
692692 "musl/src/legacy/getpass.c",
693693 "musl/src/legacy/getusershell.c",
694 "musl/src/legacy/isastream.c",
695694 "musl/src/legacy/lutimes.c",
696695 "musl/src/legacy/ulimit.c",
697696 "musl/src/legacy/utmpx.c",