authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-15 11:46:47-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-10-15 11:46:47-07:00
log0915d24e6b34b67d358c1309e9bc8516416f1008
tree711578f68083d711560bd968e23bf1549690bd04
parent01b390568872344e53862d61da091071e0ab1f3e

std.os: add workarounds for stage1 `@minimum` implementation


1 files changed, 6 insertions(+), 2 deletions(-)

lib/std/os.zig+6-2
...@@ -5601,7 +5601,9 @@ pub fn sendfile(...@@ -5601,7 +5601,9 @@ pub fn sendfile(
5601 hdtr = &hdtr_data;5601 hdtr = &hdtr_data;
5602 }5602 }
56035603
5604 const adjusted_count = @minimum(in_len, @as(u63, max_count));5604 const adjusted_count_temporary = @minimum(in_len, @as(u63, max_count));
5605 // TODO we should not need this int cast; improve the return type of `@minimum`
5606 const adjusted_count = @intCast(u63, adjusted_count_temporary);
56055607
5606 while (true) {5608 while (true) {
5607 var sbytes: off_t = adjusted_count;5609 var sbytes: off_t = adjusted_count;
...@@ -5655,7 +5657,9 @@ pub fn sendfile(...@@ -5655,7 +5657,9 @@ pub fn sendfile(
5655 rw: {5657 rw: {
5656 var buf: [8 * 4096]u8 = undefined;5658 var buf: [8 * 4096]u8 = undefined;
5657 // Here we match BSD behavior, making a zero count value send as many bytes as possible.5659 // Here we match BSD behavior, making a zero count value send as many bytes as possible.
5658 const adjusted_count = if (in_len == 0) buf.len else @minimum(buf.len, in_len);5660 const adjusted_count_tmp = if (in_len == 0) buf.len else @minimum(buf.len, in_len);
5661 // TODO we should not need this cast; improve return type of @minimum
5662 const adjusted_count = @intCast(usize, adjusted_count_tmp);
5659 const amt_read = try pread(in_fd, buf[0..adjusted_count], in_offset);5663 const amt_read = try pread(in_fd, buf[0..adjusted_count], in_offset);
5660 if (amt_read == 0) {5664 if (amt_read == 0) {
5661 if (in_len == 0) {5665 if (in_len == 0) {