5772 Commits

Author SHA1 Message Date
Andrew Kelley
cb257d59f9
Merge pull request #13148 from r00ster91/progressfollowup
fix(std.Progress): some follow-ups
2022-10-14 14:43:34 -04:00
r00ster91
ab4e696e1f fix: handle larger window sizes more robustly
We should now be able to handle virtually any window size gracefully.
2022-10-14 09:38:09 +02:00
r00ster91
4ae8717fb3 test: uncomment print
For general output testing, this shouldn't always be required and is only sometimes useful.
2022-10-13 16:06:51 +02:00
r00ster91
cbe6872518 refactor: max_width calculation
I think this may be helpful in the future when we might want to calculate this again at some other point.
It also makes it more clear that the other two functions below it are only required for this calculation.
2022-10-13 16:06:51 +02:00
r00ster91
e484e75969 docs: add notes 2022-10-13 16:06:46 +02:00
Jacob Young
f5f28e0d2c io_uring: ignore SOCK_NONEMPTY for reproducible tests
Fixes #12670
2022-10-13 14:58:06 +02:00
Ali Chraghi
0eb3b8fa44 std.SegmentedList: fix compilation error 2022-10-13 13:57:20 +02:00
Bill Nagel
ea23217751 enable event loop for ios, tvos, and watchos 2022-10-13 13:33:45 +02:00
Ali Chraghi
fb366f3cd4 std.c: fix incorrect return types
Closes #12964
2022-10-13 13:21:19 +02:00
Marijn Stollenga
3a9344d8fc Return invalid argument in sendto instead of unreachable, since this can happen with user-side errors 2022-10-13 13:10:29 +02:00
zooster
cd3d8f3a4e
std.Progress: fix inaccurate line truncation and use optimal max terminal width (#12079)
* prep: output_buffer -> output_buffer_slice

* fix: truncate lines accurately

Currently, the code assumes a terminal width of 100.

If we look at what's printed for the last test:
```
Test [1/1] test "basic functionality"... [101/100] this is a really long name designed to activate the truncation code. let's fi...
```
No, it does not really work because the relevant part here is `"[101/100] this is a really long name designed to activate the truncation code. let's fi... "`,
which is 90 characters, but we expect 100 because that's the width that is assumed.
The reason is that it also measures **unprintable characters** (escape sequences) at least non-Windows systems.
With this commit the output is now:
```
Test [1/1] test "basic functionality"... [101/100] this is a really long name designed to activate the truncation code. let's find out if...
```
Of which `"[101/100] this is a really long name designed to activate the truncation code. let's find out if... "`
is the actual output of *our* `std.Progress` (remember that `zig test` has an `std.Progress` and our test itself does).
The length of that string is 100. Now the length is consistent with Windows where we don't use escape sequences. This issue was only present on non-Windows systems.

* feat: decide optimal maximum width

This is done by 1. getting the current terminal width and 2. subtracting that by the current cursor column. This accounts for previous output from someone else.

* test: add more tests

They make it easier to see how the progress line is printed in different cases.

* style: fix typo and improve docs

It also expands an acronym used as a variable name. It confused me.

* cleanup: import std.time

* test: add test

* fix: limit termios usage to Linux only for now

* fix: missing cast on Windows

* test: try to debug failure

* fix: fix off-by-one and disable tests

* docs: make comment clearer

* fix: more durability

* fix(getTerminalWidth): change order
2022-10-13 06:39:24 -04:00
Michael Dusan
0b47e69b7c improve header searchlist handling in build, main
build.zig:
- use "-I" instead of "-isystem" for `b.addSearchPrefix()`

main.zig:
- silently ignore superfluous search dirs
- warn when a dir is added to multiple searchlists
- consolidate "expected paramter after {s}" fatal error messages
- rename command-line switch `-dirafter` → `-idirafter`

closes #12888
2022-10-12 13:50:25 -04:00
Andrew Kelley
c23b3e6fd9
Merge pull request #13073 from squeek502/fs-delete-tree-2
`fs.Dir.deleteTree`: Optimize for non-deeply-nested directories
2022-10-12 13:37:06 -04:00
Andrew Kelley
d08191e146
Merge pull request #12897 from r00ster91/uefi
std.os.uefi: fix some mistakes
2022-10-12 05:28:13 -04:00
Andrew Kelley
7ce1ee1bce
Merge pull request #13081 from r00ster91/docs
fix(text): hyphenation and other fixes
2022-10-12 05:26:11 -04:00
Gaëtan
62258555b6 Make CompressorOptions public 2022-10-12 04:04:43 -04:00
GethDW
01b9fa2c25
std: fix memory leak on OutOfMemory error in math.big.int and math.big.rationa 2022-10-11 20:12:03 +03:00
Ali Chraghi
d086b371f0 Compilation: strip debug info from ReleaseSmall by default 2022-10-11 17:51:25 +02:00
mllken
42a3b60c33 io_uring: allow for nullable arguments 2022-10-11 17:49:30 +02:00
r00ster91
697e22caa4 fix: resolve data race in std.Progress.maybeRefresh()
It seems we can simply lock the update mutex a little earlier.
2022-10-11 17:46:39 +02:00
Eric Milliken
0b7b4b7e97
std: add linux support for packet sockaddr 2022-10-11 18:46:24 +03:00
Andrew Kelley
c3d67c5c4e
Merge pull request #13117 from topolarity/compiler-rt-cmul
compiler-rt: Implement complex multiply/division
2022-10-11 05:51:47 -04:00
Rekai Nyangadzayi Musuka
dacdc95ea2
std/math.zig: use previous rotate code with non-power-of-two integers 2022-10-11 00:22:35 +03:00
Cody Tapscott
879fb0c57c Manually construct denormal constants in tests
Constructing these at runtime can cause them to be flushed to zero,
which was triggering a CI failure for Windows.
2022-10-09 20:29:30 -07:00
Cody Tapscott
eac1e613be compiler_rt: Re-implement ldexp/ilogb using bit-ops
This re-write was needed to fix deficiencies in the existing ldexp,
which was failing to compute correct results for both f16 and f80.

It would be nice to add a fast multiplication-based fallback in the
future for targets that have a hardware FPU, but this implementation
should be much faster than the existing for targets without one.
2022-10-09 11:09:02 -07:00
Luuk de Gram
3beef5a94f
CheckObjectStep: parsing and dumping producers 2022-10-08 09:43:40 +02:00
r00ster91
47e72132e2 fix: wrong amount of arguments passed to function
I don't know why that one argument was discarded. Is there a reason? It failed to compile.
2022-10-07 19:33:29 +02:00
r00ster91
a56a51e48f fix: wrong return type for _poll
See page 1055 of <https://uefi.org/sites/default/files/resources/UEFI_Spec_2_3_1.pdf>.
2022-10-07 19:33:29 +02:00
r00ster91
4440391d81 fix: wrap function pointers in std.meta.FnPtr 2022-10-07 19:33:29 +02:00
Ali Chraghi
11dce78944 std.http: fix typo 2022-10-06 21:22:20 +03:00
Ryan Liptak
1468eb12f3 std.fs.deleteTree: Unify how the initial sub_path is treated between deleteTree/deleteTreeMinStackSize 2022-10-05 20:08:53 -07:00
Ryan Liptak
063c5f43e9 fs.Dir.deleteTree: Fix FileBusy errors on Windows
Windows requires the directory handle to be closed before attempting to delete the directory, so now we do that and then re-open it if we need to retry (from getting DirNotEmpty when trying to delete).
2022-10-05 19:58:36 -07:00
Ryan Liptak
db0829c15a fs.Dir.deleteTree: Fix some handling of NotDir error in deleteFile calls
We don't control sub_path so it may contain directory components; therefore, NotDir is a potential error when acting on sub_path.
2022-10-05 19:51:43 -07:00
Ryan Liptak
34f180901e fs: deleteTreeFallback -> deleteTreeMinStackSize and make it pub 2022-10-05 16:15:25 -07:00
Ryan Liptak
39f192d54e fs: Reduce IterableDir.Iterator buf size to 1024
This was sized large so that `getdents` (and other platforms' equivalents) could provide large amounts of entries per syscall, but some benchmarking seems to indicate that the larger 8192 sizing doesn't actually lead to performance gains outside of edge cases like extremely large amounts of entries within a single directory (e.g. 25,000 files in one directory), and even then the gains are minimal ('./walk-8192 dir-with-tons-of-entries' ran 1.02 ± 0.34 times faster than './walk-1024 dir-with-tons-of-entries').

Note: Sizes 1024 and 2048 had similar performance characteristics, so the smaller of the two was chosen.
2022-10-05 16:05:02 -07:00
r00ster91
8e2aaf6aed fix(text): hyphenate "runtime" adjectives 2022-10-05 21:33:42 +02:00
r00ster91
51d9db8569 fix(text): hyphenate "comptime" adjectives 2022-10-05 21:19:30 +02:00
r00ster91
654e0b6679 fix(text): hyphenation and other fixes 2022-10-05 21:19:10 +02:00
Ryan Liptak
274d19575e fs: Optimize Dir.deleteTree for non-deeply-nested directories
`deleteTree` now uses a stack-allocated stack for the first 16 nested directories, and then falls back to the previous implementation (which only keeps 1 directory open at a time) when it runs out of room in its stack. This allows the function to perform as well as a recursive implementation for most use-cases without needing allocation or introducing the possibility of stack overflow.
2022-10-05 03:27:25 -07:00
Ryan Liptak
e9889cd25f fs: Add IterableDir.Iterator.reset 2022-10-05 03:26:13 -07:00
Ryan Liptak
8cec8f6ddd fs.Dir.deleteTree: Reduce the number of failing deleteFile calls
There are two parts to this:

1. The deleteFile call on the sub_path has been moved outside the loop, since if the first call fails with `IsDir` then it's very likely that all the subsequent calls will do the same. Instead, if the `openIterableDir` call ever hits `NotDir` after the `deleteFile` hit `IsDir`, then we assume that the tree was deleted at some point and can consider the deleteTree a success.

2. Inside the `dir_it.next()` loop, we look at entry.kind and only try doing the relevant (deleteFile/openIterableDir) operation, but always fall back to the other if we get the relevant error (NotDir/IsDir).
2022-10-05 03:26:13 -07:00
Ryan Liptak
5059384b57 Introduce IterableDir.iterateAssumeFirstIteration
This allows for avoiding an unnecessary lseek (or equivalent) call in places where it can be known that the fd has not had its cursor modified yet.
2022-10-05 02:20:13 -07:00
Andrew Kelley
ff534d2267
Merge pull request #12979 from Vexu/inline-switch
Implement inline switch cases
2022-10-03 23:43:09 -04:00
GethDW
9d5462dcb5
std: fix memory leak in ArrayHashMap (#13001) 2022-10-03 22:57:53 -04:00
Luuk de Gram
8bbb022500 std: WASI - update to latest snapshot preview 1
This implements the new addition to the API: `sock_accept`.
Reference commit of WASI spec:
0ba0c5e2e37625ca5a6d3e4255a998dfaa3efc52

For full details:
0ba0c5e2e3

For entire spec at this commit:
0ba0c5e2e3/phases/snapshot/docs.md
2022-10-03 22:48:57 -04:00
zooster
db5562deb0 std.os.windows: fix HANDLER_ROUTINE callconv 2022-10-03 13:05:38 +03:00
alex
2eb0909206 std.ChildProcess: correct fn getUserInfo pkg in setUserName
17b0166e moved getUserInfo from std.os to std.process
but ChildProcess.setUserName never updated the pkg name.
2022-10-03 12:59:47 +03:00
zooster
91b05ad473 std.math: allow comptime_float for radiansToDegrees and degreesToRadians
And some other minor things.
2022-10-01 13:46:20 +03:00
r00ster91
f6312e4b69 docs: minor improvements
Just some minor improvements when passing by.
2022-09-29 21:40:25 +02:00
r00ster91
fda0b2c372 fix(std.testing.refAllDeclsRecursive): silently return if !builtin.is_test 2022-09-29 21:40:25 +02:00