Commit graph

34717 commits

Author SHA1 Message Date
Andrew Kelley
e252e6c696
Merge pull request #24847 from squeek502/zstd-partial-magic
zstd.Decompress: Treat a partial magic number as a failure
2025-08-14 16:08:06 -07:00
Justus Klausecker
2761cc8be0 zig fmt: add tests for cast builtin canonicalization 2025-08-14 14:44:35 -07:00
Ryan Liptak
353cf1f671 zstd.Decompress: Delete unused/impossible "end" state 2025-08-14 14:08:49 -07:00
Ryan Liptak
60b0b21296 zstd.Decompress: Treat a partial magic number as a failure
Previously, the "allow EndOfStream" part of this logic was too permissive. If there are a few dangling bytes at the end of the stream, that should be treated as a bad magic number. The only case where EndOfStream is allowed is when the stream is truly at the end, with exactly zero bytes available.
2025-08-14 14:08:49 -07:00
Alex Rønne Petersen
be51d69dc7
Merge pull request #24845 from alexrp/netbsd-fixes
Update NetBSD system headers; make TSan cross-compilable for NetBSD
2025-08-14 22:55:02 +02:00
Andrew Kelley
af7e142485 std.Io.Writer: introduce rebase to the vtable
fixes #24814
2025-08-14 12:56:37 -07:00
Frank Denis
96e4825fbb
Validate wildcard TLS certificates correctly (#24829)
Validate wildcard certificates as specified in RFC 6125.

In particular, `*.example.com` should match `foo.example.com` but
NOT `bar.foo.example.com` as it previously did.
2025-08-14 13:57:00 +00:00
Alex Rønne Petersen
6317417fe1
test: enable tsan test for x86_64-netbsd 2025-08-14 08:25:50 +02:00
Alex Rønne Petersen
234630bb8d
netbsd: add some missing system headers
The Lua headers are needed because, yes, NetBSD has a kernel module for Lua
support. soundcard.h is technically a system header but is installed by
libossaudio and so was missed previously.

This also removes some riscv headers that shouldn't have been added because
NetBSD does not yet officially support the riscv32/riscv64 ports.

Closes #24737.
2025-08-14 08:25:08 +02:00
Andrew Kelley
6bcdcf85c7 std.fs.File.Writer.sendFile: handle sendfile errors
fixes #24842
2025-08-13 22:16:08 -07:00
Alex Rønne Petersen
007cc817a1
tsan: remove usage of libnvmm and libncurses headers on netbsd
https://github.com/llvm/llvm-project/pull/153534
2025-08-14 07:11:07 +02:00
Stephen Gregoratto
6080f2d5ea Linux: Use time64 syscalls when available
Newer 32-bit Linux targets like 32-bit RISC-V only use the 64-bit
time ABI, with these syscalls having `time64` as their suffix.

This is a stopgap solution in favor of a full audit of `std.os.linux` to
prepare for #4726.

See also #21440 for prior art.
2025-08-14 10:24:57 +10:00
Stephen Gregoratto
6f60c8eca7 Linux: Update syscall list for 6.16
The generic syscall table has different names for syscalls that take a
timespec64 on 32-bit targets, in that it adds the `_time64` suffix.
Similarly, the `_time32` suffix has been removed.

I'm not sure if the existing logic for determining the proper timespec
struct to use was subtly broken, but it should be a good chance to
finish #4726 - we only have 12 years after all...

As for the changes since 6.11..6.16:

6.11:
 - x86_64 gets `uretprobe`, a syscall to speed up returning BPF probes.
 - Hexagon gets `clone3`, but don't be fooled: it just returns ENOSYS.
6.13:
 - The `*xattr` family of syscalls have been enhanced with new `*xattrat`
   versions, similar to the other file-based `at` calls.
6.15:
 - Atomically create a detached mount tree and set mount options on it.

Finally, this commit also adds the syscall numbers for OpenRISC and maps
it to the `or1k` cpu.
2025-08-14 10:22:15 +10:00
Stephen Gregoratto
c5f10a3f7d Rewrite generate_linux_syscalls to be completely table based
Changes by Arnd Bergmann have migrated all supported architectures to
use a table for their syscall lists. This removes the need to use the
C pre-processor and simplifies the logic considerably.

All currently supported architectures have been added, with the ones Zig
doesn't support being commented out. Speaking of; OpenRisc has been
enabled for generation.
2025-08-14 10:19:31 +10:00
Alex Rønne Petersen
27d6614f81
Merge pull request #24825 from alexrp/freebsd-fixes 2025-08-14 01:00:30 +02:00
Matthew Lugg
b87b958687
Merge pull request #24816 from mlugg/small-fixes
two small fixes
2025-08-13 23:55:21 +01:00
mlugg
3736aac778 Dwarf: handle noreturn union fields in more places
A little clunky -- maybe the frontend should give an answer here -- but
this patch makes sense with the surrounding logic just to fix the crash.

Resolves: #24265
2025-08-13 23:52:40 +01:00
mlugg
e304a478c0 build runner: fix single-threaded build
Resolves: #24723
2025-08-13 23:50:57 +01:00
Kendall Condon
4f639ff880 http: fix handling of limit in chunkedSendFile
`limit` in chunkedSendFile applies only to the file, not the entire
chunk. `limit` in sendFileHeader does not include the header.

Additionally adds a comment to clarify what `limit` applies to in
sendFileHeader and fixed a small bug in it (`drain` is able to return
less then `header.len`).
2025-08-13 13:14:01 -07:00
Andrew Kelley
5e986fef1f std.fs.File.Reader: fix seekBy
Tested locally:

stage3/bin/zig build test -Dskip-release -Dskip-non-native

closes #24495
closes #24498
closes #24713
2025-08-13 12:24:14 -07:00
Matthew Lugg
a495628862
Merge pull request #24674 from Justus2308/undef-shift-bitwise
Sema: Improve comptime arithmetic undef handling
2025-08-13 14:04:59 +01:00
David Rubin
8e02f9f70d sema: strip @splat operand result type before checking it 2025-08-13 13:55:57 +01:00
Matthew Lugg
6e90ce2536
Merge pull request #24381 from Justus2308/switch-better-underscore
Enhance switch on non-exhaustive enums
2025-08-13 13:54:15 +01:00
mlugg
ba6abd71c2
llvm: unions which are equivalent to enums are not by-ref
The LLVM backend lowers unions where all fields are zero-bit as
equivalent to their backing enum, and expects them to have the same
by-ref-ness in at least one place in the backend, probably more.

Resolves: #23577
2025-08-13 11:36:16 +01:00
mlugg
38ba425b26
llvm: support small error limits
Resolves: #23533
2025-08-13 11:36:16 +01:00
Isaac Freund
b8124d9c0b std.io.Writer.Allocating: rename getWritten() to written()
This "get" is useless noise and was copied from FixedBufferWriter.
Since this API has not yet landed in a release, now is a good time
to make the breaking change to fix this.
2025-08-13 01:43:52 -07:00
Erik Schlyter
7abd62800c std.crypto.aegis: Absorb ad instead of encrypting it.
`Aegis256XGeneric` behaves differently than `Aegis128XGeneric` in that
it currently encrypts associated data instead of just absorbing it. Even
though the end result is the same, there's no point in encrypting and
copying the ad into a buffer that gets overwritten anyway. This fix
makes `Aegis256XGeneric` behave the same as `Aegis128XGeneric`.
2025-08-13 09:00:57 +02:00
Alex Rønne Petersen
113d3dd3f0 std.Target: bump default android API level from 24 to 29
According to https://apilevels.com, 88.5% of Android users are on 29+. Older API
levels require libc as of https://github.com/ziglang/zig/pull/24629, which has
confused some users. Seems reasonable to bump the default so most people won't
be confused by this.
2025-08-13 08:59:13 +02:00
Alex Rønne Petersen
662303d7e7
Merge pull request #24734 from Rexicon226/tsan-fix 2025-08-13 08:57:52 +02:00
Alex Rønne Petersen
b7602a17f8
freebsd: correctly define __FreeBSD_version to the first stable release
See: https://docs.freebsd.org/en/books/porters-handbook/versions

Closes #24819.
2025-08-13 08:46:52 +02:00
Alex Rønne Petersen
e089d21439
freebsd: fix PIC macro not being defined for crt1_s.S
Closes #24818.
2025-08-13 08:40:56 +02:00
Alex Rønne Petersen
e37fc57495
tsan: remove usage of libcrypt and libncurses headers
https://github.com/llvm/llvm-project/pull/153351

Closes #24736.
2025-08-13 08:40:35 +02:00
Rue
dd4e25cf44
optimize @intCast in llvm backend (#24739) 2025-08-13 00:56:31 +00:00
Justus Klausecker
8fda49ea8a fix: remove incorrect '&' 2025-08-12 16:33:58 +02:00
Justus Klausecker
277e4a8337 fix: emit vector instead of scalar u1_zero in shl_with_overflow logic 2025-08-12 16:33:58 +02:00
Justus Klausecker
4ec421372f add remaining undef value tests ; fix @truncate undef retval type 2025-08-12 16:33:58 +02:00
Justus Klausecker
f0ffe30f2f add undef shift tests ; mirror zirShl logic for @shlWithOverflow 2025-08-12 16:33:58 +02:00
Justus Klausecker
8f5ec2a1fb Sema: replace all remaining aggregate interns related to @typeInfo 2025-08-12 16:33:58 +02:00
Justus Klausecker
79756e681d remove redundant test cases 2025-08-12 16:33:58 +02:00
Justus Klausecker
76d2782149 replace most aggregate interns in x86_64/CodeGen 2025-08-12 16:33:57 +02:00
Justus Klausecker
79e5c138c6 replace even more aggregate interns 2025-08-12 16:33:57 +02:00
Justus Klausecker
7756fa6641 Sema: replace most aggregate interns with pt.aggregateValue 2025-08-12 16:33:57 +02:00
Justus Klausecker
05762ca02f address most comments 2025-08-12 16:33:57 +02:00
Justus Klausecker
0ef26d113a make >> a compile error with any undef arg ; add a bunch of test cases 2025-08-12 16:33:57 +02:00
Justus Klausecker
d0586da18e Sema: Improve comptime arithmetic undef handling
This commit expands on the foundations laid by https://github.com/ziglang/zig/pull/23177
and moves even more `Sema`-only functionality from `Value`
to `Sema.arith`. Specifically all shift and bitwise operations,
`@truncate`, `@bitReverse` and `@byteSwap` have been moved and
adapted to the new rules around `undefined`.

Especially the comptime shift operations have been basically
rewritten, fixing many open issues in the process.

New rules applied to operators:
* `<<`, `@shlExact`, `@shlWithOverflow`, `>>`, `@shrExact`: compile error if any operand is undef
* `<<|`, `~`, `^`, `@truncate`, `@bitReverse`, `@byteSwap`: return undef if any operand is undef
* `&`, `|`: Return undef if both operands are undef, turn undef into actual `0xAA` bytes otherwise

Additionally this commit canonicalizes the representation of
aggregates with all-undefined members in the `InternPool` by
disallowing them and enforcing the usage of a single typed
`undef` value instead. This reduces the amount of edge cases
and fixes a bunch of bugs related to partially undefined vecs.

List of operations directly affected by this patch:
* `<<`, `<<|`, `@shlExact`, `@shlWithOverflow`
* `>>`, `@shrExact`
* `&`, `|`, `~`, `^` and their atomic rmw + reduce pendants
* `@truncate`, `@bitReverse`, `@byteSwap`
2025-08-12 16:33:57 +02:00
Andrew Kelley
749f10af49 std.ArrayList: make unmanaged the default 2025-08-11 15:52:49 -07:00
Jacob Young
d625158354 aarch64: implement more assembler instructions 2025-08-11 15:47:51 -07:00
Andrew Kelley
59de7e3a57 std: introduce orderedRemoveMany
This algorithm is non-trivial and makes sense for any data structure
that acts as an array list, so I thought it would make sense as a
method.

I have a real world case for this in a music player application
(deleting queue items).

Adds the method to:
* ArrayList
* ArrayHashMap
* MultiArrayList
2025-08-11 13:32:12 -07:00
Andrew Kelley
282c3575b1 std.fs.File: prefer getSize over getEndPos
The former detects when it is appropriate to switch to streaming mode.

closes #24798
2025-08-11 12:27:52 -07:00
Jacob Young
60f8584927 Dwarf: port to new Writer API 2025-08-11 12:00:50 -07:00