aboutsummaryrefslogtreecommitdiff
path: root/lib/std/c.zig
AgeCommit message (Collapse)Author
2025-08-30Populate MSG struct for OpenBSD (#25076)Brandon Mercer
* update the MSG struct with the correct values for openbsd * add comment with link to sys/sys/socket.h --------- Co-authored-by: Brandon Mercer <bmercer@eutonian.com>
2025-08-27std.c: add correct SOMAXCONN for BSDsBrandon Black
Note the previous "28" here for openbsd was some kind of copy error long ago. That's the value of KERN.SOMAXCONN, which is an entirely different thing.
2025-08-21Merge pull request #24921 from Justus2308/messy-machAndrew Kelley
std.c.darwin: cleanup, expose everything in std.c
2025-08-20Add mlock syscalls to std.c and std.posixBrandon Black
Linux already gained the relevant syscalls and consts in #24473 The basic mlock() and munlock() are fairly universal across the *nix world with a consistent interface, but are missing on wasi and windows. The mlockall() and munlockall() calls are not as widely supported as the basic ones. Notable non-implementers include darwin, haiku, and serenity (and of course wasi and windows again). mlock2() is Linux-only, as are its MLOCK flags.
2025-08-20std.c.darwin: cleanup, expose everything in std.cJustus Klausecker
This mainly just moves stuff around. Justifications for other changes: * `KEVENT.FLAGS` is backed by `c_uint` because that's what the `kevent64` flags param takes (according to the 'latest' manpage from 2008) * `MACH_RCV_NOTIFY` is a legacy name and `MACH_RCV_OVERWRITE` is deprecated (xnu/osfmk/mach/message.h), so I removed them. They were 0 anyway and thus couldn't be represented as a packed struct field. * `MACH.RCV` and `MACH.SEND` are technically the same 'type' because they can both be supplied at the same time to `mach_msg`. I decided to still keep them separate because naming works out better that way and all flags except for `MACH_MSG_STRICT_REPLY` aren't shared anyway. Both are part of a packed union `mach_msg_option_t` which supplies a helper function to combine the two types. * `PT` is backed by `c_int` because that's what `ptrace` takes as a request arg (according to the latest manpage from 2015)
2025-08-19expose darwin.PT in std.cJustus Klausecker
2025-08-10std.c: Remove serenity's internet_checksum() functionLinus Groh
See: https://github.com/SerenityOS/serenity/commit/59911d8da3da36aefd2d4902a0fdfc21e1f6f8ac
2025-08-07std: fix std.c._msize signatureMeghan Denny
2025-08-05std.c: fix utsname array sizesVeikka Tuominen
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
2025-07-31Merge pull request #24633 from linusg/more-serenity-fixesAndrew Kelley
std: A few more fixes for serenity
2025-07-30add grp.h functions to c.zigChinmay Dalal
2025-07-30std.posix: Default ACCMODE to NONE for serenityLinus Groh
Unlike all other platforms where RDONLY is 0 it does not work as a default for the O flags on serenity - various syscalls other than 'open', e.g. 'pipe', return EINVAL if unexpected bits are set in the flags.
2025-07-30std.c: Fix MAP for serenityLinus Groh
I accidentally translated MAP_ constants representing the type as individual fields. MAP_FILE is for compatibility only and not needed here.
2025-07-30std.c: Fix msghdr_const for serenityLinus Groh
2025-07-24std.c: Fix dirent.name size for serenityLinus Groh
The null terminator is added to the buffer size.
2025-07-21std.fs.File.Reader: fix sendFile logicAndrew Kelley
it wasn't accounting for both writer and reader buffering
2025-07-14std.c: add missing netbsd and freebsd MSG flagsAndrew Kelley
2025-07-14make msghdr.iovlen unsignedAndrew Kelley
I don't care what C headers say. This value is never supposed to be negative.
2025-07-14Add setsid to std.(c|posix)Brandon Black
The interface and errors for this seem to be very universal and generic. Note Linux already has this defined as a syscall as well.
2025-07-07std.c: Use __sigemptyset14 for sigemptyset on NetBSDAlex Rønne Petersen
Closes #24344.
2025-06-24c.darwin: define MSG for macos (#24224)Dacheng
* 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-05std.c: getcontext is not supported on haikuElaine Gibson
2025-06-05std.c.SOCK: define NONBLOCK and CLOEXEC for haikuElaine Gibson
2025-05-29std.c: Expand the definition of NetBSD's pthread_rwlock_t for more targets.Alex Rønne Petersen
2025-05-29std.c: Fix return type for NetBSD's __sigfillset14().Alex Rønne Petersen
2025-05-29std.c: Fix sigrtmin()/sigrtmax() for FreeBSD and NetBSD.Alex Rønne Petersen
They just define the constants in the system headers.
2025-05-22Add EVFILT_USER and friends for OpenBSDEvan Silberman
OpenBSD -current grew EVFILT_USER. See commit message [1] and and current sys/event.h [2] Also EVFILT_DEVICE was missing. Closes #23930 [1]: https://marc.info/?l=openbsd-cvs&m=174686993115485&w=2 [2]: https://codeberg.org/OpenBSD/src/src/branch/master/sys/sys/event.h
2025-05-21libc: implement common `abs` for various integer sizes (#23893)David
* libc: implement common `abs` for various integer sizes * libc: move imaxabs to inttypes.zig and don't use cInclude * libc: delete `fabs` c implementations because already implemented in compiler_rt * libc: export functions depending on the target libc Previously all the functions that were exported were handled equally, though some may exist and some not inside the same file. Moving the checks inside the file allows handling different functions differently * remove empty ifs in inttypes Co-authored-by: Alex Rønne Petersen <alex@alexrp.com> * remove empty ifs in stdlib Co-authored-by: Alex Rønne Petersen <alex@alexrp.com> * libc: use `@abs` for the absolute value calculation --------- Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-05-17std.c: Fill out some missing definitions for supported NetBSD libc targets.Alex Rønne Petersen
This allows ubsan-rt to build.
2025-05-09std.posix: Add sigrtmin() and sigrtmax()Pat Tullmann
For C code the macros SIGRTMIN and SIGRTMAX provide these values. In practice what looks like a constant is actually provided by a libc call. So the Zig implementations are explicitly function calls. glibc (and Musl) export a run-time minimum "real-time" signal number, based on how many signals are reserved for internal implementation details (generally threading). In practice, on Linux, sigrtmin() is 35 on glibc with the older LinuxThread and 34 with the newer NPTL-based implementation. Musl always returns 35. The maximum "real-time" signal number is NSIG - 1 (64 on most Linux kernels, but 128 on MIPS). When not linking a C Library, Zig can report the full range of "rt" signals (none are reserved by Zig). Fixes #21189
2025-04-30c.zig: glibc/musl export 1024-bit sigset_tPat Tullmann
Export the sigset_t ops (sigaddset, etc) from the C library. Don't rely on the linux.zig defintions (which will be defined to use the kernel ABI). Move Darwin sigset and NSIG declarations into darwin.zig. Remove extraneous (?) sigaddset. The C library sigaddset can reject some signals being added, so need to defer to it.
2025-04-26std.c: use arch's ino_t and off_t for direntCarter Snook
Fixes #23622. The integer types used for these fields before would not work on some platforms.
2025-04-07std.os.linux: use heap.pageSize() instead of MMAP2_UNITStefan Weigl-Bosker
2025-03-27std.posix: add getuid()/geteuid()blurrycat
2025-03-25std.c: android bionic C supports arc4random_buf and getentropy孙冰
1. https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/bits/getentropy.h 2. https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/stdlib.h
2025-03-11std.c: fix sysconf names (std.c._SC) for android api孙冰
c.f. https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/include/bits/sysconf.h
2025-03-11std.c: Add definitions for SerenityOSLinus Groh
2025-02-22zig build fmtAndrew Kelley
2025-02-20std.c: define MADV for darwinGabriel Borrelli
2025-02-17std.Target: Remove functions that just wrap component functions.Alex Rønne Petersen
Functions like isMinGW() and isGnuLibC() have a good reason to exist: They look at multiple components of the target. But functions like isWasm(), isDarwin(), isGnu(), etc only exist to save 4-8 characters. I don't think this is a good enough reason to keep them, especially given that: * It's not immediately obvious to a reader whether target.isDarwin() means the same thing as target.os.tag.isDarwin() precisely because isMinGW() and similar functions *do* look at multiple components. * It's not clear where we would draw the line. The logical conclusion before this commit would be to also wrap Arch.isX86(), Os.Tag.isSolarish(), Abi.isOpenHarmony(), etc... this obviously quickly gets out of hand. * It's nice to just have a single correct way of doing something.
2025-02-11std.c: was missing callocMeghan Denny
2025-02-10Merge pull request #22834 from ↵Alex Rønne Petersen
krkk/hi-this-is-my-first-PR-and-heres-my-breaking-change-haha std.c: Improve the description of getnameinfo() arguments: optional pointers and specialized `flags` type
2025-02-09std.c: Fix definition of stack_t on OpenBSDLinus Groh
The size field is not supposed to be signed. See: https://man.openbsd.org/sigaltstack.2
2025-02-09std.c: Use std.c.NI as the flags type in getnameinfoKarol Kosek
std.c.NI was never used in the source, so let's finally use it and make the function more clear! This is a breaking change, although a minor one: If you previously passed 0 here (meaning no flags), then now you have to pass an empty struct (.{}) instead. Otherwise, you probably used @bitCast() shenanigans here (like @bitCast(c.NI { .NUMERICHOST = true }) and that will still work, but you can also get rid of the @bitCast() now!
2025-02-09std.c: Support optional addr and host arguments in getnameinfoKarol Kosek
The POSIX spec allows passing null here https://pubs.opengroup.org/onlinepubs/9799919799/functions/getnameinfo.html
2025-02-09wasi: fix wasm-wasi-musl constantsPat Tullmann
Zig's copy of the `SYMLINK_{NO,}FOLLOW` constants from wasi-musl was wrong, as were the `IFIFO` and `IFSOCK` file type flags. Fix these up, and add comments pointing to exactly where they come from (as the wasi-musl source has lots of unused, different definitions of these constants). Add tests for the Zig convention that WASM preopen 3 is the current working directory. This is true for WASM with or without libc. Enable several fs and posix tests that are now passing (not necessarily because of this change) on wasm targets. Fixes #20890.
2025-02-07Merge pull request #20511 from archbirdplusAndrew Kelley
runtime page size detection rework GeneralPurposeAllocator to reduce active mapping count Allocator VTable API update
2025-02-06std: fix compilation under -lcAndrew Kelley
2025-02-06adjust runtime page size APIsAndrew Kelley
* fix merge conflicts * rename the declarations * reword documentation * extract FixedBufferAllocator to separate file * take advantage of locals * remove the assertion about max alignment in Allocator API, leaving it Allocator implementation defined * fix non-inline function call in start logic The GeneralPurposeAllocator implementation is totally broken because it uses global state but I didn't address that in this commit.