| ... | ... | @@ -405,7 +405,6 @@ pub fn readv(fd: fd_t, iov: []const iovec) ReadError!usize { |
| 405 | 405 | else => |err| return unexpectedErrno(err), |
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | | |
| 409 | 408 | const iov_count = math.cast(u31, iov.len) catch math.maxInt(u31); |
| 410 | 409 | while (true) { |
| 411 | 410 | // TODO handle the case when iov_len is too large and get rid of this @intCast |
| ... | ... | @@ -2451,9 +2450,8 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t |
| 2451 | 2450 | if (builtin.os.tag == .windows) { |
| 2452 | 2451 | // NOTE: windows translates the SOCK_NONBLOCK/SOCK_CLOEXEC flags into windows-analagous operations |
| 2453 | 2452 | const filtered_sock_type = socket_type & ~@as(u32, SOCK_NONBLOCK | SOCK_CLOEXEC); |
| 2454 | | const flags : u32 = if ((socket_type & SOCK_CLOEXEC) != 0) windows.ws2_32.WSA_FLAG_NO_HANDLE_INHERIT else 0; |
| 2455 | | const rc = windows.ws2_32.WSASocketW(@intCast(c_int, domain), @intCast(c_int, filtered_sock_type), |
| 2456 | | @intCast(c_int, protocol), null, 0, flags); |
| 2453 | const flags: u32 = if ((socket_type & SOCK_CLOEXEC) != 0) windows.ws2_32.WSA_FLAG_NO_HANDLE_INHERIT else 0; |
| 2454 | const rc = windows.ws2_32.WSASocketW(@intCast(c_int, domain), @intCast(c_int, filtered_sock_type), @intCast(c_int, protocol), null, 0, flags); |
| 2457 | 2455 | if (rc == windows.ws2_32.INVALID_SOCKET) switch (windows.ws2_32.WSAGetLastError()) { |
| 2458 | 2456 | .WSAEMFILE => return error.ProcessFdQuotaExceeded, |
| 2459 | 2457 | .WSAENOBUFS => return error.SystemResources, |
| ... | ... | @@ -2463,7 +2461,7 @@ pub fn socket(domain: u32, socket_type: u32, protocol: u32) SocketError!socket_t |
| 2463 | 2461 | }; |
| 2464 | 2462 | errdefer windows.closesocket(rc) catch unreachable; |
| 2465 | 2463 | if ((socket_type & SOCK_NONBLOCK) != 0) { |
| 2466 | | var mode : c_ulong = 1; // nonblocking |
| 2464 | var mode: c_ulong = 1; // nonblocking |
| 2467 | 2465 | if (windows.ws2_32.SOCKET_ERROR == windows.ws2_32.ioctlsocket(rc, windows.ws2_32.FIONBIO, &mode)) { |
| 2468 | 2466 | switch (windows.ws2_32.WSAGetLastError()) { |
| 2469 | 2467 | // have not identified any error codes that should be handled yet |
| ... | ... | @@ -2858,7 +2856,7 @@ pub fn connect(sockfd: socket_t, sock_addr: *const sockaddr, len: socklen_t) Con |
| 2858 | 2856 | .WSAECONNREFUSED => return error.ConnectionRefused, |
| 2859 | 2857 | .WSAETIMEDOUT => return error.ConnectionTimedOut, |
| 2860 | 2858 | .WSAEHOSTUNREACH // TODO: should we return NetworkUnreachable in this case as well? |
| 2861 | | ,.WSAENETUNREACH => return error.NetworkUnreachable, |
| 2859 | , .WSAENETUNREACH => return error.NetworkUnreachable, |
| 2862 | 2860 | .WSAEFAULT => unreachable, |
| 2863 | 2861 | .WSAEINVAL => unreachable, |
| 2864 | 2862 | .WSAEISCONN => unreachable, |
| ... | ... | @@ -4906,3 +4904,17 @@ pub fn tcsetattr(handle: fd_t, optional_action: TCSA, termios_p: termios) Termio |
| 4906 | 4904 | } |
| 4907 | 4905 | } |
| 4908 | 4906 | } |
| 4907 | |
| 4908 | pub fn ioctl(handle: fd_t, request: u32, arg: var) !void { |
| 4909 | switch (errno(system.ioctl(handle, request, arg))) { |
| 4910 | 0 => {}, |
| 4911 | EINVAL => unreachable, |
| 4912 | ENOTTY => unreachable, |
| 4913 | ENXIO => unreachable, |
| 4914 | EBADF => return error.BadFile, |
| 4915 | EINTR => return error.CaughtSignal, |
| 4916 | EIO => return error.FileSystem, |
| 4917 | ENODEV => return error.NoDevice, |
| 4918 | else => |err| return unexpectedErrno(err), |
| 4919 | } |
| 4920 | } |