5815 Commits

Author SHA1 Message Date
Naoki MATSUMOTO
059e397ffc std.os: handle error.UnreachableAddress in send() 2022-10-17 13:10:23 +02:00
Jens Goldberg
1459231624 fix setsockopt returning ENODEV 2022-10-17 12:55:12 +02:00
Ali Chraghi
5127dae7a2 std.os: fix execv* doc comment 2022-10-16 11:38:22 -04:00
dan
ca1c185eb6
std.zig: search include dir and lib dir from environment variables (#13145)
* minor fix based on feedback from @marler8997

Co-authored-by: dan <i@dan.games>
2022-10-16 11:37:35 -04:00
bfredl
c750d95417 os.linux: some fixes to BPF module
- For ALU operations, src should be allowed to be an explicit Reg.
- Expose AluOp and JmpOp as public types.
  This makes code generation using BPF as a backend easier,
  as AluOp and JmpOp can be used directly as part of an IR
2022-10-16 11:36:11 -04:00
Evin Yulo
b346d48572 Simplify code in std.meta.isTag 2022-10-16 11:35:27 -04:00
Isaac Yonemoto
99c3578f69
adds isTag function to std.meta (#11895) 2022-10-15 14:32:05 -04:00
Andrew Kelley
c0d7f64036
Merge pull request #12448 from r00ster91/ultimateascii
std.ascii: rename functions and other improvements
2022-10-15 14:28:33 -04:00
Andrew Kelley
c289794f0d nvptx: add TODO comment regarding abuse of llvm builtins 2022-10-15 10:50:02 -07:00
Guillaume Wenzek
24c749473a implement os.abort and panic for cuda 2022-10-15 10:39:19 -07:00
Guillaume Wenzek
aad983cf40 sanitize qualified name for nvptx backend 2022-10-15 10:39:19 -07:00
Andrew Kelley
66d6183001 Merge branch 'amdgpu-improvements' of https://github.com/Snektron/zig into Snektron-amdgpu-improvements 2022-10-15 10:36:10 -07:00
Andrew Kelley
16cc65242f
Merge pull request #12918 from jacobly0/math-cast-comptime-int
std.math: fix behavior relating to comptime_int arguments
2022-10-15 12:11:55 -04:00
xEgoist
ae39e7867d Added os check for std.fs.setAsCwd() to work with windows
Due to the unavailability of fchdir in Windows, a call for setting the
CWD needs to either call chdir with the path string or call
SetCurrentDirectory.
Either way, since we are dealing with a Handle in Windows, a call for
GetFinalPathNameByHandle is necessary for getting the file path first.
2022-10-15 11:05:15 -04:00
Andrew Kelley
b4e3424594
Merge pull request #13100 from topolarity/powerpc64le
stage2: Fix softfloat support for PPC64(LE)
2022-10-15 10:05:00 -04:00
Ryan Liptak
8bb2e96ac3 std.os.windows: Change HKEY to *opaque {}
The definition of HKEY__ as a struct with an unused int field is only the case in the Windows headers when `STRICT` is defined. From https://learn.microsoft.com/en-us/windows/win32/winprog/enabling-strict:

> When STRICT is defined, data type definitions change as follows:
>
> -  Specific handle types are defined to be mutually exclusive; for example, you will not be able to pass an HWND where an HDC type argument is required. Without STRICT, all handles are defined as HANDLE, so the compiler does not prevent you from using one type of handle where another type is expected.

Zig's `opaque {}` already gives this benefit to us, so the usage of a struct with an unused field is unnecessary, and it was causing HKEY to have an alignment of 4, which is a problem because there are HKEY constants like HKEY_LOCAL_MACHINE (0x80000002) that are not 4-byte aligned. Without this change, the compiler would not allow something like HKEY_LOCAL_MACHINE to be defined since it enforces pointer alignment.
2022-10-14 15:23:13 -04:00
Evan Haas
e4e1c21e1f i386 ABI: Fix some sizes and alignments
This makes the following changes for i386:

long long and unsigned long long have 4 byte alignment on non-Windows

f64 (double) has 4-byte alignment on non-Windows

long double is 80 bits and has 4 byte alignment on mingw

long double on android is 64 bits, not 80: https://www.uclibc.org/docs/psABI-i386.pdf

Fixes #12453
Fixes #12987
2022-10-14 15:22:00 -04:00
Ryan Liptak
c8da03a0e1 Fix compile error in Dir.deleteTreeMinStackSize and add test
Follow up to #13073
2022-10-14 14:48:23 -04:00
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
Cody Tapscott
b8c587eb40 tests: Enable PPC64LE as a test target 2022-10-13 12:53:20 -07:00
Cody Tapscott
37c6fcafa2 stage2 LLVM: Correct long double for WASM
Also, f16 is not supported on this backend.
2022-10-13 12:53:20 -07: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
Jacob Young
02d7292a8c build.zig: Forward LLVM lib/include dirs from CMake
Previously, you might obtain `-lLLVM-15` from the CMake configuration,
but we might not be able to locate the library if it's not in your
system library path.
2022-10-12 18:11:46 -04:00
Robin Voetter
9ff60e356e
typo 2022-10-12 20:38:43 +02:00
Robin Voetter
9f14681473
stage2: check address space cast validity 2022-10-12 20:36:14 +02:00
Robin Voetter
5859d8458f
big int: make Mutable.normalize const 2022-10-12 20:34:41 +02:00
Robin Voetter
6b69dcfdd2
amdgpu: add AmdgpuKernel calling convention 2022-10-12 20:34:41 +02: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
Jacob Young
e78d7704a4 math.big.int: document the purpose of limb_len in scalar methods
Ideally this duplicated code could be factored out into a function, but
there doesn't seem to be any way in the Zig type system to represent an
argument to a function called at comptime that is only needed if it is
comptime-known.  Instead, we document what is going on in an adjacent
comment in case it gets copy-pasted into new methods in the future.
2022-10-12 08:56:13 -04:00
Jacob Young
38ee512a25 math.big.int: add calcLimbLen doc comment note
When trying to allocate memory for functions like `Managed.init` and
`Managed.set` on the stack, a comptime-known allocation size is desired.
The doc comments for these functions indicate that `calcLimbLen` can be
used to determine how many limbs to allocate, but if `value` is not
comptime-known, then neither is `calcLimbLen(value)`.  However, an upper
bound on the allocation size is still computable at comptime in this
case, so this note documents an expression that can be used, rather than
trying to add it to every doc comment that mentions `calcLimbLen`.
2022-10-12 08:18:47 -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
Jacob Young
2fe5bdb9ed big.int: rewrite confusing code in an equivalent but less confusing way 2022-10-11 19:57:13 -04:00
Jacob Young
5c49341f09 big.int: add support for non-comptime scalars 2022-10-11 19:51:03 -04:00
Jacob Young
7a89eebfc6 std.math: add support to cast for a comptime_int argument
This allows converting a comptime_int to an optional integer type, which
either behaves the same as an implicit cast or produces null if the
argument is outside the range of the destination type.
2022-10-11 19:51:03 -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