Commit graph

12789 commits

Author SHA1 Message Date
John Benediktsson
47a2f2ddae
Merge pull request #24926 from mrjbq7/http-fetch
http.Client: don't forget to flush
2025-08-22 12:35:18 -07:00
GasInfinity
306176046e chore(std.Target): explicitly set baseline only to arm with 3ds
* `arm` is the only supported tag for 3ds

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-08-22 04:14:53 +02:00
GasInfinity
851f31b0e1 chore(std.Target): document the 3ds version range 2025-08-22 04:14:53 +02:00
GasInfinity
cc71936eb9 feat(std.Target): add 3ds os 2025-08-22 04:14:53 +02:00
Raiden1411
55daefdb10 std: remove lossy int to float coercion on json parse 2025-08-22 02:50:26 +02:00
Andrew Kelley
595c9d2353
Merge pull request #24921 from Justus2308/messy-mach
std.c.darwin: cleanup, expose everything in std.c
2025-08-21 11:52:22 -07:00
Justus Klausecker
1594c80555 zig reduce: adapt to new Writer API 2025-08-21 11:50:03 -07:00
Isaac Freund
52de06c3b0 langref: sync with zig-spec grammar.peg 2025-08-21 17:12:38 +02:00
Sardorbek Imomaliev
01b5023868
drop NameTooLong from sysctlbynameZ error set (#24909) 2025-08-21 12:36:57 +02:00
Justus Klausecker
da4c9af354 make some compile errors aliases instead 2025-08-21 11:33:34 +02:00
Lwazi Dube
cab6d752e8 std.os.uefi: Fix typo that causes compile time error #22809" 2025-08-21 03:10:28 +01:00
Brandon Black
8248597a27 Add mlock syscalls to std.c and std.posix
Linux already gained the relevant syscalls and consts in #24473

The basic mlock() and munlock() are fairly universal across the
*nix world with a consistent interface, but are missing on wasi
and windows.

The mlockall() and munlockall() calls are not as widely supported
as the basic ones.  Notable non-implementers include darwin,
haiku, and serenity (and of course wasi and windows again).

mlock2() is Linux-only, as are its MLOCK flags.
2025-08-20 23:38:45 +02:00
Carl Åstholm
172e97154d Use readStreaming, not readPositional, for streaming file readVec on Windows 2025-08-20 21:49:07 +02:00
Alex Rønne Petersen
07cc32b004 wasi-libc: update to c89896107d7b57aef69dcadede47409ee4f702ee 2025-08-20 19:18:11 +02:00
Justus Klausecker
590d264bdf std.c.darwin: cleanup, expose everything in std.c
This mainly just moves stuff around.
Justifications for other changes:
* `KEVENT.FLAGS` is backed by `c_uint` because that's what the `kevent64` flags param takes (according to the 'latest' manpage from 2008)
* `MACH_RCV_NOTIFY` is a legacy name and `MACH_RCV_OVERWRITE` is deprecated (xnu/osfmk/mach/message.h), so I removed them. They were 0 anyway and thus couldn't be represented
as a packed struct field.
* `MACH.RCV` and `MACH.SEND` are technically the same 'type' because they can both be supplied at the same time to `mach_msg`. I decided to still keep them separate because
naming works out better that way and all flags except for `MACH_MSG_STRICT_REPLY` aren't shared anyway. Both are part of a packed union `mach_msg_option_t` which supplies a
helper function to combine the two types.
* `PT` is backed by `c_int` because that's what `ptrace` takes as a request arg (according to the latest manpage from 2015)
2025-08-20 18:21:32 +02:00
Justus Klausecker
d748cc9c12 expose darwin.PT in std.c 2025-08-19 16:18:27 -07:00
Carl Åstholm
9e9cb3ad6d Fix bugs in Windows readVec implementations 2025-08-19 16:18:02 -07:00
TemariVirus
51a2c0feaf std.Io.Writer: fix upper case hex float formatting 2025-08-19 11:20:30 -07:00
Rohlem
81f5a7b8fd
never advance seek position in std.Io.Reader.peekDelimiterExclusive (#24899)
* extend std.Io.Reader.peekDelimiterExclusive test to repeat successful end-of-stream path (fails)

* fix std.Io.Reader.peekDelimiterExclusive to not advance seek position in successful end-of-stream path
2025-08-19 11:19:02 -07:00
Andrew Kelley
89c9282d34 std.http.Client: discard response body when reusing connection
When an error response was encountered, such as 404 not found, the body
wasn't discarded, leading to the string "404 not found" being
incorrectly interpreted as the next request's response.

closes #24732
2025-08-18 17:26:55 -07:00
Giuseppe Cesarano
b734d03340
Expanded std.os.linux perf-related definitions (#24264)
* Added perf_event_header definition

* Added perf_event_mmap_page definition

* Removed default values for perf_event_header

* Fixed comments typos

* Updated perf_event_attr definition

* Explicit packet struct type

* PERF.RECORD from struct to enum

* fix typo: miscs to misc

* misc as packed struct

* cpu_mode as named enum

* Rescoping CPU_MODE
2025-08-18 21:32:44 +00:00
Isaac Freund
c315f2bc2e http.BodyWriter: improve clarity of chunked state machine
This is theoretically a bugfix as well, since it enforces the correct
limit on the first write after writing the header. This theoretical bug
hasn't been hit in practice though as far as I know.
2025-08-17 14:42:57 +02:00
Andrew Kelley
623290ea9b
Merge pull request #24864 from ifreund/fix-std-cmd
http.BodyWriter: handle EOF in chunkedSendFile, simplify
2025-08-16 16:24:11 -07:00
Isaac Freund
551e009da7 Build.Step.Run: fix missing stdin buffer and flush
Writer.sendFileAll() asserts non-zero buffer capacity in the case that
the fallback is hit. It also requires the caller to flush. The buffer
may be bypassed as an optimization but this is not a guarantee.

Also improve the Writer documentation and add an earlier assert on
buffer capacity in sendFileAll().
2025-08-16 15:43:48 -07:00
Andrew Kelley
399bace2f2
Merge pull request #24874 from ziglang/tls-client
std: more reliable HTTP and TLS networking
2025-08-16 14:47:52 -07:00
Andrew Kelley
ef14c73245 Compilation: remove last instance of deprecatedReader
This also makes initStreaming preemptively disable file size checking.
2025-08-16 14:46:20 -07:00
Isaac Freund
0cfd07bc86
http.BodyWriter: handle EOF in chunkedSendFile, simplify
With these changes, the `zig std` command now works again and doesn't
trigger assertion failures or mess up the chunked transfer encoding.
2025-08-16 22:07:16 +02:00
Isaac Freund
ce4e8a991f
std-docs: improve error message on write failure 2025-08-16 17:43:15 +02:00
Josh Wolfe
4fcdb08390 [std] fix compile error in std.Io.Writer.failing 2025-08-16 00:23:47 -07:00
Özgür Akkurt
99c4890559
implement registering NAPI on IoUring (#24850) 2025-08-16 09:18:49 +02:00
Andrew Kelley
a0f9a5e78d std: more reliable HTTP and TLS networking
* std.Io.Reader: fix confused semantics of rebase. Before it was
  ambiguous whether it was supposed to be based on end or seek. Now it
  is clearly based on seek, with an added assertion for clarity.

* std.crypto.tls.Client: fix panic due to not enough buffer size
  available. Also, avoid unnecessary rebasing.

* std.http.Reader: introduce max_head_len to limit HTTP header length.
  This prevents crash in underlying reader which may require a minimum
  buffer length.

* std.http.Client: choose better buffer sizes for streams and TLS
  client. Crucially, the buffer shared by HTTP reader and TLS client
  needs to be big enough for all http headers *and* the max TLS record
  size. Bump HTTP header size default from 4K to 8K.

fixes #24872

I have noticed however that there are still fetch problems
2025-08-16 00:16:15 -07:00
Ryan Liptak
98547713a3 zstd: Protect against index out-of-bounds when decoding sequences
Previously, index out-of-bounds could occur when copying match_length bytes while decoding whatever sequence happened to overflow `dest`. Now, each sequence checks that there is enough room for the full sequence_length (literal_length + match_length) before doing any copying.

Fixes the failing inputs found here: https://github.com/ziglang/zig/issues/24817#issuecomment-3192927715
2025-08-15 22:11:51 -07:00
Rue
ee85c8b6d0
re-enable std.math.modf vector tests (#24786)
* re-enable std.math.modf vector tests
* re-disable std.math.modf vector tests for `aarch64-macos`
* re-disable for s390x architecture
2025-08-16 02:36:09 +00:00
mlugg
d835a6ba9a std.Build: improve error for peak RSS exceeding declared value
As well as the exact byte count, include a human-readable value so it's
clearer what the error is actually telling you. The exact byte count
might not be worth keeping, but I decided I would in case it's useful in
any scenario.
2025-08-15 23:03:16 +01:00
Fri3dNstuff
f758b97bfd
std.math: Add splat for vectors of u0s in rotl/rotr (#24822) 2025-08-15 23:45:33 +02:00
Manlio Perillo
39aca6f37e zon: Add anonymous struct literal in the example 2025-08-15 23:35:16 +02:00
Andrew Kelley
30b41dc510 std.compress.zstd.Decompress fixes
* std.Io.Reader: appendRemaining no longer supports alignment and has
  different rules about how exceeding limit. Fixed bug where it would
  return success instead of error.StreamTooLong like it was supposed to.

* std.Io.Reader: simplify appendRemaining and appendRemainingUnlimited
  to be implemented based on std.Io.Writer.Allocating

* std.Io.Writer: introduce unreachableRebase

* std.Io.Writer: remove minimum_unused_capacity from Allocating. maybe
  that flexibility could have been handy, but let's see if anyone
  actually needs it. The field is redundant with the superlinear growth
  of ArrayList capacity.

* std.Io.Writer: growingRebase also ensures total capacity on the
  preserve parameter, making it no longer necessary to do
  ensureTotalCapacity at the usage site of decompression streams.

* std.compress.flate.Decompress: fix rebase not taking into account seek

* std.compress.zstd.Decompress: split into "direct" and "indirect" usage
  patterns depending on whether a buffer is provided to init, matching
  how flate works. Remove some overzealous asserts that prevented buffer
  expansion from within rebase implementation.

* std.zig: fix readSourceFileToAlloc returning an overaligned slice
  which was difficult to free correctly.

fixes #24608
2025-08-15 10:44:35 -07:00
Frank Denis
c1eff72c4a
crypto/aes_ocb.zig: actually check against test vectors (#24835)
And use the correct bit endianness for padding
2025-08-15 13:09:06 +00:00
Andrew Kelley
e395c24c6d std.fs.File.Reader: fix freestanding build failures
This should be enough to unblock people for now. We'll revisit the way
these things are organized with the upcoming std.Io interface.

fixes #24685
2025-08-14 23:10:29 -07:00
Alex Rønne Petersen
47e6528762
Merge pull request #24702 from The-King-of-Toasters/syscall-tables
Rewrite Linux syscalls generation
2025-08-15 05:38:02 +02:00
Ryan Liptak
08f0780cb2 zstd.Decompress.stream: Fix handling of skippable frames in new_frame state
The previous code assumed that `initFrame` during the `new_frame` state would always result in the `in_frame` state, but that's not always the case. `initFrame` can also result in the `skippable_frame` state, which would lead to access of union field 'in_frame' while field 'skipping_frame' is active.

Now, the switch is re-entered with the updated state so either case is handled appropriately.

Fixes the crashes from https://github.com/ziglang/zig/issues/24817
2025-08-14 17:37:51 -07:00
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
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