aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Progress.zig
AgeCommit message (Collapse)Author
2025-10-29std: make signal numbers into an enumAndrew Kelley
fixes start logic for checking whether IO/POLL exist
2025-10-29WIP land the std.Io interfaceAndrew Kelley
fix std lib compilation errors caused by introducing std.Io
2025-10-29std.Thread.ResetEvent: make it more reusableAndrew Kelley
2025-10-27remove all Oracle Solaris supportAlex Rønne Petersen
There is no straightforward way for the Zig team to access the Solaris system headers; to do this, one has to create an Oracle account, accept their EULA to download the installer ISO, and finally install it on a machine or VM. We do not have to jump through hoops like this for any other OS that we support, and no one on the team has expressed willingness to do it. As a result, we cannot audit any Solaris contributions to std.c or other similarly sensitive parts of the standard library. The best we would be able to do is assume that Solaris and illumos are 100% compatible with no way to verify that assumption. But at that point, the solaris and illumos OS tags would be functionally identical anyway. For Solaris especially, any contributions that involve APIs introduced after the OS was made closed-source would also be inherently more risky than equivalent contributions for other proprietary OSs due to the case of Google LLC v. Oracle America, Inc., wherein Oracle clearly demonstrated its willingness to pursue legal action against entities that merely copy API declarations. Finally, Oracle laid off most of the Solaris team in 2017; the OS has been in maintenance mode since, presumably to be retired completely sometime in the 2030s. For these reasons, this commit removes all Oracle Solaris support. Anyone who still wishes to use Zig on Solaris can try their luck by simply using illumos instead of solaris in target triples - chances are it'll work. But there will be no effort from the Zig team to support this use case; we recommend that people move to illumos instead.
2025-09-20std.Progress: avoid problematic catch syntaxAndrew Kelley
2025-08-29std.Io: delete GenericReaderAndrew Kelley
and delete deprecated alias std.io
2025-08-05std: replace various mem copies with `@memmove`Andrew Kelley
2025-07-30std: Add serenity to more OS checksLinus Groh
2025-07-25std.Progress: introduce StatusAndrew Kelley
2025-07-25std.Progress: support progress bar escape codesAndrew Kelley
2025-07-22aarch64: add new from scratch self-hosted backendJacob Young
2025-07-17std.Progress: reset end when failing to flush stderrkcbanner
2025-07-07std.fmt: breaking API changesAndrew Kelley
added adapter to AnyWriter and GenericWriter to help bridge the gap between old and new API make std.testing.expectFmt work at compile-time std.fmt no longer has a dependency on std.unicode. Formatted printing was never properly unicode-aware. Now it no longer pretends to be. Breakage/deprecations: * std.fs.File.reader -> std.fs.File.deprecatedReader * std.fs.File.writer -> std.fs.File.deprecatedWriter * std.io.GenericReader -> std.io.Reader * std.io.GenericWriter -> std.io.Writer * std.io.AnyReader -> std.io.Reader * std.io.AnyWriter -> std.io.Writer * std.fmt.format -> std.fmt.deprecatedFormat * std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape * std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape * std.fmt.fmtSliceHexLower -> {x} * std.fmt.fmtSliceHexUpper -> {X} * std.fmt.fmtIntSizeDec -> {B} * std.fmt.fmtIntSizeBin -> {Bi} * std.fmt.fmtDuration -> {D} * std.fmt.fmtDurationSigned -> {D} * {} -> {f} when there is a format method * format method signature - anytype -> *std.io.Writer - inferred error set -> error{WriteFailed} - options -> (deleted) * std.fmt.Formatted - now takes context type explicitly - no fmt string
2025-07-07std.io: move getStdIn, getStdOut, getStdErr functions to fs.FileAndrew Kelley
preparing to rearrange std.io namespace into an interface how to upgrade: std.io.getStdIn() -> std.fs.File.stdin() std.io.getStdOut() -> std.fs.File.stdout() std.io.getStdErr() -> std.fs.File.stderr()
2025-06-12compiler: improve progress outputmlugg
* "Flush" nodes ("LLVM Emit Object", "ELF Flush") appear under "Linking" * "Code Generation" disappears when all analysis and codegen is done * We only show one node under "Semantic Analysis" to accurately convey that analysis isn't happening in parallel, but rather that we're pausing one task to do another
2025-05-03std.Progress: fix many bugsmlugg
There were several bugs with the synchronization here; most notably an ABA problem which was causing #21663. I fixed that and some other issues, and took the opportunity to get rid of the `.seq_cst` orderings from this file. I'm at least relatively sure my new orderings are correct. Co-authored-by: achan1989 <achan1989@gmail.com> Resolves: #21663
2025-04-30sigset_t: sigemptyset() and sigfillset() are functions that return sigset_tPat Tullmann
By returning an initialized sigset (instead of taking the set as an output parameter), these functions can be used to directly initialize the `mask` parameter of a `Sigaction` instance.
2025-04-30posix: remove empty_sigsetPat Tullmann
When linking a libc, Zig should defer to the C library for sigset operations. The pre-filled constants signal sets (empty_sigset, filled_sigset) are not compatible with C library initialization, so remove them and use the runtime `sigemptyset` and `sigfillset` methods to initialize any sigset.
2025-01-16all: update to `std.builtin.Type.Pointer.Size` field renamesmlugg
This was done by regex substitution with `sed`. I then manually went over the entire diff and fixed any incorrect changes. This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since my regex happened to also trigger here. I opted to leave these changes in, since they *are* a correct migration, even if they're not the one I was trying to do!
2024-10-23std.Progress: fix data raceAndrew Kelley
In end(), the freelist pointer is owned so the bare store would be ok. However, there is a load in start() that can happen at the same time, if another start() and end() pair grabs that same index. I don't think this fixes #21663 actually because even if the data race corrupts the value for `next`, the cmpxchg protects the value from being stored there.
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-07-21std.posix: Consider invalid signal numbers to sigaction() to be programmer ↵Alex Rønne Petersen
error. The set of signals that cannot have their action changed is documented in POSIX, and any additional, non-standard signals are documented by the specific OS. I see no valid reason why EINVAL should be considered an unpredictable error here.
2024-07-19std.c reorganizationAndrew Kelley
It is now composed of these main sections: * Declarations that are shared among all operating systems. * Declarations that have the same name, but different type signatures depending on the operating system. Often multiple operating systems share the same type signatures however. * Declarations that are specific to a single operating system. - These are imported one per line so you can see where they come from, protected by a comptime block to prevent accessing the wrong one. Closes #19352 by changing the convention to making types `void` and functions `{}`, so that it becomes possible to update `@hasDecl` sites to use `@TypeOf(f) != void` or `T != void`. Happily, this ended up removing some duplicate logic and update some bitrotted feature detection checks. A handful of types have been modified to gain namespacing and type safety. This is a breaking change. Oh, and the last usage of `usingnamespace` site is eliminated.
2024-07-16Progress: avoid race on `global_progress.draw_buffer`Jacob Young
2024-07-14std.Progress: add getIpcFd and have_ipc APIAndrew Kelley
This makes advanced use cases possible such as a long-lived child process whose progress node gets re-attached to a different parent.
2024-07-10std.Progress: slightly better atomic memcpyAndrew Kelley
Let's at least do aligned usize loads/stores where possible.
2024-07-09Progress: suppress tsan racesJacob Young
This removes the undefined behavior, but not the actual races. Closes #20477
2024-07-08Compilation: put supported codegen backends on a separate threadJacob Young
(There are no supported backends.)
2024-06-16std.Progress.Node: add `none` init valueAndrew Kelley
2024-06-12std.Progress: use a recursive mutex for stderrAndrew Kelley
2024-06-11std.Progress: fix race assertion failureAndrew Kelley
A node may be freed during the execution of this loop, causing there to be a parent reference to a nonexistent node. Without this assignment, this would lead to the map entry containing stale data. By assigning none, the child node with the bad parent pointer will be harmlessly omitted from the tree. Closes #20262
2024-06-02Add `File.getOrEnableAnsiEscapeSupport` and use itRyan Liptak
On Windows, the console mode flag `ENABLE_VIRTUAL_TERMINAL_PROCESSING` determines whether or not ANSI escape codes are parsed/acted on. On the newer Windows Terminal, this flag is set by default, but on the older Windows Console, it is not set by default, but *can* be enabled (since Windows 10 RS1 from June 2016). The new `File.getOrEnableAnsiEscapeSupport` function will get the current status of ANSI escape code support, but will also attempt to enable `ENABLE_VIRTUAL_TERMINAL_PROCESSING` on Windows if necessary which will provide better/more consistent results for things like `std.Progress` and `std.io.tty`. This type of change was not done previously due to a mistaken assumption (on my part) that the console mode would persist after the run of a program. However, it turns out that the console mode is always reset to the default for each program run in a console session.
2024-06-02std.Progress: fix line upper bound calculationAndrew Kelley
closes #20161 problem introduced in e09963d8544c19812db20e520f09f6e5d9a57d64
2024-06-02Progress: Emit \r\n on Windows, include new line bytes in line_upper_bound_lenRyan Liptak
The \r\n is necessary to get the progress tree to work properly in the old console when ENABLE_VIRTUAL_TERMINAL_PROCESSING and DISABLE_NEWLINE_AUTO_RETURN are set. The line_upper_bound_len fix addresses part of #20161
2024-05-31std.Progress: keep the cursor at the beginningAndrew Kelley
This changes the terminal display to keep the cursor at the top left of the progress display, so that unlocked stderr writes, perhaps by child processes, don't get eaten by the clear.
2024-05-31std.Progress: IPC fixesAndrew Kelley
Reduce node_storage_buffer_len from 200 to 83. This makes messages over the pipe fit in a single packet (4096 bytes). There is now a comptime assert to ensure this. In practice this is plenty of storage because typical terminal heights are significantly less than 83 rows. Handling of split reads is fixed; instead of using a global `remaining_read_trash_bytes`, the value is stored in the "saved metadata" for the IPC node. Saved metadata is split into two arrays so that the "find" operation can quickly scan over fds for a match, looking at 332 bytes maximum, and only reading the memory for the other data upon match. More typical number of bytes read for this operation would be 0 (no child processes), 4 (1 child process), or 64 (16 child processes reporting progress). Removed an align(4) that was leftover from an older design. This also includes part of Jacob Young's not-yet-landed patch that implements `writevNonblock`.
2024-05-28std.Progress: Fix Windows console API implementationRyan Liptak
3a3d2187f986066859cfb793fb7ee1cae4dfea08 unintentionally broke some of the Windows console API implementation. - The 'marker' character was no longer being written at all - The ANSI escape codes for syncing were being written unconditionally
2024-05-28std.Progress: better Windows supportAndrew Kelley
* Merge a bunch of related state together into TerminalMode. Windows sometimes follows the same path as posix via ansi_escape_codes, sometimes not. * Use a different thread entry point for Windows API but share the same entry point on Windows when the terminal is in ansi_escape_codes mode. * Only clear the terminal when the stderr lock is held. * Don't try to clear the terminal when nothing has been written yet. * Don't try to clear the terminal in IPC mode. * Fix size detection logic bug under error conditions.
2024-05-28std.Progress: Use Windows console API calls when ANSI escape codes are not ↵Ryan Liptak
supported
2024-05-27std.Progress: relax some of the atomic orderingsAndrew Kelley
Generates better machine code, particularly on ARM
2024-05-27std.Progress: fix race condition with setIpcFdAndrew Kelley
The update thread was sometimes reading the special state and then incorrectly getting 0 for the file descriptor, making it hang since it tried to read from stdin.
2024-05-27fix zig translate-c creating root progress node twiceAndrew Kelley
2024-05-27std.Progress: handle short writesAndrew Kelley
2024-05-27std.Progress: handle big-endian targetsAndrew Kelley
We cannot rely on host endianness because the parent or child process may be executing inside QEMU.
2024-05-27std.Progress: adjust the timings a little bitAndrew Kelley
Slightly slower refresh rate. It's still updating very quickly. Lower the initial delay so that CLI applications feel more responsive. Even though the application is doing work for the full 500ms until something is displayed on the screen, it feels nicer to get the progress earlier.
2024-05-27std.Progress: elide root node if emptyAndrew Kelley
when the root progress node has a zero length name, the sub-tree is flattened one layer, reducing visual noise, as well as bytes written to the terminal.
2024-05-27std.Progress: count newlines more accuratelyAndrew Kelley
Split newline_count into written_newline_count and accumulated_newline_count. This handle the case when the tryLock() fails to obtain the lock, because in such case there would not be any newlines written to the terminal but the system would incorrectly think there were. Now, written_newline_count is only adjusted when the write() call succeeds. Furthermore, write() call failure is handled by exiting the update thread.
2024-05-27std.Progress: handle when terminal write buffer too smallAndrew Kelley
2024-05-27std.Progress: keep cursor on newlineAndrew Kelley
Don't truncate trailing newline. This better handles stray writes to stderr that are not std.Progress-aware, such as from non-zig child processes. This commit also makes `Node.start` and `Node.end` bail out early with a comptime branch when it is known the target will not be spawning an update thread.
2024-05-27std.Progress: use std.log.debug rather than warnAndrew Kelley
when the errors could possibly be spammed many times