aboutsummaryrefslogtreecommitdiff
path: root/lib/std/c/openbsd.zig
AgeCommit message (Collapse)Author
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-17Merge pull request #25195 from blblack/netdefsAndrew Kelley
std: Add several sockopt-related constants and structs
2025-09-13std.posix.ptrace: support more platforms more correctlyJustus Klausecker
2025-09-09std: add IP, IPV6, IPTOS sockopt constantsBrandon Black
Because these lists are very long in several cases and quite varied, I opted to place them in the existing c/foo.zig files. There are many other sets of network-related constants like this to add over time across all the OSes. For now I picked these because I needed a few constants from each of these namespaces for my own project, so I tried to flesh out these namespaces completely as best I could, at least for basic sockopt purposes. Note windows has some of these already defined in ws2_32 as individual constants rather than contained in a namespacing struct. I'm not sure what to do with that in the long run (break it and namespace them?), but this doesn't change the status quo for windows in any case.
2025-08-01enable pwd.h functions for other OSesChinmay Dalal
also add the layout of `struct passwd` for DragonflyBSD and FreeBSD: - https://github.com/DragonFlyBSD/DragonFlyBSD/blob/c267aac0072dae6cf4ae874605f3f0659a2fc820/include/pwd.h#L112 - https://cgit.freebsd.org/src/tree/include/pwd.h?id=d66f9c86fa3fd8d8f0a56ea96b03ca11f2fac1fb#n114
2024-07-19std.c reorganizationAndrew Kelley
It is now composed of these main sections: * Declarations that are shared among all operating systems. * Declarations that have the same name, but different type signatures depending on the operating system. Often multiple operating systems share the same type signatures however. * Declarations that are specific to a single operating system. - These are imported one per line so you can see where they come from, protected by a comptime block to prevent accessing the wrong one. Closes #19352 by changing the convention to making types `void` and functions `{}`, so that it becomes possible to update `@hasDecl` sites to use `@TypeOf(f) != void` or `T != void`. Happily, this ended up removing some duplicate logic and update some bitrotted feature detection checks. A handful of types have been modified to gain namespacing and type safety. This is a breaking change. Oh, and the last usage of `usingnamespace` site is eliminated.
2024-03-30cbe: rewrite `CType`Jacob Young
Closes #14904
2024-03-23haiku: debitrotJacob Young
2024-03-19extract std.posix from std.osAndrew Kelley
closes #5019
2024-03-17AstGen: disallow alignment on function typesJacob Young
A pointer type already has an alignment, so this information does not need to be duplicated on the function type. This already has precedence with addrspace which is already disallowed on function types for this reason. Also fixes `@TypeOf(&func)` to have the correct addrspace and alignment.
2024-03-14bsd: add missing os.IFNAMESIZEMichael Dusan
- based on system API value IF_NAMESIZE - unblocks `zig test lib/std/std.zig`
2024-03-08std.c.openbsd: remove nop `usingnamespace`mlugg
I have no idea why this was even here... Eliminates one more usage of `usingnamespace` from the standard library. 5 remain.
2024-02-15std.os.termios: add/fix std.c.TCSA for BSDsMichael Dusan
2024-02-14bsd: debitrot type-safe std.c.OMichael Dusan
Minor changes as per 7680c5330cb mostly about pipe2() flags. closes #18927
2024-02-12std.os.speed_t: add type safetyAndrew Kelley
and collect the missing flag bits from all the operating systems.
2024-02-12std.os.termios: add type safety to cflag fieldAndrew Kelley
This creates `tc_cflag_t` even though such a type is not defined by libc. I also collected the missing flag bits from all the operating systems.
2024-02-12std.os.termios: add type safety to oflag fieldAndrew Kelley
This creates `tc_oflag_t` even though such a type is not defined by libc. I also collected the missing flag bits from all the operating systems.
2024-02-12std.os.termios: add type safety to iflag fieldAndrew Kelley
This creates `tc_iflag_t` even though such a type is not defined by libc. I also collected the missing flag bits from all the operating systems.
2024-02-12std.os.termios: consolidate and correctAndrew Kelley
2024-02-12std.c.NCSS: consolidate and correctAndrew Kelley
2024-02-12std: add type safety to cc_tAndrew Kelley
2024-02-11some API work on std.c, std.os, std.os.wasiAndrew Kelley
* std.c: consolidate some definitions, making them share code. For example, freebsd, dragonfly, and openbsd can all share the same `pthread_mutex_t` definition. * add type safety to std.c.O - this caught a bug where mode flags were incorrectly passed as the open flags. * 3 fewer uses of usingnamespace keyword * as per convention, remove purposeless field prefixes from struct field names even if they have those prefixes in the corresponding C code. * fix incorrect wasi libc Stat definition * remove C definitions from incorrectly being in std.os.wasi * make std.os.wasi definitions type safe * go through wasi native APIs even when linking libc because the libc APIs are problematic and wasteful * don't expose WASI definitions in std.posix * remove std.os.wasi.rights_t.ALL: this is a footgun. should it be all future rights too? or only all current rights known? both are the wrong answer.
2024-02-06std.c.MAP: use a packed structAndrew Kelley
Same as previous commit, but for the libc interface.
2023-07-31std.c.openbsd: remove "msg_" prefixes from structsAndrew Kelley
Reapplies 8f14431bc883898aaf78cc985e2d90716187e882 which was reverted in 95e2605d30c15963c4d6bc9e39751031b0f52007.
2023-07-31std.c.openbsd: add PTHREAD_STACK_MINAndrew Kelley
@semarie audited this definition.
2023-07-31std.c.openbsd: add ucontext_t for aarch64Andrew Kelley
Reapplies 1585ed637d101ed16adb6b9ebdfa465299bfdb13 which was reverted in f3adbe249b0dfad91318916142a33619232a968f. I removed use of `usingnamespace` in this commit. @semarie audited this struct definition.
2023-07-31Revert "std.c: openbsd sigcontext/ucontext for arm64."Andrew Kelley
This reverts commit 1585ed637d101ed16adb6b9ebdfa465299bfdb13.
2023-07-31Revert "std.Thread: refining stack size from platform minimum, changes more ↵Andrew Kelley
targetted towards platform like Linux/musl (#15791)" This reverts commit 41502c6aa53a3da31b276c23c4db74db7d04796b.
2023-07-31Revert "std.c: update netbsd/openbsd mman constants"Andrew Kelley
This reverts commit 64f0059cd33b571d6cf91df45f4cb2e0af9c0742.
2023-07-31Revert "std.c: msghdr* struct removing prefixes to match linux."Andrew Kelley
This reverts commit 8f14431bc883898aaf78cc985e2d90716187e882.
2023-07-01std.c: msghdr* struct removing prefixes to match linux.David CARLIER
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-22std.c: update netbsd/openbsd mman constantsDavid CARLIER
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-15openbsd: fix std.c.getdents and debitrotMichael Dusan
- fix getdents return type usize → c_int - special-case process.zig to use sysctl instead of sysctlbyname - use struct/field pattern for sysctl HW_* constants
2023-05-25std.Thread: refining stack size from platform minimum, changes more ↵David CARLIER
targetted towards platform like Linux/musl (#15791)
2023-05-22std.c: openbsd sigcontext/ucontext fix enumMichael Dusan
2023-05-09std.c: openbsd sigcontext/ucontext for arm64.David Carlier
2023-01-03Merge pull request #13980 from ziglang/std.netAndrew Kelley
networking: delete std.x; add std.crypto.tls and std.http.Client
2023-01-02std.fs: add NAME_MAX for openbsd and netbsdMichael Dusan
2023-01-02remove the experimental std.x namespaceAndrew Kelley
Playtime is over. I'm working on networking now.
2022-12-06remove most conditional compilation based on stage1Andrew Kelley
There are still a few occurrences of "stage1" in the standard library and self-hosted compiler source, however, these instances need a bit more careful inspection to ensure no breakage.
2022-11-09Merge pull request #13418 from ryanschneider/signal-alignment-13216Veikka Tuominen
std.os: fix alignment of Sigaction.handler_fn
2022-11-04std.os: fix alignment of Sigaction.handler_fnRyan Schneider
Fixes #13216
2022-11-04all: rename i386 to x86Ali Chraghi
2022-09-29std: Replace use of stage1 function pointersominitay
2022-08-26openbsd: fix sigcontext struct and avoid defining fxsave64Sébastien Marie
`sc_fpstate` member of `struct sigcontext` is a `struct fxsave64 *`. use *anyopaque to represent it. avoid to defining `fxsave64` as it is a packed struct with some arrays.
2022-08-11std: fix definition of SIG_IGN, SIG_DFL, etc.Isaac Freund
POSIX specifies that the sa_handler field of the sigaction struct may be set to SIG_IGN or SIG_DFL. However, the current constants in the standard library use the function pointer signature corresponding to the sa_sigaction field instead. This may not cause issues in practice because the fields usually occupy the same memory in a union, but this isn't required by POSIX and there may be systems we do not yet support that do this differently. Fixing this also makes the Zig interface less confusing to use after reading the man page.
2022-07-04std: update bsd bits to new fn ptr semanticsAndrew Kelley
2022-06-07add const to msghdr_const iov and control pointersJonathan Marler
alongside the typical msghdr struct, Zig has added a msghdr_const type that can be used with sendmsg which allows const data to be provided. I believe that data pointed to by the iov and control fields in msghdr are also left unmodified, in which case they can be marked const as well.