Commit graph

271 commits

Author SHA1 Message Date
Alex Rønne Petersen
71fd5ac38a
std.c: Fix return type for NetBSD's __sigfillset14(). 2025-05-29 16:48:28 +02:00
Alex Rønne Petersen
309ac27d35
std.c: Fix sigrtmin()/sigrtmax() for FreeBSD and NetBSD.
They just define the constants in the system headers.
2025-05-29 16:48:28 +02:00
Evan Silberman
931c6f90f5 Add EVFILT_USER and friends for OpenBSD
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-22 04:37:57 +02:00
David
55848363fd
libc: implement common abs for various integer sizes (#23893)
* 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-21 00:57:38 +02:00
Alex Rønne Petersen
9af8e7c68e
std.c: Fill out some missing definitions for supported NetBSD libc targets.
This allows ubsan-rt to build.
2025-05-17 04:41:26 +02:00
Pat Tullmann
6eb5e56306 std.posix: Add sigrtmin() and sigrtmax()
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-05-09 15:10:25 +02:00
Pat Tullmann
51654aea87 c.zig: glibc/musl export 1024-bit sigset_t
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-30 20:32:04 -07:00
Carter Snook
573d9aab5e std.c: use arch's ino_t and off_t for dirent
Fixes #23622. The integer types used for these fields before would not
work on some platforms.
2025-04-26 14:55:59 +02:00
Stefan Weigl-Bosker
bcb4ba9afd
std.os.linux: use heap.pageSize() instead of MMAP2_UNIT 2025-04-07 13:37:01 +02:00
blurrycat
fb188c3d18
std.posix: add getuid()/geteuid() 2025-03-27 07:58:27 +00:00
孙冰
fbbdde41b4 std.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-25 13:17:45 +01:00
孙冰
77395457fe std.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-11 21:41:58 +01:00
Linus Groh
79a0de2a2f std.c: Add definitions for SerenityOS 2025-03-11 14:59:29 +00:00
Andrew Kelley
eb3c7f5706 zig build fmt 2025-02-22 17:09:20 -08:00
Gabriel Borrelli
8e293ea8bd std.c: define MADV for darwin 2025-02-20 20:42:24 +01:00
Alex Rønne Petersen
481b7bf3f0
std.Target: Remove functions that just wrap component functions.
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-17 19:18:19 +01:00
Meghan Denny
b2b830e0e9 std.c: was missing calloc 2025-02-11 17:21:07 -08:00
Alex Rønne Petersen
d4c85079c5
Merge pull request #22834 from 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-10 10:44:21 +01:00
Linus Groh
75df7e502c std.c: Fix definition of stack_t on OpenBSD
The size field is not supposed to be signed.
See: https://man.openbsd.org/sigaltstack.2
2025-02-09 22:17:35 +01:00
Karol Kosek
2ccfb1dafd std.c: Use std.c.NI as the flags type in getnameinfo
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-09 16:40:21 +01:00
Karol Kosek
18ffd48b60 std.c: Support optional addr and host arguments in getnameinfo
The POSIX spec allows passing null here
https://pubs.opengroup.org/onlinepubs/9799919799/functions/getnameinfo.html
2025-02-09 16:06:38 +01:00
Pat Tullmann
138d30bb47 wasi: fix wasm-wasi-musl constants
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-09 09:08:11 +01:00
Andrew Kelley
6a6e72fff8
Merge pull request #20511 from archbirdplus
runtime page size detection
rework GeneralPurposeAllocator to reduce active mapping count
Allocator VTable API update
2025-02-07 06:21:51 -08:00
Andrew Kelley
d20d934a8a std: fix compilation under -lc 2025-02-06 14:23:23 -08:00
Andrew Kelley
284de7d957 adjust runtime page size APIs
* 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.
2025-02-06 14:23:23 -08:00
Archbirdplus
439667be04 runtime page size detection
heap.zig: define new default page sizes
heap.zig: add min/max_page_size and their options
lib/std/c: add miscellaneous declarations
heap.zig: add pageSize() and its options
switch to new page sizes, especially in GPA/stdlib
mem.zig: remove page_size
2025-02-06 14:23:23 -08:00
David Rubin
eb72f26e28
std.c: add HINT to macos MAP 2025-02-06 01:17:49 -08:00
John Benediktsson
7309a13bd8 std.c: fix timerfd_clockid_t.MONOTONIC on freebsd 2025-02-03 15:44:27 +01:00
John Benediktsson
d358ef804e std.c: use linux.timerfd_clockid_t 2025-02-03 15:44:27 +01:00
Chris Boesch
58c00a829e
std.posix: Use separate clock ID enums for clock_gettime() and timerfd_create() (#22627) 2025-02-01 06:53:57 +00:00
Meghan Denny
7cef585f55 std.c: define more fields for darwin.AI 2025-01-30 01:44:45 +01:00
Bing Sun
798bb0bc61
std.c: android bionic compatibility fixes (getrandom & getaddressinfo) (#22143)
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2025-01-29 19:16:08 +00:00
Alex Rønne Petersen
484f72311e
Merge pull request #22634 from nektro/patch-6
std.c: was missing more
2025-01-29 16:26:57 +01:00
Meghan Denny
0bf57b7114 std: mkdir(2) mode uses mode_t 2025-01-29 14:57:07 +01:00
David Rubin
898658e3a0 std.c: add msghdr and msghdr_const definitions for macos 2025-01-29 13:34:37 +01:00
thejohnny5
78b7a446f0 std: add optional times pointer for futimes, futimens, utimes, utimensat 2025-01-29 09:17:20 +01:00
Meghan Denny
97ccf3504f std.c: was missing darwin.kevent64_s 2025-01-29 06:34:34 +01:00
Meghan Denny
0bbea1e848
std.c: was missing darwin.@"close$NOCANCEL" 2025-01-27 22:26:20 -08:00
Meghan Denny
1bfadc1381
std.c: was missing darwin.host_t 2025-01-27 21:40:23 -08:00
Meghan Denny
87b0e0821a
std.c: was missing darwin.natural_t 2025-01-27 21:38:25 -08:00
John Benediktsson
530335b572
adding std.c.TCP.NODELAY for macos (#22404)
closes #17260
2025-01-23 04:01:05 +00:00
mlugg
d00e05f186
all: update to std.builtin.Type.Pointer.Size field renames
This was done by regex substitution with `sed`. I then manually went
over the entire diff and fixed any incorrect changes.

This diff also changes a lot of `callconv(.C)` to `callconv(.c)`, since
my regex happened to also trigger here. I opted to leave these changes
in, since they *are* a correct migration, even if they're not the one I
was trying to do!
2025-01-16 12:46:29 +00:00
gbaraldi
10282eae64 Also export mach_timebase_info_data from darwin 2024-12-14 03:16:34 +01:00
Alex Rønne Petersen
24ecf45569
std.Target: Add Os.HurdVersionRange for Os.Tag.hurd.
This is necessary since isGnuLibC() is true for hurd, so we need to be able to
represent a glibc version for it.

Also add an Os.TaggedVersionRange.gnuLibCVersion() convenience function.
2024-11-24 22:11:16 +01:00
Gabriel Borrelli
ccf8488a1e Add missing pthread_key_t definition for Darwin 2024-11-16 17:18:07 +01:00
PauloCampana
e6989fe637
std: fix compiler errors
See: #20505, #21094
2024-11-12 22:08:27 +01:00
Daniel Hooper
ee9f00d673
Add missing Darwin declarations (#21929) 2024-11-07 00:09:39 +00:00
Alex Rønne Petersen
ab89af3d39
Merge pull request #21860 from alexrp/llvm-triple-stuff
More support for OS/libc version ranges in `std.Target` and improvements to LLVM target triple construction
2024-11-02 02:00:25 +01:00
Brook Jeynes
a99449d8be
std.c: Added utsname struct definition for .macos (#21873) 2024-11-01 07:57:00 +00:00
Alex Rønne Petersen
3c1ccbdf39
std.Target: Add support for specifying Android API level. 2024-11-01 06:23:59 +01:00