Skip to content

Commit 3add9d8

Browse files
dweillerandrewrk
authored andcommitted
std.c: fix return type of recv/recvfrom on windows
Windows defines `recv` and `recvfrom` to return a value of type `int`, rather than a pointer-sized signed integer, and so should use `c_int` rather than `isize` for their return types.
1 parent ff57a26 commit 3add9d8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/std/c.zig

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,20 @@ pub extern "c" fn sendto(
213213
) isize;
214214
pub extern "c" fn sendmsg(sockfd: c.fd_t, msg: *const c.msghdr_const, flags: u32) isize;
215215

216-
pub extern "c" fn recv(sockfd: c.fd_t, arg1: ?*anyopaque, arg2: usize, arg3: c_int) isize;
216+
pub extern "c" fn recv(
217+
sockfd: c.fd_t,
218+
arg1: ?*anyopaque,
219+
arg2: usize,
220+
arg3: c_int,
221+
) if (builtin.os.tag == .windows) c_int else isize;
217222
pub extern "c" fn recvfrom(
218223
sockfd: c.fd_t,
219224
noalias buf: *anyopaque,
220225
len: usize,
221226
flags: u32,
222227
noalias src_addr: ?*c.sockaddr,
223228
noalias addrlen: ?*c.socklen_t,
224-
) isize;
229+
) if (builtin.os.tag == .windows) c_int else isize;
225230
pub extern "c" fn recvmsg(sockfd: c.fd_t, msg: *c.msghdr, flags: u32) isize;
226231

227232
pub extern "c" fn kill(pid: c.pid_t, sig: c_int) c_int;

0 commit comments

Comments
 (0)