aboutsummaryrefslogtreecommitdiff
path: root/lib/std/io.zig
AgeCommit message (Collapse)Author
2022-09-07libstd: use windows.GetStdHandle() with stage2_x86_64 backend for nowJakub Konka
2022-04-14stage2: progress towards stage3Andrew Kelley
* The `@bitCast` workaround is removed in favor of `@ptrCast` properly doing element casting for slice element types. This required an enhancement both to stage1 and stage2. * stage1 incorrectly accepts `.{}` instead of `{}`. stage2 code that abused this is fixed. * Make some parameters comptime to support functions in switch expressions (as opposed to making them function pointers). * Avoid relying on local temporaries being mutable. * Workarounds for when stage1 and stage2 disagree on function pointer types. * Workaround recursive formatting bug with a `@panic("TODO")`. * Remove unreachable `else` prongs for some inferred error sets. All in effort towards #89.
2021-11-30std lib API deprecations for the upcoming 0.9.0 releaseAndrew Kelley
See #3811
2021-10-04migrate from `std.Target.current` to `@import("builtin").target`Andrew Kelley
closes #9388 closes #9321
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
2021-06-21fix code broken from previous commitJacob G-W
2021-04-15std: change `@import("builtin")` to `std.builtin`Andrew Kelley
2021-02-16std: remove io.AutoIndentingStreamIsaac Freund
This type is not widely applicable enough to be a public part of the public interface of the std. The current implementation in only fully utilized by the zig fmt implementation, which could benefit by even tighter integration as will be demonstrated in the next commit. Therefore, move the current io.AutoIndentingStream to lib/std/zig/render.zig. The C backend of the self hosted compiler also use this type currently, but it does not require anywhere near its full complexity. Therefore, implement a greatly simplified version of this interface in src/codegen/c.zig.
2021-01-22std: Update `test ""` to `test` where it makes senseLemonBoy
2021-01-11std.EarlyEOFReader: rename to LimitedReaderAndrew Kelley
2021-01-11std: add LimitedReader: reader that returns EOF earlydaurnimator
2021-01-08io: `FindByteOutStream` to `FindByteWriter`Jay Petacat
See #4917
2021-01-08Remove deprecated stream aliasesJay Petacat
2020-12-31Year++Frank Denis
2020-12-24std: clenup, fixes, fmtVeikka Tuominen
2020-12-23Added std.io.counting_readertgschultz
2020-12-20std: move serialization to the std lib orphanageAndrew Kelley
std-lib-orphanage commit 633792839f6f838fa864cde6af015413ee713404
2020-08-31zig fmt: Remove dynamic stack from auto-indenting-streamLachlan Easton
2020-08-29Refactor zig fmt indentation. Remove indent from rendering code and have a ↵Lachlan Easton
stream handle automatic indentation
2020-08-20add license header to all std lib filesAndrew Kelley
add SPDX license identifier copyright ownership is zig contributors
2020-06-09Support Reader for InStreamJonathan Marler
2020-06-08support Writer instead of OutStreamJonathan Marler
Start implementing https://github.com/ziglang/zig/issues/4917 which is to rename instream/outstream to reader/writer. This first change allows code to use Writer/writer instead of OutStream/outStream, but still maintains the old outstream names with "Deprecated" comments.
2020-05-16Merge pull request #5175 from daurnimator/multi-out-streamVexu
std: add io.MultiOutStream
2020-05-01cleanup and fixes. behavior tests passing with evented I/OAndrew Kelley
2020-05-01Merge branch 'windows-evented-io' of https://github.com/FireFox317/zig into ↵Andrew Kelley
FireFox317-windows-evented-io
2020-04-27std: add io.MultiOutStreamdaurnimator
2020-04-01io: test all files under std/ioVincent Rischmann
2020-03-30std lib API deprecations for the upcoming 0.6.0 releaseAndrew Kelley
See #3811
2020-03-27fix behavior test with --test-evented-io on windowsTimon Kruiper
also make simple file operations work asynchronously on windows
2020-03-11add std.io.StreamSource and fixes to emitRawAndrew Kelley
2020-03-10update standard library to new I/O streams APIAndrew Kelley
2020-03-10(breaking) improve and simplify fixed buffer streams APIAndrew Kelley
2020-03-10(breaking) rework stream abstractionsAndrew Kelley
The main goal here is to make the function pointers comptime, so that we don't have to do the crazy stuff with async function frames. Since InStream, OutStream, and SeekableStream are already generic across error sets, it's not really worse to make them generic across the vtable as well. See #764 for the open issue acknowledging that using generics for these abstractions is a design flaw. See #130 for the efforts to make these abstractions non-generic. This commit also changes the OutStream API so that `write` returns number of bytes written, and `writeAll` is the one that loops until the whole buffer is written.
2020-03-03breaking: std.os read/write functions + sendfileAndrew Kelley
* 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
2020-03-01short std.builtin enum literals in std libxackus
2020-02-28introduce operating system version ranges as part of the targetAndrew Kelley
* re-introduce `std.build.Target` which is distinct from `std.Target`. `std.build.Target` wraps `std.Target` so that it can be annotated as "the native target" or an explicitly specified target. * `std.Target.Os` is moved to `std.Target.Os.Tag`. The former is now a struct which has the tag as well as version range information. * `std.elf` gains some more ELF header constants. * `std.Target.parse` gains the ability to parse operating system version ranges as well as glibc version. * Added `std.Target.isGnuLibC()`. * self-hosted dynamic linker detection and glibc version detection. This also adds the improved logic using `/usr/bin/env` rather than invoking the system C compiler to find the dynamic linker when zig is statically linked. Related: #2084 Note: this `/usr/bin/env` code is work-in-progress. * `-target-glibc` CLI option is removed in favor of the new `-target` syntax. Example: `-target x86_64-linux-gnu.2.27` closes #1907
2020-02-24remove uses of `@ArgType` and `@IntType`Vexu
2020-02-24remove usages of `@typeId`, `@memberCount`, `@memberName` and `@memberType`Vexu
2020-02-20remove std.io.readLineAndrew Kelley
This was deceptive. It was always meant to be sort of a "GNU readline" sort of thing where it provides a Command Line Interface to input text. However that functionality did not exist and it was basically a red herring for people trying to read line-delimited input from a stream. In this commit the API is deleted, so that people can find the proper API more easily. A CLI text input abstraction would be useful but may not even need to be in the standard library. As you can see in this commit, the guess_number CLI game gets by just fine by using `std.fs.File.read`.
2020-02-18avoid a `@ptrCast` with an array literalAndrew Kelley
2020-02-18std: use LinearFifo to implement io.BufferedOutStreamCustomdaurnimator
2020-02-18std: let PeekStream have static/dynamic variantsdaurnimator
This completes a TODO in the existing implementation
2020-02-18std: use LinearFifo to implement io.PeekStreamdaurnimator
2020-02-18std: use LinearFifo to implement io.BufferedInStreamCustomdaurnimator
2020-02-12Switch a bunch of FBA to use testing.allocatorBenjamin Feng
2020-02-06more std lib async I/O integrationAndrew Kelley
* `zig test` gainst `--test-evented-io` parameter and gains the ability to seamlessly run async tests. * `std.ChildProcess` opens its child process pipe with O_NONBLOCK when using evented I/O * `std.io.getStdErr()` gives a File that is blocking even in evented I/O mode. * Delete `std.event.fs`. The functionality is now merged into `std.fs` and async file system access (using a dedicated thread) is automatically handled. * `std.fs.File` can be configured to specify whether its handle is expected to block, and whether that is OK to block even when in async I/O mode. This makes async I/O work correctly for e.g. the file system as well as network. * `std.fs.File` has some deprecated functions removed. * Missing readv,writev,pread,pwrite,preadv,pwritev functions are added to `std.os` and `std.fs.File`. They are all integrated with async I/O. * `std.fs.Watch` is still bit rotted and needs to be audited in light of the new async/await syntax. * `std.io.OutStream` integrates with async I/O * linked list nodes in the std lib have default `null` values for `prev` and `next`. * Windows async I/O integration is enabled for reading/writing file handles. * Added `std.os.mode_t`. Integer sizes need to be audited. * Fixed #4403 which was causing compiler to crash. This is working towards: ./zig test ../test/stage1/behavior.zig --test-evented-io Which does not successfully build yet. I'd like to enable behavioral tests and std lib tests with --test-evented-io in the test matrix in the future, to prevent regressions.
2020-01-29Move FailingAllocator to testingBenjamin Feng
2019-12-11lib/std/io: let the bring-your-own OS package handle stdio (#3887)Christine Dodrill
2019-12-10Add hotpath for BufferedOutStream (#3858)frmdstryr
* Add hotpath for BufferedOutStream
2019-12-10Replace @typeOf with @TypeOf in all zig sourceRobin Voetter
This change was mostly made with `zig fmt` and this also modified some whitespace. Note that in some files, `zig fmt` produced incorrect code, so the change was made manually.