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).
This commit is contained in:
Josh Megnauth
2026-03-29 19:56:28 -04:00
committed by Andrew Kelley
parent 746dd51faf
commit 56507ecf98
4 changed files with 18 additions and 8 deletions
+1
View File
@@ -73,6 +73,7 @@ comptime {
_ = @import("c/stdlib.zig");
_ = @import("c/string.zig");
_ = @import("c/strings.zig");
_ = @import("c/stropts.zig");
_ = @import("c/sys/capability.zig");
_ = @import("c/sys/file.zig");
+17
View File
@@ -0,0 +1,17 @@
const builtin = @import("builtin");
const std = @import("std");
const linux = std.os.linux;
const symbol = @import("../c.zig").symbol;
const errno = @import("../c.zig").errno;
comptime {
if (builtin.target.isMuslLibC()) {
symbol(&isastream, "isastream");
}
}
fn isastream(fd: c_int) callconv(.c) c_int {
return if (errno(linux.fcntl(fd, linux.F.GETFD, 0)) < 0) -1 else 0;
}
-7
View File
@@ -1,7 +0,0 @@
#include <stropts.h>
#include <fcntl.h>
int isastream(int fd)
{
return fcntl(fd, F_GETFD) < 0 ? -1 : 0;
}
-1
View File
@@ -691,7 +691,6 @@ const src_files = [_][]const u8{
"musl/src/legacy/getpagesize.c",
"musl/src/legacy/getpass.c",
"musl/src/legacy/getusershell.c",
"musl/src/legacy/isastream.c",
"musl/src/legacy/lutimes.c",
"musl/src/legacy/ulimit.c",
"musl/src/legacy/utmpx.c",