| ... | ... | @@ -890,10 +890,7 @@ pub fn pread(fd: fd_t, buf: []u8, offset: u64) PReadError!usize { |
| 890 | 890 | }; |
| 891 | 891 | const adjusted_len = @min(max_count, buf.len); |
| 892 | 892 | |
| 893 | | const pread_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 894 | | system.pread64 |
| 895 | | else |
| 896 | | system.pread; |
| 893 | const pread_sym = if (lfs64_abi) system.pread64 else system.pread; |
| 897 | 894 | |
| 898 | 895 | const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned |
| 899 | 896 | while (true) { |
| ... | ... | @@ -966,10 +963,7 @@ pub fn ftruncate(fd: fd_t, length: u64) TruncateError!void { |
| 966 | 963 | } |
| 967 | 964 | |
| 968 | 965 | while (true) { |
| 969 | | const ftruncate_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 970 | | system.ftruncate64 |
| 971 | | else |
| 972 | | system.ftruncate; |
| 966 | const ftruncate_sym = if (lfs64_abi) system.ftruncate64 else system.ftruncate; |
| 973 | 967 | |
| 974 | 968 | const ilen = @bitCast(i64, length); // the OS treats this as unsigned |
| 975 | 969 | switch (errno(ftruncate_sym(fd, ilen))) { |
| ... | ... | @@ -1034,10 +1028,7 @@ pub fn preadv(fd: fd_t, iov: []const iovec, offset: u64) PReadError!usize { |
| 1034 | 1028 | |
| 1035 | 1029 | const iov_count = math.cast(u31, iov.len) orelse math.maxInt(u31); |
| 1036 | 1030 | |
| 1037 | | const preadv_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 1038 | | system.preadv64 |
| 1039 | | else |
| 1040 | | system.preadv; |
| 1031 | const preadv_sym = if (lfs64_abi) system.preadv64 else system.preadv; |
| 1041 | 1032 | |
| 1042 | 1033 | const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned |
| 1043 | 1034 | while (true) { |
| ... | ... | @@ -1311,10 +1302,7 @@ pub fn pwrite(fd: fd_t, bytes: []const u8, offset: u64) PWriteError!usize { |
| 1311 | 1302 | }; |
| 1312 | 1303 | const adjusted_len = @min(max_count, bytes.len); |
| 1313 | 1304 | |
| 1314 | | const pwrite_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 1315 | | system.pwrite64 |
| 1316 | | else |
| 1317 | | system.pwrite; |
| 1305 | const pwrite_sym = if (lfs64_abi) system.pwrite64 else system.pwrite; |
| 1318 | 1306 | |
| 1319 | 1307 | const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned |
| 1320 | 1308 | while (true) { |
| ... | ... | @@ -1400,10 +1388,7 @@ pub fn pwritev(fd: fd_t, iov: []const iovec_const, offset: u64) PWriteError!usiz |
| 1400 | 1388 | } |
| 1401 | 1389 | } |
| 1402 | 1390 | |
| 1403 | | const pwritev_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 1404 | | system.pwritev64 |
| 1405 | | else |
| 1406 | | system.pwritev; |
| 1391 | const pwritev_sym = if (lfs64_abi) system.pwritev64 else system.pwritev; |
| 1407 | 1392 | |
| 1408 | 1393 | const iov_count = if (iov.len > IOV_MAX) IOV_MAX else @intCast(u31, iov.len); |
| 1409 | 1394 | const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned |
| ... | ... | @@ -1514,10 +1499,7 @@ pub fn openZ(file_path: [*:0]const u8, flags: u32, perm: mode_t) OpenError!fd_t |
| 1514 | 1499 | return open(mem.sliceTo(file_path, 0), flags, perm); |
| 1515 | 1500 | } |
| 1516 | 1501 | |
| 1517 | | const open_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 1518 | | system.open64 |
| 1519 | | else |
| 1520 | | system.open; |
| 1502 | const open_sym = if (lfs64_abi) system.open64 else system.open; |
| 1521 | 1503 | |
| 1522 | 1504 | while (true) { |
| 1523 | 1505 | const rc = open_sym(file_path, flags, perm); |
| ... | ... | @@ -1730,10 +1712,7 @@ pub fn openatZ(dir_fd: fd_t, file_path: [*:0]const u8, flags: u32, mode: mode_t) |
| 1730 | 1712 | return openat(dir_fd, mem.sliceTo(file_path, 0), flags, mode); |
| 1731 | 1713 | } |
| 1732 | 1714 | |
| 1733 | | const openat_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 1734 | | system.openat64 |
| 1735 | | else |
| 1736 | | system.openat; |
| 1715 | const openat_sym = if (lfs64_abi) system.openat64 else system.openat; |
| 1737 | 1716 | |
| 1738 | 1717 | while (true) { |
| 1739 | 1718 | const rc = openat_sym(dir_fd, file_path, flags, mode); |
| ... | ... | @@ -4117,10 +4096,7 @@ pub fn fstat(fd: fd_t) FStatError!Stat { |
| 4117 | 4096 | @compileError("fstat is not yet implemented on Windows"); |
| 4118 | 4097 | } |
| 4119 | 4098 | |
| 4120 | | const fstat_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 4121 | | system.fstat64 |
| 4122 | | else |
| 4123 | | system.fstat; |
| 4099 | const fstat_sym = if (lfs64_abi) system.fstat64 else system.fstat; |
| 4124 | 4100 | |
| 4125 | 4101 | var stat = mem.zeroes(Stat); |
| 4126 | 4102 | switch (errno(fstat_sym(fd, &stat))) { |
| ... | ... | @@ -4176,10 +4152,7 @@ pub fn fstatatZ(dirfd: fd_t, pathname: [*:0]const u8, flags: u32) FStatAtError!S |
| 4176 | 4152 | return fstatatWasi(dirfd, mem.sliceTo(pathname), flags); |
| 4177 | 4153 | } |
| 4178 | 4154 | |
| 4179 | | const fstatat_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 4180 | | system.fstatat64 |
| 4181 | | else |
| 4182 | | system.fstatat; |
| 4155 | const fstatat_sym = if (lfs64_abi) system.fstatat64 else system.fstatat; |
| 4183 | 4156 | |
| 4184 | 4157 | var stat = mem.zeroes(Stat); |
| 4185 | 4158 | switch (errno(fstatat_sym(dirfd, pathname, &stat, flags))) { |
| ... | ... | @@ -4416,10 +4389,7 @@ pub fn mmap( |
| 4416 | 4389 | fd: fd_t, |
| 4417 | 4390 | offset: u64, |
| 4418 | 4391 | ) MMapError![]align(mem.page_size) u8 { |
| 4419 | | const mmap_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 4420 | | system.mmap64 |
| 4421 | | else |
| 4422 | | system.mmap; |
| 4392 | const mmap_sym = if (lfs64_abi) system.mmap64 else system.mmap; |
| 4423 | 4393 | |
| 4424 | 4394 | const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned |
| 4425 | 4395 | const rc = mmap_sym(ptr, length, prot, flags, fd, ioffset); |
| ... | ... | @@ -4823,10 +4793,7 @@ pub fn lseek_SET(fd: fd_t, offset: u64) SeekError!void { |
| 4823 | 4793 | } |
| 4824 | 4794 | } |
| 4825 | 4795 | |
| 4826 | | const lseek_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 4827 | | system.lseek64 |
| 4828 | | else |
| 4829 | | system.lseek; |
| 4796 | const lseek_sym = if (lfs64_abi) system.lseek64 else system.lseek; |
| 4830 | 4797 | |
| 4831 | 4798 | const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned |
| 4832 | 4799 | switch (errno(lseek_sym(fd, ioffset, SEEK.SET))) { |
| ... | ... | @@ -4870,10 +4837,7 @@ pub fn lseek_CUR(fd: fd_t, offset: i64) SeekError!void { |
| 4870 | 4837 | else => |err| return unexpectedErrno(err), |
| 4871 | 4838 | } |
| 4872 | 4839 | } |
| 4873 | | const lseek_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 4874 | | system.lseek64 |
| 4875 | | else |
| 4876 | | system.lseek; |
| 4840 | const lseek_sym = if (lfs64_abi) system.lseek64 else system.lseek; |
| 4877 | 4841 | |
| 4878 | 4842 | const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned |
| 4879 | 4843 | switch (errno(lseek_sym(fd, ioffset, SEEK.CUR))) { |
| ... | ... | @@ -4917,10 +4881,7 @@ pub fn lseek_END(fd: fd_t, offset: i64) SeekError!void { |
| 4917 | 4881 | else => |err| return unexpectedErrno(err), |
| 4918 | 4882 | } |
| 4919 | 4883 | } |
| 4920 | | const lseek_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 4921 | | system.lseek64 |
| 4922 | | else |
| 4923 | | system.lseek; |
| 4884 | const lseek_sym = if (lfs64_abi) system.lseek64 else system.lseek; |
| 4924 | 4885 | |
| 4925 | 4886 | const ioffset = @bitCast(i64, offset); // the OS treats this as unsigned |
| 4926 | 4887 | switch (errno(lseek_sym(fd, ioffset, SEEK.END))) { |
| ... | ... | @@ -4964,10 +4925,7 @@ pub fn lseek_CUR_get(fd: fd_t) SeekError!u64 { |
| 4964 | 4925 | else => |err| return unexpectedErrno(err), |
| 4965 | 4926 | } |
| 4966 | 4927 | } |
| 4967 | | const lseek_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 4968 | | system.lseek64 |
| 4969 | | else |
| 4970 | | system.lseek; |
| 4928 | const lseek_sym = if (lfs64_abi) system.lseek64 else system.lseek; |
| 4971 | 4929 | |
| 4972 | 4930 | const rc = lseek_sym(fd, 0, SEEK.CUR); |
| 4973 | 4931 | switch (errno(rc)) { |
| ... | ... | @@ -6169,10 +6127,7 @@ pub fn sendfile( |
| 6169 | 6127 | // TODO we should not need this cast; improve return type of @min |
| 6170 | 6128 | const adjusted_count = @intCast(usize, adjusted_count_tmp); |
| 6171 | 6129 | |
| 6172 | | const sendfile_sym = if (builtin.link_libc) |
| 6173 | | system.sendfile64 |
| 6174 | | else |
| 6175 | | system.sendfile; |
| 6130 | const sendfile_sym = if (lfs64_abi) system.sendfile64 else system.sendfile; |
| 6176 | 6131 | |
| 6177 | 6132 | while (true) { |
| 6178 | 6133 | var offset: off_t = @bitCast(off_t, in_offset); |
| ... | ... | @@ -7050,10 +7005,7 @@ pub fn prctl(option: PR, args: anytype) PrctlError!u31 { |
| 7050 | 7005 | pub const GetrlimitError = UnexpectedError; |
| 7051 | 7006 | |
| 7052 | 7007 | pub fn getrlimit(resource: rlimit_resource) GetrlimitError!rlimit { |
| 7053 | | const getrlimit_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 7054 | | system.getrlimit64 |
| 7055 | | else |
| 7056 | | system.getrlimit; |
| 7008 | const getrlimit_sym = if (lfs64_abi) system.getrlimit64 else system.getrlimit; |
| 7057 | 7009 | |
| 7058 | 7010 | var limits: rlimit = undefined; |
| 7059 | 7011 | switch (errno(getrlimit_sym(resource, &limits))) { |
| ... | ... | @@ -7067,10 +7019,7 @@ pub fn getrlimit(resource: rlimit_resource) GetrlimitError!rlimit { |
| 7067 | 7019 | pub const SetrlimitError = error{ PermissionDenied, LimitTooBig } || UnexpectedError; |
| 7068 | 7020 | |
| 7069 | 7021 | pub fn setrlimit(resource: rlimit_resource, limits: rlimit) SetrlimitError!void { |
| 7070 | | const setrlimit_sym = if (builtin.os.tag == .linux and builtin.link_libc) |
| 7071 | | system.setrlimit64 |
| 7072 | | else |
| 7073 | | system.setrlimit; |
| 7022 | const setrlimit_sym = if (lfs64_abi) system.setrlimit64 else system.setrlimit; |
| 7074 | 7023 | |
| 7075 | 7024 | switch (errno(setrlimit_sym(resource, &limits))) { |
| 7076 | 7025 | .SUCCESS => return, |
| ... | ... | @@ -7339,3 +7288,5 @@ pub fn ptrace(request: u32, pid: pid_t, addr: usize, signal: usize) PtraceError! |
| 7339 | 7288 | }, |
| 7340 | 7289 | }; |
| 7341 | 7290 | } |
| 7291 | |
| 7292 | const lfs64_abi = builtin.os.tag == .linux and builtin.link_libc and builtin.abi.isGnu(); |