aboutsummaryrefslogtreecommitdiff
path: root/lib/std/c/haiku.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-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-06-05haiku: restore functions mistakenly removed in e8c4e79Elaine Gibson
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-04-08haiku: fix directory iterationJacob Young
2024-03-30cbe: rewrite `CType`Jacob Young
Closes #14904
2024-03-27haiku: fix poll definitionsJacob Young
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-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-31Revert "std: adding sigevent to supported platforms."Andrew Kelley
This reverts commit 23c4f55a612842d8544a9dfe604a9caf1ca39697.
2023-07-31Revert "std.c: add find_path for haiku"Andrew Kelley
This reverts commit 1084590ec4939ed0aba5574eb835a07783301a8c.
2023-07-31Revert "std.fs: selfExePath haiku using constants instead"Andrew Kelley
This reverts commit e21739dd8caf7d6a9aefe68c37eddb6406bcb810.
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 "Merge pull request #15867 from devnexen/haiku_malloc_usable_size"Andrew Kelley
This reverts commit 3ef91233caf2c637797d84527a4e78f870e4b4b9, reversing changes made to 2839e35d1c06ca5b6bda1f20ae870f2b2fbbbfb1.
2023-07-31Revert "std.c: msghdr* struct removing prefixes to match linux."Andrew Kelley
This reverts commit 8f14431bc883898aaf78cc985e2d90716187e882.
2023-07-31Revert "std.c: fix haiku's find_path signature."Andrew Kelley
This reverts commit 9e0ac4449a18677ba695f7a75342cbdb049aad52.
2023-07-01std.c: fix haiku's find_path signature.David Carlier
codePointer and subPath are not mandatory. following up on 1084590
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-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-05-26std.c: haiku also supports malloc_usable_size to benefit zig's heapDavid Carlier
2023-05-25std.Thread: refining stack size from platform minimum, changes more ↵David CARLIER
targetted towards platform like Linux/musl (#15791)
2023-05-09std.fs: selfExePath haiku using constants insteadDavid Carlier
2023-04-24std.c: add find_path for haikuDavid Carlier
2023-04-23std: adding sigevent to supported platforms.David CARLIER
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-04std.os: fix alignment of Sigaction.handler_fnRyan Schneider
Fixes #13216
2022-10-29fs: Some NAME_MAX/MAX_NAME_BYTES improvementsRyan Liptak
2022-10-29std.fs: Add MAX_NAME_BYTESRyan Liptak
Also add some NAME_MAX or equivalent definitions where necessary
2022-09-29std: Replace use of stage1 function pointersominitay
2022-08-18AstGen: disallow leading zeroes in int literals and int typeszooster
This makes `0123` and `u0123` etc. illegal. I'm now confident that this is a good change because I actually caught two C header translation mistakes in `haiku.zig` with this. Clearly, `0123` being octal in C (TIL) can cause confusion, and we make this easier to read by requiring `0o` as the prefix and now also disallowing leading zeroes in integers. For consistency and because it looks weird, we disallow it for integer types too (e.g. `u0123`). Fixes #11963 Fixes #12417
2022-07-11Sema: allow `void` as an extern union field & fix invalid extern unionsVeikka Tuominen
2022-07-04std: update bsd bits to new fn ptr semanticsAndrew Kelley
2022-02-26add constant for haikuAl Hoang
* re-enable zig build on haiku
2022-02-15Adds Linux support for POSIX file locking with fcntlAnthony Carrico
On Linux, locking fails with EAGAIN (vs. EACCES on other systems). This commit also adds FcntlErrors for EDEADLK and ENOLCK.
2022-02-13std.c.haiku: move Stat.crtime to Stat.birthtimeominitay
2021-12-19stage1, stage2: rename c_void to anyopaque (#10316)Isaac Freund
zig fmt now replaces c_void with anyopaque to make updating code easy.
2021-11-19haiku follow up cleanup of constantsAl Hoang
2021-11-15haiku constants cleanup and updateAl Hoang
2021-11-15update mmap flags, use definesAl Hoang
2021-11-15ensure zig fmtAl Hoang
2021-11-15updates for haiku stdcAl Hoang
* add team_info, area_info * update signature for get_next_image_info * add error checks for haiku system calls * update and cleanup of haiku constants
2021-09-16Set the Storage socket sizes to be system definedStephen Gregoratto
Some systems (Solaris, OpenBSD, AIX) change their definitions of sockaddr_storage to be larger than 128 bytes. This comment adds a new constant in the `sockaddr` that defines the size for every system. Fixes #9759