| ... | ... | @@ -320,6 +320,7 @@ pub const ReadError = error{ |
| 320 | 320 | /// Linux has a limit on how many bytes may be transferred in one `read` call, which is `0x7ffff000` |
| 321 | 321 | /// on both 64-bit and 32-bit systems. This is due to using a signed C int as the return value, as |
| 322 | 322 | /// well as stuffing the errno codes into the last `4096` values. This is noted on the `read` man page. |
| 323 | /// The limit on Darwin is `0x7fffffff`, trying to read more than that returns EINVAL. |
| 323 | 324 | /// For POSIX the limit is `math.maxInt(isize)`. |
| 324 | 325 | pub fn read(fd: fd_t, buf: []u8) ReadError!usize { |
| 325 | 326 | if (builtin.os.tag == .windows) { |
| ... | ... | @@ -353,6 +354,7 @@ pub fn read(fd: fd_t, buf: []u8) ReadError!usize { |
| 353 | 354 | // Prevents EINVAL. |
| 354 | 355 | const max_count = switch (std.Target.current.os.tag) { |
| 355 | 356 | .linux => 0x7ffff000, |
| 357 | .macosx, .ios, .watchos, .tvos => math.maxInt(i32), |
| 356 | 358 | else => math.maxInt(isize), |
| 357 | 359 | }; |
| 358 | 360 | const adjusted_len = math.min(max_count, buf.len); |
| ... | ... | @@ -693,6 +695,7 @@ pub const WriteError = error{ |
| 693 | 695 | /// Linux has a limit on how many bytes may be transferred in one `write` call, which is `0x7ffff000` |
| 694 | 696 | /// on both 64-bit and 32-bit systems. This is due to using a signed C int as the return value, as |
| 695 | 697 | /// well as stuffing the errno codes into the last `4096` values. This is noted on the `write` man page. |
| 698 | /// The limit on Darwin is `0x7fffffff`, trying to read more than that returns EINVAL. |
| 696 | 699 | /// The corresponding POSIX limit is `math.maxInt(isize)`. |
| 697 | 700 | pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { |
| 698 | 701 | if (builtin.os.tag == .windows) { |
| ... | ... | @@ -726,6 +729,7 @@ pub fn write(fd: fd_t, bytes: []const u8) WriteError!usize { |
| 726 | 729 | |
| 727 | 730 | const max_count = switch (std.Target.current.os.tag) { |
| 728 | 731 | .linux => 0x7ffff000, |
| 732 | .macosx, .ios, .watchos, .tvos => math.maxInt(i32), |
| 729 | 733 | else => math.maxInt(isize), |
| 730 | 734 | }; |
| 731 | 735 | const adjusted_len = math.min(max_count, bytes.len); |
| ... | ... | @@ -851,6 +855,7 @@ pub const PWriteError = WriteError || error{Unseekable}; |
| 851 | 855 | /// Linux has a limit on how many bytes may be transferred in one `pwrite` call, which is `0x7ffff000` |
| 852 | 856 | /// on both 64-bit and 32-bit systems. This is due to using a signed C int as the return value, as |
| 853 | 857 | /// well as stuffing the errno codes into the last `4096` values. This is noted on the `write` man page. |
| 858 | /// The limit on Darwin is `0x7fffffff`, trying to write more than that returns EINVAL. |
| 854 | 859 | /// The corresponding POSIX limit is `math.maxInt(isize)`. |
| 855 | 860 | pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { |
| 856 | 861 | if (std.Target.current.os.tag == .windows) { |
| ... | ... | @@ -888,6 +893,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { |
| 888 | 893 | // Prevent EINVAL. |
| 889 | 894 | const max_count = switch (std.Target.current.os.tag) { |
| 890 | 895 | .linux => 0x7ffff000, |
| 896 | .macosx, .ios, .watchos, .tvos => math.maxInt(i32), |
| 891 | 897 | else => math.maxInt(isize), |
| 892 | 898 | }; |
| 893 | 899 | const adjusted_len = math.min(max_count, bytes.len); |
| ... | ... | @@ -3084,7 +3090,7 @@ pub fn connect(sockfd: socket_t, sock_addr: *const sockaddr, len: socklen_t) Con |
| 3084 | 3090 | .WSAECONNREFUSED => return error.ConnectionRefused, |
| 3085 | 3091 | .WSAETIMEDOUT => return error.ConnectionTimedOut, |
| 3086 | 3092 | .WSAEHOSTUNREACH // TODO: should we return NetworkUnreachable in this case as well? |
| 3087 | | , .WSAENETUNREACH => return error.NetworkUnreachable, |
| 3093 | , .WSAENETUNREACH => return error.NetworkUnreachable, |
| 3088 | 3094 | .WSAEFAULT => unreachable, |
| 3089 | 3095 | .WSAEINVAL => unreachable, |
| 3090 | 3096 | .WSAEISCONN => unreachable, |
| ... | ... | @@ -4711,6 +4717,7 @@ fn count_iovec_bytes(iovs: []const iovec_const) usize { |
| 4711 | 4717 | /// Linux has a limit on how many bytes may be transferred in one `sendfile` call, which is `0x7ffff000` |
| 4712 | 4718 | /// on both 64-bit and 32-bit systems. This is due to using a signed C int as the return value, as |
| 4713 | 4719 | /// well as stuffing the errno codes into the last `4096` values. This is cited on the `sendfile` man page. |
| 4720 | /// The limit on Darwin is `0x7fffffff`, trying to write more than that returns EINVAL. |
| 4714 | 4721 | /// The corresponding POSIX limit on this is `math.maxInt(isize)`. |
| 4715 | 4722 | pub fn sendfile( |
| 4716 | 4723 | out_fd: fd_t, |
| ... | ... | @@ -4733,6 +4740,7 @@ pub fn sendfile( |
| 4733 | 4740 | }); |
| 4734 | 4741 | const max_count = switch (std.Target.current.os.tag) { |
| 4735 | 4742 | .linux => 0x7ffff000, |
| 4743 | .macosx, .ios, .watchos, .tvos => math.maxInt(i32), |
| 4736 | 4744 | else => math.maxInt(size_t), |
| 4737 | 4745 | }; |
| 4738 | 4746 | |