28711 Commits

Author SHA1 Message Date
Leo Emar-Kar
f88a971e4f
std.fmt: fix incorrect rounding on 0 precision of a decimal 2024-03-16 23:38:46 +00:00
Andrew Kelley
242ab81112
std: introduce pointer stability locks to hash maps (#17719)
This adds std.debug.SafetyLock and uses it in std.HashMapUnmanaged by
adding lockPointers() and unlockPointers().

This provides a way to detect when an illegal modification has happened and
panic rather than invoke undefined behavior.
2024-03-16 18:45:10 -04:00
Andrew Kelley
1b8d1b18c7
Merge pull request #19271 from The-King-of-Toasters/falling-metal-pipe
Windows: Replace CreatePipe with ntdll implementation
2024-03-16 15:44:02 -07:00
Stephen Gregoratto
67df3ded68 Windows: make FILE_INFO_BY_HANDLE_CLASS a tagged enum
Fixes a TODO referencing the ancient issue #305.
2024-03-16 23:37:50 +11:00
Stephen Gregoratto
69175ad62f Windows: Add wrappers for GetCurrent(Process|Thread) via NT_TIB
This is how they've been implemented in `kernel32` since NT 3.1.
2024-03-16 23:37:50 +11:00
Stephen Gregoratto
9532f72937 Windows: Replace CreatePipe with ntdll implementation
This implementation is now a direct replacement for the `kernel32` one.
New bitflags for named pipes and other generic ones were added based on
browsing the ReactOS sources.

`UNICODE_STRING.Buffer` has also been changed to be nullable, as
this is what makes the implementation work.
This required some changes to places accesssing the buffer after a
`SUCCESS`ful return, most notably `QueryObjectName` which even referred
to it being nullable.
2024-03-16 23:37:50 +11:00
Andreas Herrmann
dbb11915bd Fix "unable to generate DLL import .lib file"
Closes https://github.com/ziglang/zig/issues/19284

As of 9f2cb920c055bc990cc9d593b8dc9eaa450d07b9 configuring the global
cache directory to a relative path causes errors of the following form
when cross compiling to `windows-gnu`.
```
error: unable to generate DLL import .lib file for kernel32: FileNotFound
```

The issue occurred because the `def_final_path` included the global
cache path as a prefix and later on the `def_final_file` was created
using that path with the global cache directory handle.
2024-03-16 13:33:36 +02:00
zhylmzr
fe61b19b96 macos: archive size fix
fixed: #19154
2024-03-16 07:33:18 +01:00
Igor Anić
3ea1276eeb
io_uring: ring mapped buffers (#17806)
* io_uring: ring mapped buffers

Ring mapped buffers are newer implementation of ring provided buffers, supported
since kernel 5.19. Best described in Jens Axboe [post](https://github.com/axboe/liburing/wiki/io_uring-and-networking-in-2023#provided-buffers)

This commit implements low level io_uring_*_buf_ring_* functions as mostly
direct translation from liburing. It also adds BufferGroup abstraction over those
low level functions.

* io_uring: add multishot recv to BufferGroup

Once we have ring mapped provided buffers functionality it is possible to use
multishot recv operation. Multishot receive is submitted once, and completions
are posted whenever data arrives on the socket. Received data are placed in a
new buffer from buffer group.

Reference: [io_uring and networking in 2023](https://github.com/axboe/liburing/wiki/io_uring-and-networking-in-2023#multi-shot)

Getting NOENT for cancel completion result, meaning:
  -ENOENT
    The request identified by user_data could not be located.
    This could be because it completed before the cancelation
    request was issued, or if an invalid identifier is used.

https://man7.org/linux/man-pages/man3/io_uring_prep_cancel.3.html
https://github.com/ziglang/zig/actions/runs/6801394000/job/18492139893?pr=17806

Result in cancel/recv cqes are different depending on the kernel.
on older kernel (tested with v6.0.16, v6.1.57, v6.2.12, v6.4.16)
  cqe_cancel.err() == .NOENT
  cqe_crecv.err() == .NOBUFS
on kernel (tested with v6.5.0, v6.5.7)
  cqe_cancel.err() == .SUCCESS
  cqe_crecv.err() == .CANCELED
2024-03-15 22:34:31 -04:00
Andrew Kelley
ce4245f873
Merge pull request #19312 from mikdusan/bsd-debitrot
bsd: debitrot
2024-03-15 16:59:05 -07:00
Andrew Kelley
cb419a1a86 langref: caution against default field values
closes #19169
2024-03-15 16:37:13 -07:00
Loris Cro
5cd7fef17f build runner: add --summary new
`new` only prints summary nodes that were not cached.
Useful for build.zig authors to check if rebuilds happen exactly only
when expected.
2024-03-15 09:13:01 -07:00
Nguyễn Gia Phong
f13401ac69 Fix stuttering stderr in Zig test log
Before this fix, the stderr FIFO was advanced by the length
of the trimmed message, thus the next error log contained
the tail of that message.
2024-03-15 16:45:58 +02:00
Meghan Denny
4b1edad6e2 test: reenable some behavior vector tests 2024-03-15 16:42:10 +02:00
garrisonhh
1ddd0691c6 std.mem: use destructurable tuple for indexOfMinMax return type 2024-03-15 16:40:51 +02:00
Paul Jimenez
df174648e4
langref: bit-aligned -> byte-aligned 2024-03-15 16:40:03 +02:00
expikr
67a40c679d
make math.degreesToRadians and math.radiansToDegrees infer type from argument 2024-03-15 16:31:02 +02:00
paoda
a4508ad716 fix(math): eval isPowerOfTwo at comptime in rotl/rotr 2024-03-15 16:19:48 +02:00
Jakub Konka
d565c5dfcd macho: fix a sad typo in calculating the address of a TLV pointer 2024-03-15 08:17:10 +01:00
Michael Dusan
d7cf25f5ca
bsd: debitrot std.c
- follow-up to f4bf061d8a8
- updated std.fs.Dir to use properly named symbols
2024-03-15 02:28:50 -04:00
Michael Dusan
5ce40e61c6
bsd: debitrot AtomicOrder renames
- complete std.builtin.AtomicOrder renames that were missed from 6067d39522f
2024-03-15 02:28:50 -04:00
Michael Dusan
cf4a2099e1
dragonfly: debitrot std.c 2024-03-15 02:28:50 -04:00
mlugg
5193da3422 langref: add basic documentation of RLS 2024-03-15 03:10:45 +00:00
Elaine Gibson
6b38758594 coff: only store PDB basename 2024-03-14 18:56:02 -07:00
Michael Dusan
6724a524d4 bsd: add missing os.IFNAMESIZE
- based on system API value IF_NAMESIZE
- unblocks `zig test lib/std/std.zig`
2024-03-14 18:54:25 -07:00
Matthew Lugg
39459e78ad
Merge pull request #19273 from mlugg/incremental-some-more
compiler: more progress on incremental
2024-03-14 17:45:21 +00:00
Ahmed
5c8eda36d6 chore: Fix some typos 2024-03-14 19:43:24 +02:00
Motiejus Jakštys
400145ee3b reduce garbage for repeated zig cc - calls
Context: user provides `-` to read from stdin instead of a file.

Before: it would create a file in $ZIG_LOCAL_CACHE_DIR/tmp/ for each
invocation and leave it there.
After: it hashes the file contents and renames the file to the hash.

Result: repeated invocations of `zig cc` do not cause so much trash to
be created.
2024-03-14 09:32:56 -07:00
Andrew Kelley
bc5b094695 remove std.io.PeekStream
See #16114. This functionality should be added to bufferedReader
instead.
2024-03-14 07:48:47 -07:00
Luuk de Gram
0103c4bf78 std: make std.dwarf.FixedBufferReader public
Also fixes a compile-error as the field `is_64` no longer exists.
2024-03-14 02:57:46 -07:00
mlugg
7c32370194
Zcu: preserve ordering of usingnamespace decls
See comment. This slightly regresses a previous fix from this branch. A
proper solution will come soon, with the splitting up of `Decl` into
`Cau` and `Nav`.
2024-03-14 07:40:08 +00:00
mlugg
347196f905
Zcu: perform orphan checks against uncoerced function 2024-03-14 07:40:08 +00:00
mlugg
075c103332
compiler: add func_ies incremental dependencies
This was an oversight in my original design. This new form of dependency
is invalidated when the resolved IES for a runtime function changes.
2024-03-14 07:40:08 +00:00
mlugg
1421d329a3
compiler: progress towards incremental
Most basic re-analysis logic is now in place. Trivial updates are
hitting linker assertions.
2024-03-14 07:40:07 +00:00
mlugg
7ba8641d19
Zcu: handle updates to file root struct 2024-03-14 07:40:07 +00:00
mlugg
42fedb3f6c
Zcu: handle incremental updates (more) correctly when scanning namespaces 2024-03-14 07:40:06 +00:00
mlugg
d4ce1ec8dd
Zcu: convert Decl.zir_inst_index to a TrackedInst.Index.Optional
This makes tracking easier across incremental updates: `scanDecl` can
now tell whether an existing decl in a namespace was mapped to the one
it's analyzing in the new ZIR.
2024-03-14 07:40:06 +00:00
mlugg
7c4793f23c
Zcu: remove old decls after scanning namespace 2024-03-14 07:40:06 +00:00
mlugg
48af67c152
Zcu: rename implicitly-named decls to avoid overriding by explicit decls 2024-03-14 07:40:05 +00:00
mlugg
00969062a9
compiler: detect duplicate test names in AstGen
There is no reason to perform this detection during semantic analysis.
In fact, doing so is problematic, because we wish to utilize detection
of existing decls in a namespace in incremental compilation.
2024-03-14 07:40:05 +00:00
Andrew Kelley
778ab767b1
Merge pull request #19258 from castholm/enums-eval-branch-quota
std.enums: Increase eval branch quotas
2024-03-13 18:50:12 -07:00
Jonathan Marler
32f602ad16
std.os.windows: handle OBJECT_NAME_INVALID in OpenFile (#19288)
It's been seen on Windows 11 (22H2) Build 22621.3155 that NtCreateFile
will return the OBJECT_NAME_INVALID error code with certain path names.
The path name we saw this with started with `C:Users` (rather than
`C:\Users`) and also contained a `$` character.  This PR updates our
OpenFile wrapper to propagate this error code as `error.BadPathName`
instead of making it `unreachable`.

see https://github.com/marler8997/zigup/issues/114#issuecomment-1994420791
2024-03-13 21:39:20 -04:00
Carl Åstholm
2008b14bc7 autodoc: Use code for keyboard events 2024-03-13 18:37:00 -07:00
pancelor
7a858257f2 remove math.lerp bounds for t
I think of lerp() as a way to change coordinate systems, essentially
remapping the input numberline onto a shifted+rescaled numberline. In
my mind the full numberline is remapped, not just the 0-1 segment.

An example of how this is useful: in a game, you can write:
`myPos = lerp(pos0, pos1, easeOutBack(u))`
for some `u` that changes from 0 to 1 over time.
(see https://easings.net/#easeOutBack)
This will animate `myPos` between `pos0` and `pos1`, overshooting the
goal position `pos1` in a nicely-animated way.
`easeOutBack(float)->float` is a pure function that overshoots 1,
and by combining it with `lerp()` we can remap coordinates in other
coordinate systems, making them overshoot in the same way.

However, this overshooting is only possible because `easeOutBack(t)`
sometimes exceeds the range 0-1 (e.g. `easeOutBack(0.5)` is 1.0877),
which is not allowed by the current `math.lerp` implementation.

This commit removes the asserts that prevented this use-case. Now, any
value can be inputted for t. For example, `lerp(10,20, 2.0)` will now
return 30, instead of throwing an assert error.
2024-03-13 18:35:07 -07:00
Andrew Kelley
ea8e9e668b
Merge pull request #19289 from ianic/issue_19052
compress.xz: fix slow running read loop
2024-03-13 18:32:50 -07:00
Adrià Arrufat
17bad9f886 Fix emscripten exports 2024-03-13 21:47:31 +01:00
Igor Anić
791c4491a7 compress.xz: remove unnecessary variable
`to_read.items.len is always zero when entering readBlock.
2024-03-13 18:43:36 +01:00
Igor Anić
54f882c4aa compress.xz: make reader loop little more readable
No need to do same error check on two places. First return all
uncompressed data then on last read check error.
2024-03-13 18:41:20 +01:00
Igor Anić
a21f9b6d8b compress.xz: remove copyForwards from tight loop
In the example from the issue #19052 to_read holds 213_315_584
uncompressed bytes. Calling read with small output results in many
shifts of that big buffer.
This removes need to shift to_read after each read.
2024-03-13 18:22:08 +01:00
Jakub Konka
b9cca3b63d
Merge pull request #19257 from ziglang/elf-aarch64-thunks-2
elf+aarch64: fix off-by-one in converging on groups interleaved with thunks
2024-03-13 14:46:45 +01:00