aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/linux
AgeCommit message (Collapse)Author
2025-10-30Merge pull request #25763 from mrjbq7/cancelledJohn Benediktsson
rename Cancelled to Canceled
2025-10-29Merge pull request #25592 from ziglang/init-std.IoAndrew Kelley
std: Introduce `Io` Interface
2025-10-29std.os.linux: fix restore for powerpc/powerpc64Alex Rønne Petersen
sigreturn and rt_sigreturn are distinct syscalls on PowerPC.
2025-10-29std.os.linux.IoUring: disable failing testAndrew Kelley
tracked by https://github.com/ziglang/zig/issues/25734
2025-10-29std.os.linux.s390x: fix restore functionAndrew Kelley
2025-10-29std.os.linux.x86: fix signal restore functionAndrew Kelley
After handling any signal on x86, it would previously segfault.
2025-10-29std: make signal numbers into an enumAndrew Kelley
fixes start logic for checking whether IO/POLL exist
2025-10-29std.os.linux.IoUring: use linux msghdrAndrew Kelley
it disagrees with posix msghdr
2025-10-29std: fix some Io compilation errorsAndrew Kelley
2025-10-29std: updating to std.Io interfaceAndrew Kelley
got the build runner compiling
2025-10-23std.os.linux.tls: add hppa supportAlex Rønne Petersen
Turns out Linux on PA-RISC does system calls in a pretty fascinating way; see arch/parisc/kernel/syscall.S for details.
2025-10-23std.os.linux.tls: add sh supportAlex Rønne Petersen
2025-10-23std.os.linux.tls: add microblaze supportAlex Rønne Petersen
Implemented according to glibc because I'm pretty sure musl gets it wrong.
2025-10-23std.os.linux.tls: add alpha supportAlex Rønne Petersen
2025-10-23std.Target: add arceb and xtensaeb Cpu.Arch tagsAlex Rønne Petersen
2025-10-18std.os.linux: add or1k arch bitsAlex Rønne Petersen
2025-10-18std.os.linux.tls: implement or1k supportAlex Rønne Petersen
2025-10-18std.os.linux: remove syscall7() on mips64/mipsn32Alex Rønne Petersen
I'm not sure why this was here, but this is only a thing on O32, not N32/N64.
2025-10-18std.os.linux: fix some issues in x32 inline asmAlex Rønne Petersen
ref https://github.com/ziglang/zig/issues/22189
2025-10-18std.os.linux: fix some issues in mipsn32 inline asmAlex Rønne Petersen
ref https://github.com/ziglang/zig/issues/22189
2025-10-18std: make all MIPS inline asm safe for MIPS IAlex Rønne Petersen
MIPS I has load hazards so we need to insert nops in a few places. This is not a problem for MIPS II and later. While doing this, I also touched up all the inline asm to use ABI register aliases and a consistent formatting convention. Also fixed a few places that didn't properly check if the syscall return value should be negated.
2025-10-17Merge pull request #25610 from alexrp/std-os-linux-cleanupAlex Rønne Petersen
`std.os.linux`: some miscellaneous cleanup in arch bits
2025-10-17std.os.linux.tls: don't unnecessarily use std.posixAlex Rønne Petersen
2025-10-17std.os.linux: add incomplete x32 arch bits fileAlex Rønne Petersen
This is very likely full of wrong stuff. It's effectively just a copy of the x86_64 file - needed because the former stopped using usize/isize. To be clear, this is no more broken than the old situation was; this just makes the brokenness explicit.
2025-10-17std.os.linux: add incomplete mipsn32 arch bits fileAlex Rønne Petersen
This is very likely full of wrong stuff. It's effectively just a copy of the mips64 file - needed because the former stopped using usize/isize. To be clear, this is no more broken than the old situation was; this just makes the brokenness explicit.
2025-10-17std.os.linux: clean up a bunch of dead constsAlex Rønne Petersen
2025-10-17std.os.linux: retranslate F_* constants and Flock struct, and move out of ↵Alex Rønne Petersen
arch bits Flock is now equivalent to struct flock64, and the related F.* constants map to the 64-bit variants on 32-bit systems.
2025-10-17std.os.linux: replace usize/isize in arch bits with fixed types for clarityAlex Rønne Petersen
2025-10-17std.os.linux: move some generic decls out of the arch bitsAlex Rønne Petersen
2025-10-16std.os.linux.thumb: remove some @setRuntimeSafety(false) with no clear purposeAlex Rønne Petersen
2025-10-16std.os.linux: remove some pointless asm clobbers in naked fnsAlex Rønne Petersen
2025-10-16std.os.linux: fix a bunch of syscall and time ABI issues on hexagonAlex Rønne Petersen
I'm not particularly happy with sprinkling this check everywhere, but the situation should improve once we complete the time64 migration.
2025-10-14std.os.linux.sparc64: use icc instead of xcc in asm clobbersAlex Rønne Petersen
LLVM currently doesn't recognize xcc; icc does what we want.
2025-10-10std: stop exposing anything having to do with ucontext_tAlex Rønne Petersen
This type is useful for two things: * Doing non-local control flow with ucontext.h functions. * Inspecting machine state in a signal handler. The first use case is not one we support; we no longer expose bindings to those functions in the standard library. They're also deprecated in POSIX and, as a result, not available in musl. The second use case is valid, but is very poorly served by the standard library. As evidenced by my changes to std.debug.cpu_context.signal_context_t, users will be better served rolling their own ucontext_t and especially mcontext_t types which fit their specific situation. Further, these types tend to evolve frequently as architectures evolve, and the standard library has not done a good job keeping up, or even providing them for all supported targets.
2025-10-09std.os.linux: remove dead/wrong msghdr definitions in some arch bitsAlex Rønne Petersen
2025-10-07std.os.linux: add ucontext_t and mcontext_t for mips/mips64Alex Rønne Petersen
2025-10-07std.os.linux: minor NFC corrections to hexagon ucontext_t and mcontext_tAlex Rønne Petersen
2025-10-05std.os.linux: add mcontext_t and ucontext_t for hexagonAlex Rønne Petersen
2025-10-03std.os.linux: improve the s390x mcontext_t definitionAlex Rønne Petersen
The old one was correct in terms of layout but very user-hostile.
2025-09-30std: rework/remove ucontext_tmlugg
Our usage of `ucontext_t` in the standard library was kind of problematic. We unnecessarily mimiced libc-specific structures, and our `getcontext` implementation was overkill for our use case of stack tracing. This commit introduces a new namespace, `std.debug.cpu_context`, which contains "context" types for various architectures (currently x86, x86_64, ARM, and AARCH64) containing the general-purpose CPU registers; the ones needed in practice for stack unwinding. Each implementation has a function `current` which populates the structure using inline assembly. The structure is user-overrideable, though that should only be necessary if the standard library does not have an implementation for the *architecture*: that is to say, none of this is OS-dependent. Of course, in POSIX signal handlers, we get a `ucontext_t` from the kernel. The function `std.debug.cpu_context.fromPosixSignalContext` converts this to a `std.debug.cpu_context.Native` with a big ol' target switch. This functionality is not exposed from `std.c` or `std.posix`, and neither are `ucontext_t`, `mcontext_t`, or `getcontext`. The rationale is that these types and functions do not conform to a specific ABI, and in fact tend to get updated over time based on CPU features and extensions; in addition, different libcs use different structures which are "partially compatible" with the kernel structure. Overall, it's a mess, but all we need is the kernel context, so we can just define a kernel-compatible structure as long as we don't claim C compatibility by putting it in `std.c` or `std.posix`. This change resulted in a few nice `std.debug` simplifications, but nothing too noteworthy. However, the main benefit of this change is that DWARF unwinding---sometimes necessary for collecting stack traces reliably---now requires far less target-specific integration. Also fix a bug I noticed in `PageAllocator` (I found this due to a bug in my distro's QEMU distribution; thanks, broken QEMU patch!) and I think a couple of minor bugs in `std.debug`. Resolves: #23801 Resolves: #23802
2025-09-30std: fix os.linux.x86.syscall6mlugg
It was possible for `arg6` to be passed as an operand relative to esp. In that case, the `push` at the top clobbered esp and hence made the reference to arg6 invalid. This was manifesting in this branch as broken stack traces on x86-linux due to an `mmap2` syscall accidentally passing the page offset as non-zero! This commit fixes a bug introduced in cb0e6d8aa.
2025-09-28std.os.linux: delete restore and restore_rt for hexagon, loongarch, mips, riscvAlex Rønne Petersen
2025-09-23Don't specify clobbers in `restore_rt`taylor.fish
Per @alexrp, this is unnecessary in naked functions.
2025-09-23Fix PowerPC `restore_rt`taylor.fish
Clang fails to compile the CBE translation of this code ("non-ASM statement in naked function"). Similar to the implementations of `restore_rt` on x86 and ARM, when the CBE is in use, this commit employs alternative inline assembly that avoids using non-immediate input operands.
2025-09-24Fix PowerPC syscalls causing invalid code from CBEtaylor.fish
Fixes #25209. On PowerPC, some registers are both inputs to syscalls and clobbered by them. An example is r0, which initially contains the syscall number, but may be overwritten during execution of the syscall. musl and glibc use a `+` (read-write) constraint to indicate this, which isn't supported in Zig. The current implementation of PowerPC syscalls in the Zig standard library instead lists these registers as both inputs and clobbers, but this results in the C backend generating code that is invalid for at least some C compilers, like GCC, which doesn't support the specifying the same register as both an input and a clobber. This PR changes the PowerPC syscall functions to list such registers as inputs and outputs rather than inputs and clobbers. Thanks to jacobly0 who pointed out that it's possible to have multiple outputs; I had gotten the wrong idea from the documentation.
2025-09-15bpf: use bitCast instead of intCast in ld_imm_implGeorge Huebner
Any 32 bit immediate is allowed in a BPF instruction, including those greater than the largest positive i32 value.
2025-08-28std.os.linux: powerpc syscalls clobber ctr and xerAlex Rønne Petersen
https://git.musl-libc.org/cgit/musl/commit/?id=f6944eb3c4ce1c97dc39dc36d32390dc9f70b67b
2025-08-16implement registering NAPI on IoUring (#24850)Özgür Akkurt
2025-08-14Linux: Update syscall list for 6.16Stephen Gregoratto
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-06linux/mips.zig: Use `i32` for stat nsec fieldsPat Tullmann
The `atime()`, etc wrappers here expect to create a `std.linux.timespec` (defined in `linux.zig` to have `isize` fields), so the u32 causes errors: error: expected type 'isize', found 'u32' .nsec = self.atim_nsec, Make the nsec fields signed for consistency with all the other structs, with and with `std.linux.timespec`. Also looks like the comment on `__pad1` was copied from `__pad0`, but it only applies to `__pad0`.