Commit Graph

36223 Commits

Author SHA1 Message Date
Andrew Kelley 3204fb7569 update all occurrences of std.fs.File to std.Io.File 2025-12-23 22:15:07 -08:00
Andrew Kelley 1b1fb7fab6 std.crypo.tls: delete unused import 2025-12-23 22:15:07 -08:00
Andrew Kelley aafddc2ea1 update all occurrences of close() to close(io) 2025-12-23 22:15:07 -08:00
Andrew Kelley eab354b2f5 std.Io.Threaded: import File and Dir 2025-12-23 22:15:07 -08:00
Andrew Kelley 72b76077ab std: fix some surface level compilation errors
And boldly remove preadv, pwritev, readv, writev, pread, pwrite from
std.posix.
2025-12-23 22:15:07 -08:00
Andrew Kelley ba999d608c std: extract sendfile/copy_file_range from Io.File.Writer
and move it into std.Io.Threaded (below the VTable)
2025-12-23 22:15:07 -08:00
Andrew Kelley 814480db7c std: all File functions moved to std.Io 2025-12-23 22:15:07 -08:00
Andrew Kelley d1d2c37af2 std: all Dir functions moved to std.Io 2025-12-23 22:15:07 -08:00
Andrew Kelley 81214278ca std.Io.Threaded: implement dirStat 2025-12-23 22:15:07 -08:00
Andrew Kelley 89bda60d28 std.Io.Threaded: implement makePath 2025-12-23 22:15:07 -08:00
Stephen Gregoratto c3f2de5e51 Linux: Update syscall list for 6.17
The 6.17 kernel added[1] syscalls for getting/setting certain file flags
and attributes. It's meant to be a more extensible replacement for these
ioctl's:

- `FS_IOC_GETFLAGS`/`FS_IOC_SETFLAGS`.
- `FS_IOC_FSGETXATTR`/`FS_IOC_FSSETXATTR`.

The definitions of these calls are as follows:

```zig
const file_attr = extern struct {
    /// Extended flags that apply to this file. (get/set).
    xflags: u64,
    /// Preferred extent allocation size, in bytes. (get/set).
    extsize: u32,
    /// One of:
    /// - The number of data extents in this file.
    /// - If `FS_IOC_FSGETXATTRA` is set, the number of extended attribute events in the file.
    /// (get)
    nextents: u32,
    /// Project Identifier (get/set).
    projid: u32,
    /// Preferred extent allocation size for CoW operations, in bytes (get/set).
    cowextsize: u32,
};

// size=@sizeOf(file_attr)
fn file_getattr(dirfd: fd_t, path: [*:0], fattr: *file_attr, size: usize, at_flags: u32) {}
fn file_setattr(dirfd: fd_t, path: [*:0], fattr: *file_attr, size: usize, at_flags: u32) {}
```

Users need to set/check `xflags` with the `FS_XFLAG` flags defined in
`linux/fs.h`. `ioctl_xfs_fsgetxattr(2)` has more information about the
type of information one can retrieve.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=57fcb7d930d8f00f383e995aeebdcd2b416a187a
2025-12-24 13:10:38 +11:00
Andrew Kelley 985a3565c6 Merge pull request 'Replace uses of std.Thread.Pool with std.Io, and remove std.Thread.Pool' (#30557) from compiler-std.Io into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30557
Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org>
2025-12-22 20:09:34 +01:00
Mason Remaley 3af842f0e8 Fixes enums.fromInt failing at compile time on in range but invalid values 2025-12-22 14:19:18 +01:00
pyk b346090ed2 add PERF_EVENT_IOC_ID
The value is derived from the following:

```
std.os.linux.IOCTL.IOR('$', 7, u64);
```

Signed-off-by: pyk <pyk@noreply.codeberg.org>
2025-12-22 14:16:06 +01:00
Matthew Lugg 23e5a17187 std: delete Thread.Pool in favour of Io 2025-12-22 12:55:16 +00:00
Matthew Lugg 18bc7e802f compiler: replace thread pool with std.Io
Eliminate the `std.Thread.Pool` used in the compiler for concurrency and
asynchrony, in favour of the new `std.Io.async` and `std.Io.concurrent`
primitives.

This removes the last usage of `std.Thread.Pool` in the Zig repository.
2025-12-22 12:55:16 +00:00
Matthew Lugg 9ae4e38ca2 tools: replace thread pool with std.Io 2025-12-22 12:47:38 +00:00
Matthew Lugg 2046e0f4be std.Io.Threaded: fix group closure leak
More tasks could be added to the group at any time before it completes,
so it's not valid to look at the `token` passed in here.

There's also a related bug in `Threaded`, which is that tasks spawned in
a group after it is canceled will not observe that cancelation, but that
is a more complex bug which needs some deeper design changes.
2025-12-22 12:47:38 +00:00
Matthew Lugg 4772f1a9f4 std.Io: make it safe to call Group.async within a group task 2025-12-22 11:54:57 +00:00
Matthew Lugg 49f17237b0 compiler,std: remove a handful of redundant discards
I'm embarrassed to say I didn't realise until a few days ago that you
could omit the `_` capture for `if`/`while` on `E!void`...
2025-12-22 11:54:57 +00:00
Alex Rønne Petersen aa0249d74e Merge pull request 'std.ascii: rename indexOf functions to find' (#30101) from adria/zig:indexof-find into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30101
Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org>
Reviewed-by: mlugg <mlugg@noreply.codeberg.org>
2025-12-22 12:50:46 +01:00
Doug Coleman 6b9125cbe6 build_runner: fix race condition in dispatch_deps capacity reservation
Move ensureUnusedCapacity inside the mutex call to prevent
a race condition where other worker threads could append to
memory_blocked_steps between checking the length and iterating.

repro branch: https://codeberg.org/erg/zig/src/branch/fix-30014-repro
check out that branch, and depending on if you have the fix-30014 patch or not,
it will either race condition or succeed

Fixes #30014
2025-12-21 20:11:05 -06:00
mlugg 8c5f731afb Merge pull request 'Some std.Io goodies' (#30235) from std.Io-misc into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30235
Reviewed-by: Andrew Kelley <andrewrk@noreply.codeberg.org>
2025-12-21 14:50:58 +01:00
Matthew Lugg 67eed99550 std.Io.Queue: introduce closure and fix a bug
Queues can now be "closed". A closed queue cannot have more elements
appended with `put`, and blocked calls to `put` will immediately unblock
having failed to append some elements. Calls to `get` will continue to
succeed as long as the queue buffer is non-empty, but will then never
block; already-blocked calls to `get` will unblock.

All queue get/put operations can now return `error.Closed` to indicate
that the queue has been closed. For bulk get/put operations, they may
add/receive fewer elements than the minimum requested *if* the queue was
closed or the calling task was canceled. In that case, if any elements
were already added/received, they are returned first, and successive
calls will return `error.Closed` or `error.Canceled`.

Also, fix a bug where `Queue.get` could deadlock because it incorrectly
blocked until the given buffer was *filled*.

Resolves: #30141
2025-12-21 13:07:04 +00:00
Matthew Lugg fa7e818e14 std.Io: add new cancelation APIs
Also, better document how cancelation actually works.
2025-12-21 13:07:04 +00:00
Matthew Lugg 9bf65f6e05 std.Io.Threaded: replace ResetEvent with Io.Event 2025-12-21 13:07:04 +00:00
Matthew Lugg 0649f96da3 std.Io: introduce Event implemented using futex 2025-12-21 13:07:03 +00:00
Matthew Lugg b4ee54b580 std.Io: reimplement Mutex and Condition atop futex
This work was partially cherry-picked from Andrew's WIP std.fs branch.
However, I also analyzed and simplified the Mutex and Condition
implementations, and brought them in line with modern Zig style.

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2025-12-21 13:07:03 +00:00
Matthew Lugg 6ed5b62050 std.Io: introduce futex primitives
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2025-12-21 13:07:03 +00:00
Matthew Lugg 330e295bc4 mailmap: add some addresses used by the Codeberg UI 2025-12-21 13:07:03 +00:00
Matthew Lugg 5611779f39 Sema: fix nested error union coercions
Previously, `E1!void` failed to coerce to `E2!E1!void` because it tried
to coerce the `E1` error to an `E2` if comptime-known and refused to
attempt any other coercion. This is a strange language rule with no
clear justification, and breaks real use cases (such as calling `getOne`
on an `Io.Queue(E!T)`). Instead, only error *sets* should try to coerce
to an "error" value of an error union type.
2025-12-21 13:07:03 +00:00
Matthew Lugg 3f08073f7d x86_64: hack around more OPV bugs
I would just fix this in Sema if it were easy to do so, but this is more
like a (minor) AIR data design issue than a straightforward Sema bug.
2025-12-21 13:07:00 +00:00
Alex Rønne Petersen b27bdd5af0 libc: add back freebsd bsm headers
Accidentally removed in #30135.
2025-12-21 03:54:17 +01:00
Prokop Randáček 442592855c change placeholder pattern in deduplicated type errors 2025-12-20 08:06:59 +01:00
Andrew Kelley 5fa7f13082 Merge pull request 'Windows: Avoid ever-expanding DeviceIoControl error set, handle NOT_A_REPARSE_POINT in ReadLink' (#30186) from squeek502/zig:win-deviceiocontrol into master
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30186
2025-12-19 18:50:27 +01:00
Alex Rønne Petersen f9419c81cf build: bump test-c-abi max_rss to 2_389_779_251 on x86_64-linux 2025-12-18 13:01:35 +01:00
Alex Rønne Petersen a6c22c5edb std.os.linux.test: disable fallocate on mips64*-linux-*abin32
https://codeberg.org/ziglang/zig/issues/30220
2025-12-18 12:56:28 +01:00
Alex Rønne Petersen 6b77bb3f91 build: bump test-compiler-rt max_rss to 978_463_129 on x86_64-linux 2025-12-18 11:42:42 +01:00
Alex Rønne Petersen 0437decca9 std.http.test: disable redirect to different connection on mips*-linux w/o libc
https://codeberg.org/ziglang/zig/issues/30216
2025-12-18 01:46:31 +01:00
Mick Sayson fc78a61c4c Prevent register clobbering on x86_64 threadlocal access
On the x86_64 self hosted backend, thread locals are accessed through
__tls_get_addr on PIC. Usually this goes through a fast path which does
not lose any registers, however in some cases (notably any dlopened
library on my machine) this can take a slow path which calls out to C
ABI functions

Catch this case and backup registers as necessary

Fix a few other ones while we're here. Credit to mlugg

Fixes #30183
2025-12-17 15:33:10 +01:00
Alex Rønne Petersen b9eefe17af test: fix up c3ee8078b4
Oops, accidentally didn't run the tests for 32-bit powerpc.
2025-12-16 09:01:51 +01:00
Alex Rønne Petersen 00903d35b1 std.Target: openbsd's landisk port is only little endian 2025-12-16 06:27:25 +01:00
Alex Rønne Petersen 447d6a0dd3 test: remove some nonsensical openbsd targets from llvm_targets 2025-12-16 06:25:32 +01:00
Alex Rønne Petersen b675223eb5 std: disable tests that depend on getFdPath on openbsd 2025-12-16 06:25:27 +01:00
Alex Rønne Petersen 215b250e6b std.posix.test: fix sigset tests on openbsd (no rt signals) 2025-12-16 06:25:21 +01:00
Alex Rønne Petersen da9733d441 compiler-rt: implement __clear_cache() for arm/mips64-openbsd 2025-12-16 06:25:15 +01:00
Alex Rønne Petersen 914005105e std.fs: fix build error in selfExePath() on openbsd 2025-12-16 06:25:10 +01:00
Alex Rønne Petersen 707e389f38 std.Io.Threaded: apply netbsd todo hacks to openbsd
https://codeberg.org/ziglang/zig/issues/30063
2025-12-16 06:25:07 +01:00
Alex Rønne Petersen 18db762bb8 std.c: openbsd does not have SIGRTMIN/SIGRTMAX 2025-12-16 06:24:58 +01:00
Alex Rønne Petersen 56add8374c std.c: remove comptime asserts of siginfo_t size
These serve no purpose other than to verify that the compiler is doing layout
correctly, and this is clearly not the place for that.
2025-12-16 06:24:54 +01:00