authorgravatar for bblack@wikimedia.orgBrandon Black <bblack@wikimedia.org> 2025-09-10 14:26:13-05:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-09-12 07:01:04+02:00
loga0ec4e270e680960290642468f6df3ce7e7d7664
tree4dbf57bf61fedd444ad8dcdbbf1cdfe326d9128d
parent4972c987fd41d897148c23ea2e1308811bd797a7

std.os.linux.socketpair(): switch to unsigned args

We need std.os.linux and std.c to agree on the types here, or else we'd have to pointlessly cast across the difference up in the std.posix wrapper. I ran into this as a type error the first time I tried to compile my code that calls posix.socketpair() on Linux without libc. All of our existing socket calls with these kinds of arguments in std (including the existing c.socketpair as well as os.linux.socket in this same file) use unsigned for all of these parameters, and so this brings linux.socketpair() into alignment with everything else.

1 files changed, 3 insertions(+), 3 deletions(-)

lib/std/os/linux.zig+3-3
...@@ -2141,11 +2141,11 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize {...@@ -2141,11 +2141,11 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize {
2141 }2141 }
2142}2142}
21432143
2144pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: *[2]i32) usize {2144pub fn socketpair(domain: u32, socket_type: u32, protocol: u32, fd: *[2]i32) usize {
2145 if (native_arch == .x86) {2145 if (native_arch == .x86) {
2146 return socketcall(SC.socketpair, &[4]usize{ @as(usize, @intCast(domain)), @as(usize, @intCast(socket_type)), @as(usize, @intCast(protocol)), @intFromPtr(fd) });2146 return socketcall(SC.socketpair, &[4]usize{ domain, socket_type, protocol, @intFromPtr(fd) });
2147 }2147 }
2148 return syscall4(.socketpair, @as(usize, @intCast(domain)), @as(usize, @intCast(socket_type)), @as(usize, @intCast(protocol)), @intFromPtr(fd));2148 return syscall4(.socketpair, domain, socket_type, protocol, @intFromPtr(fd));
2149}2149}
21502150
2151pub fn accept(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize {2151pub fn accept(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize {