258 Commits

Author SHA1 Message Date
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
Michael Dusan
be91b68e66
dragonfly std: more std.c support 2024-10-07 13:19:33 -04:00
Alex Rønne Petersen
31d685f86f
std.c: Make dlopen() accept null for the path parameter.
Closes #21592.
2024-10-04 20:10:07 +02:00
Alex Rønne Petersen
b23a5b56c2
Merge pull request #21578 from alexrp/s390x-porting
Get module tests passing for `s390x-linux` and add it to CI
2024-10-04 14:40:32 +02:00
Alex Rønne Petersen
0345775559
Merge pull request #21577 from alexrp/mips32-stat
`std.c`: Fix `Stat` struct layout for mips/mipsel with glibc.
2024-10-04 01:30:13 +02:00
Alex Rønne Petersen
f4c23726a3
std.c: Fix Sigaction struct for s390x-linux-gnu. 2024-10-04 00:26:55 +02:00
Alex Rønne Petersen
9b273f6b9a
Merge pull request #21570 from alexrp/windows-itanium
Initial port work for `*-windows-itanium` support.
2024-10-03 21:53:22 +02:00
Alex Rønne Petersen
60f55b2bd2
std.c: Fix Stat struct layout for mips/mipsel with glibc.
std.os.linux.dev_t for mips32 is u64, but glibc uses u32.

Closes #21276.
2024-10-03 05:51:16 +02:00
Alex Rønne Petersen
537a873b17
Initial port work for *-windows-itanium support.
https://llvm.org/docs/HowToBuildWindowsItaniumPrograms.html

This is a weird middle ground between `*-windows-gnu` and `*-windows-msvc`. It
uses the C++ ABI of the former while using the system libraries of the latter.
2024-09-28 21:43:52 +02:00
Alex Rønne Petersen
ebbc50d8be
std.Target: Introduce Abi.androideabi to distinguish the soft float case.
Abi.android on its own is not enough to know whether soft float or hard float
should be used. In the C world, androideabi is typically used for the soft float
case, so let's go with that.

Note that Android doesn't have a hard float ABI, so no androideabihf.

Closes #21488.
2024-09-24 09:23:24 +02:00
Jeremy Hertel
52fc046907 std.c: fix pthread_mutex_t size for x86_64-linux-gnu 2024-09-01 00:44:09 -07:00
fn ⌃ ⌥
69e304bd51 std.c.passwd: support macOS and NetBSD 2024-08-31 20:56:27 -07:00
mlugg
a3a737e9a6
lib,test,tools,doc: update usages of @export 2024-08-27 00:44:35 +01:00
bilaliscarioth
dc72138b91 Update c.zig, openbsd don't have getcontext 2024-08-23 07:19:04 -07:00