std.os read/write functions + sendfile#4612
Merged
Conversation
This changset adds a `sendfile(2)` syscall bindings to the linux bits component. Where available, the `sendfile64(2)` syscall will be transparently called. A wrapping function has also been added to the std.os to transform errno returns to Zig errors. Change-Id: I86769fc4382c0771e3656e7b21137bafd99a4411
* rework os.sendfile and add macosx support, and a fallback implementation for any OS. * fix sendto compile error * std.os write functions support partial writes. closes #3443. * std.os pread / pwrite functions can now return `error.Unseekable`. * std.fs.File read/write functions now have readAll/writeAll variants which loop to complete operations even when partial reads/writes happen. * Audit std.os read/write functions with respect to Linux returning EINVAL for lengths greater than 0x7fff0000. * std.os read/write shim functions do not unnecessarily loop. Since partial reads/writes are part of the API, the caller will be forced to loop anyway, and so that would just be code bloat. * Improve doc comments * Add a non-trivial test for std.os.sendfile * Fix std.os.pread on 32 bit Linux * Add missing SYS_sendfile bit on aarch64
Contributor
|
What about |
Member
Author
That will be a nice separate enhancement |
daurnimator
reviewed
Mar 3, 2020
|
|
||
| else => { | ||
| _ = unexpectedErrno(err); | ||
| const discard = unexpectedErrno(err); |
Contributor
There was a problem hiding this comment.
Why does this need an assignment?
Contributor
There was a problem hiding this comment.
hrm. why don't we support discarding error values (not error unions) via assignment to _?
Contributor
|
FYI this broke zig hello world examples all over the place as |
|
Shouldn't this optimization also exist on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This merges #4131 and then does the following:
implementation for any OS.
error.Unseekable.which loop to complete operations even when partial reads/writes
happen.
EINVAL for lengths greater than 0x7fff0000.
partial reads/writes are part of the API, the caller will be forced
to loop anyway, and so that would just be code bloat.