10936 Commits

Author SHA1 Message Date
Andrew Kelley
6489907662 std.zip: work around deprecated API 2025-07-07 22:43:53 -07:00
Andrew Kelley
f4720e1407 std.testing: update to new std.io API 2025-07-07 22:43:53 -07:00
Andrew Kelley
9c8aef55b4 std.fmt.format: use {t} for tag name rather than {s}
prevents footgun when formatted type changes from string to enum
2025-07-07 22:43:52 -07:00
Andrew Kelley
30c2921eb8 compiler: update a bunch of format strings 2025-07-07 22:43:52 -07:00
Andrew Kelley
d5c97fded5 compiler: fix a bunch of format strings 2025-07-07 22:43:52 -07:00
Andrew Kelley
3afc6fbac6 std.zig.llvm.Builder: update format API 2025-07-07 22:43:52 -07:00
Andrew Kelley
cce32bd1d5 fix build runner 2025-07-07 22:43:52 -07:00
Andrew Kelley
756a2dbf1a compiler: upgrade various std.io API usage 2025-07-07 22:43:52 -07:00
Andrew Kelley
f71d97e4cb update compiler source to new APIs 2025-07-07 22:43:52 -07:00
Andrew Kelley
fac5fe57be std.io.Writer.Allocating: rename interface to writer 2025-07-07 22:43:52 -07:00
Andrew Kelley
fc310ee7bc std.io.Reader: fix appendRemaining 2025-07-07 22:43:52 -07:00
Andrew Kelley
4bca5faca6 std.Build.Cache: write manifest without heap allocating
Now that the buffered writing interface is not generic.
2025-07-07 22:43:52 -07:00
Andrew Kelley
d6ac04c478 std.Build.Step.CheckObject: fix the TODO 2025-07-07 22:43:52 -07:00
Andrew Kelley
87f32bec26 std.io.Reader: finish implementing the unit tests 2025-07-07 22:43:52 -07:00
Andrew Kelley
49093a659f std.debug: lil buffer for this guy 2025-07-07 22:43:52 -07:00
Andrew Kelley
8f4229158b std.io.Writer.Allocating: extra ensure byte
So that when returning from drain there is always capacity for at least
one more byte.
2025-07-07 22:43:52 -07:00
Andrew Kelley
d03d273117 std.io.Reader: fix fill implementation
now it avoids writing to buffer in the case of fixed
2025-07-07 22:43:52 -07:00
Andrew Kelley
1e1f026c83 std.mem.byteSwapAllFields: support slices 2025-07-07 22:43:52 -07:00
Andrew Kelley
1ee403ce93 std.io.Reader: add doctest for streamDelimiterLimit 2025-07-07 22:43:51 -07:00
Andrew Kelley
435ccf706d std.fs.File.Writer: fix drain implementation
it didn't account for data.len can no longer be zero
2025-07-07 22:43:51 -07:00
Andrew Kelley
77e839e283 std.io.Reader: fix streamDelimiter and streamDelimiterEnding 2025-07-07 22:43:51 -07:00
Andrew Kelley
1d763c8b29 std: formatted printing no longer prints type names
for structs, enums, and unions.

auto untagged unions are no longer printed as pointers; instead they are
printed as "{ ... }".

extern and packed untagged unions have each field printed, similar to
what gdb does.

also fix bugs in delimiter based reading
2025-07-07 22:43:51 -07:00
Andrew Kelley
0e37ff0d59 std.fmt: breaking API changes
added adapter to AnyWriter and GenericWriter to help bridge the gap
between old and new API

make std.testing.expectFmt work at compile-time

std.fmt no longer has a dependency on std.unicode. Formatted printing
was never properly unicode-aware. Now it no longer pretends to be.

Breakage/deprecations:
* std.fs.File.reader -> std.fs.File.deprecatedReader
* std.fs.File.writer -> std.fs.File.deprecatedWriter
* std.io.GenericReader -> std.io.Reader
* std.io.GenericWriter -> std.io.Writer
* std.io.AnyReader -> std.io.Reader
* std.io.AnyWriter -> std.io.Writer
* std.fmt.format -> std.fmt.deprecatedFormat
* std.fmt.fmtSliceEscapeLower -> std.ascii.hexEscape
* std.fmt.fmtSliceEscapeUpper -> std.ascii.hexEscape
* std.fmt.fmtSliceHexLower -> {x}
* std.fmt.fmtSliceHexUpper -> {X}
* std.fmt.fmtIntSizeDec -> {B}
* std.fmt.fmtIntSizeBin -> {Bi}
* std.fmt.fmtDuration -> {D}
* std.fmt.fmtDurationSigned -> {D}
* {} -> {f} when there is a format method
* format method signature
  - anytype -> *std.io.Writer
  - inferred error set -> error{WriteFailed}
  - options -> (deleted)
* std.fmt.Formatted
  - now takes context type explicitly
  - no fmt string
2025-07-07 22:43:51 -07:00
Andrew Kelley
0b3f0124dc std.io: move getStdIn, getStdOut, getStdErr functions to fs.File
preparing to rearrange std.io namespace into an interface

how to upgrade:

std.io.getStdIn() -> std.fs.File.stdin()
std.io.getStdOut() -> std.fs.File.stdout()
std.io.getStdErr() -> std.fs.File.stderr()
2025-07-07 22:43:51 -07:00
Nameless
7c42517151 os: fix missing and incorrect msghdr definitions
Macos uses the BSD definition of msghdr

All linux architectures share a single msghdr definition. Many
architectures had manually inserted padding fields that were endian
specific and some had fields with different integers. This unifies all
architectures to use a single correct msghdr definition.
2025-07-07 22:43:51 -07:00
Andrew Kelley
9f27d770a1 std.io: deprecated Reader/Writer; introduce new API 2025-07-07 22:43:51 -07:00
Andrew Kelley
34f64432b0 remove usingnamespace from the language
closes #20663
2025-07-07 13:39:48 -07:00
Andrew Kelley
aa52bb8327 zig fmt 2025-07-07 13:39:16 -07:00
Andrew Kelley
40d11cc25a remove async and await keywords
Also remove `@frameSize`, closing #3654.

While the other machinery might remain depending on #23446, it is
settled that there will not be `async`/ `await` keywords in the
language.
2025-07-07 13:39:16 -07:00
Alex Rønne Petersen
31e46be743 std.c: Use __sigemptyset14 for sigemptyset on NetBSD
Closes #24344.
2025-07-07 12:14:58 +02:00
jaune
ef8db03d52 std.posix.accept: add WSAENOTSOCK 2025-07-07 00:26:21 +02:00
Alex Rønne Petersen
9a8f1f675b start: Only issue fninit for x86(_64)-windows
Closes #24263.
2025-07-04 20:09:20 +02:00
Brandon Black
aa1556156e std.posix.getsockopt: set option length correctly
Fixes #24293
2025-07-03 09:41:26 +02:00
Alex Rønne Petersen
8e511e031f
std.crypto.salsa20: Disable some tests on RISC-V with vector support
https://github.com/ziglang/zig/issues/24299
2025-07-01 23:03:15 +02:00
Alex Rønne Petersen
1c9d9b70ec
std.bit_set: Disable IntegerBitSet decltest on RISC-V with vector support
https://github.com/ziglang/zig/issues/24300
2025-07-01 23:03:15 +02:00
Alex Rønne Petersen
3d7fb4f204
std.zig.system.linux: Add detection for some extra RISC-V CPUs 2025-07-01 23:03:15 +02:00
Alex Rønne Petersen
fd2d4507c8
std.os.linux: Define ucontext_t and mcontext_t for RISC-V
Closes #24239.
2025-07-01 23:03:13 +02:00
Alex Rønne Petersen
6b6e336e07
std.Build.Step.CheckObject: Truncate st_other before interpreting it
Tools are free to use the upper bits of this field for whatever; thus, tools
that want to interpret the visibility type should truncate to 2 bits.
2025-06-30 12:21:38 +02:00
Alex Rønne Petersen
b64fe53ad5
std.simd: Increase branch quota in suggestVectorLengthForCpu()
This does a bunch of CPU family and feature checks. It would be annoying to have
to @setEvalBranchQuota() at every comptime use site.
2025-06-30 08:01:27 +02:00
Dacheng
35329b510c
c.darwin: define MSG for macos (#24224)
* c.darwin: define MSG for macos

* darwin: add series os name

* Update lib/std/c.zig

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>

---------

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-06-24 15:07:06 +02:00
Alex Rønne Petersen
342c34d95e
Merge pull request #24238 from taylordotfish/bugfix/ppc64le-syscall 2025-06-24 15:06:31 +02:00
Pat Tullmann
710632b45c lib/std/fs/test.zig: Some filesystems support 8 EiB files
Btrfs at least supports 16 EiB files (limited in practice to 8EiB by the
Linux VFS code which uses signed 64-bit offsets).  So fix the fs.zig test
case to expect either a FileTooBig or success from truncating a file to
8EiB.  And test that beyond that size the offset is interpreted as a
negative number.

Fixes #24242
2025-06-23 15:20:24 +02:00
Kevin Boulain
640a130651 std.Build.Watch: key fanotify file descriptors by mount id
Since marks are limited to a single filesystem.
Context: https://github.com/ziglang/zig/issues/20670
Original pull request: https://github.com/ziglang/zig/pull/20672

Co-authored-by: Maciej 'vesim' Kuliński <vesim809@pm.me>
2025-06-23 06:08:25 +02:00
Ali Cheraghi
1df79ab895 remove spirv cpu arch 2025-06-23 06:03:03 +02:00
Ali Cheraghi
24bfefa75e std.mem.byteSwapAllFields: support untagged unions 2025-06-23 05:57:56 +02:00
taylor.fish
95b638f613 Update 32-bit PowerPC syscall functions
musl and glibc both specify r0 as an output register because its value
may be overwritten by system calls. As with the updates for 64-bit
PowerPC in the previous commit, this commit brings Zig's syscall
functions for 32-bit PowerPC in line with musl and glibc by adding r0 to
the list of clobbers. (Listing r0 as both an input and a clobber is as
close as we can get to musl, which declares it as a "+r" read-write
output, since Zig doesn't support multiple outputs or the "+"
specifier.)
2025-06-22 16:48:36 -07:00
taylor.fish
79807468e7 Fix illegal behavior from syscalls on powerpc64le
On powerpc64le Linux, the registers used for passing syscall parameters
(r4-r8, as well as r0 for the syscall number) are volatile, or
caller-saved. However, Zig's syscall wrappers for this architecture do
not include all such registers in the list of clobbers, leading the
compiler to assume these registers will maintain their values after the
syscall completes.

In practice, this resulted in a segfault when allocating memory with
`std.heap.SmpAllocator`, which calls `std.os.linux.sched_getaffinity`.
The third parameter to `sched_getaffinity` is a pointer to a `cpu_set_t`
and is stored in register r5. After the syscall, the code attempts to
access data in the `cpu_set_t`, but because the compiler doesn't realize
the value of r5 may have changed, it uses r5 as the memory address, which
in practice resulted in a memory access at address 0x8.

This commit adds all volatile registers to the list of clobbers.
2025-06-21 21:47:58 -07:00
Matthew Lugg
75d0ec9c04
Merge pull request #24227 from mlugg/misc-build-stuff
`std.Build`: more miscellaneous bits
2025-06-20 10:28:38 +01:00
Alex Rønne Petersen
14ad8378a1
Merge pull request #23464 from rootbeer/futex-casts
Linux futex (v1 and v2) API fixes, tests and Ziggification
2025-06-20 10:08:22 +02:00
mlugg
4a9e8b73aa
std.Build.Step.Run: pass correct relative cache dir to tests
Fixes an additional bug reported in the closed #24216.
2025-06-20 00:33:44 +01:00