340 Commits

Author SHA1 Message Date
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
Alex Rønne Petersen
812a444d55 std.c: Fix Sigaction struct for glibc on mips/mips64. 2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
e2a4d7acfc std.c: Fix Stat struct for mips/mips64 on linux. 2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
e211dce6fc
std.Target: Remove minix OS tag.
It has not seen development in 6 years. RIP.

* https://github.com/Stichting-MINIX-Research-Foundation/minix/commits/master
* https://groups.google.com/g/minix3/c/nUG1NwxXXkg
2024-08-12 08:59:49 +02:00
Pat Tullmann
4d6429fc4f POSIX link() syscall only takes two arguments (no flags)
The signature is documented as:

   int link(const char *, const char *);

(see https://man7.org/linux/man-pages/man2/link.2.html or https://man.netbsd.org/link.2)

And its not some Linux extension, the [syscall
implementation](21b136cc63/fs/namei.c (L4794-L4797))
only expects two arguments too.

It probably *should* have a flags parameter, but its too late now.

I am a bit surprised that linking glibc or musl against code that invokes
a 'link' with three parameters doesn't fail (at least, I couldn't get any
local test cases to trigger a compile or link error).

The test case in std/posix/test.zig is currently disabled, but if I
manually enable it, it works with this change.
2024-08-07 13:05:42 -07:00
Jeffrey C. Ollie
979fd12be9 Add getppid to std.c and std.os.linux.
The std lib is missing getppid, this patch adds it.
2024-08-07 13:03:21 -07:00
Alex Rønne Petersen
c8ca05e93a
std.Target: Remove sparcel architecture tag.
What is `sparcel`, you might ask? Good question!

If you take a peek in the SPARC v8 manual, §2.2, it is quite explicit that SPARC
v8 is a big-endian architecture. No little-endian or mixed-endian support to be
found here.

On the other hand, the SPARC v9 manual, in §3.2.1.2, states that it has support
for mixed-endian operation, with big-endian mode being the default.

Ok, so `sparcel` must just be referring to SPARC v9 running in little-endian
mode, surely?

Nope:

* 40b4fd7a3e/llvm/lib/Target/Sparc/SparcTargetMachine.cpp (L226)
* 40b4fd7a3e/llvm/lib/Target/Sparc/SparcTargetMachine.cpp (L104)

So, `sparcel` in LLVM is referring to some sort of fantastical little-endian
SPARC v8 architecture. I've scoured the internet and I can find absolutely no
evidence that such a thing exists or has ever existed. In fact, I can find no
evidence that a little-endian implementation of SPARC v9 ever existed, either.
Or any SPARC version, actually!

The support was added here: https://reviews.llvm.org/D8741

Notably, there is no mention whatsoever of what CPU this might be referring to,
and no justification given for the "but some are little" comment added in the
patch.

My best guess is that this might have been some private exercise in creating a
little-endian version of SPARC that never saw the light of day. Given that SPARC
v8 explicitly doesn't support little-endian operation (let alone little-endian
instruction encoding!), and no CPU is known to be implemented as such, I think
it's very reasonable for us to just remove this support.
2024-07-30 06:30:25 +02:00
matt ettler
ed7f11ffa7 chore: correct non-standard comments.
Comments throughout the codebase start with a space.
This commit corrects comments that do not adhere to this
norm.
2024-07-28 21:34:14 -07:00
Alex Rønne Petersen
d1d95294fd std.Target.Cpu.Arch: Remove the aarch64_32 tag.
This is a misfeature that we inherited from LLVM:

* https://reviews.llvm.org/D61259
* https://reviews.llvm.org/D61939

(`aarch64_32` and `arm64_32` are equivalent.)

I truly have no idea why this triple passed review in LLVM. It is, to date, the
*only* tag in the architecture component that is not, in fact, an architecture.
In reality, it is just an ILP32 ABI for AArch64 (*not* AArch32).

The triples that use `aarch64_32` look like `aarch64_32-apple-watchos`. Yes,
that triple is exactly what you think; it has no ABI component. They really,
seriously did this.

Since only Apple could come up with silliness like this, it should come as no
surprise that no one else uses `aarch64_32`. Later on, a GNU ILP32 ABI for
AArch64 was developed, and support was added to LLVM:

* https://reviews.llvm.org/D94143
* https://reviews.llvm.org/D104931

Here, sanity seems to have prevailed, and a triple using this ABI looks like
`aarch64-linux-gnu_ilp32` as you would expect.

As can be seen from the diffs in this commit, there was plenty of confusion
throughout the Zig codebase about what exactly `aarch64_32` was. So let's just
remove it. In its place, we'll use `aarch64-watchos-ilp32`,
`aarch64-linux-gnuilp32`, and so on. We'll then translate these appropriately
when talking to LLVM. Hence, this commit adds the `ilp32` ABI tag (we already
have `gnuilp32`).
2024-07-28 19:44:52 -07:00
Nguyễn Gia Phong
d6fa71cd67
std: Wrap setpgid on POSIX 2024-07-22 11:49:55 +09:00
Alex Rønne Petersen
5a2f6acb44
std.Target: Remove kfreebsd OS specifier.
kFreeBSD is dead.

https://lists.debian.org/debian-devel/2023/07/msg00176.html
2024-07-20 05:08:14 +02:00
Andrew Kelley
01337e2093 fix regression of flock being called on wasi targets
* common symbols are now public from std.c even if they live in
  std.posix
* LOCK is now one of the common symbols since it is the same on 100% of
  operating systems.
* flock is now void value on wasi and windows
* std.fs.Dir now uses flock being void as feature detection, avoiding
  trying to call it on wasi and windows
2024-07-19 11:35:22 -07:00
Andrew Kelley
7157189143 macos doesn't have pipe2 2024-07-19 00:40:00 -07:00
Andrew Kelley
8c4a2dc1df move non-libc stuff out of std.c 2024-07-19 00:30:32 -07:00
Andrew Kelley
e8c4e79499 std.c reorganization
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-07-19 00:30:32 -07:00
Eric Joldasov
5af68a651c
std.c.LC: mark enum as non-exhaustive
They are implementation-defined and can have values other than
hard-coded here. Also, standard permits other values not mentioned
there:

> Additional macro definitions, beginning with the characters LC_
> and an uppercase letter, may also be specified by the implementation.

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-07-16 00:32:29 +05:00
Eric Joldasov
ece8480fc2
std.c.setlocale: fix return type to nullable pointer
According to https://en.cppreference.com/mwiki/index.php?title=c/locale/setlocale&oldid=171500 ,
`setlocale` "returns null value on failure":

> Return value
> pointer to a narrow null-terminated string identifying the C locale
> after applying the changes, if any, or null pointer on failure.

Example program:
```zig
const std = @import("std");

pub fn main() void {
    const ptr = std.c.setlocale(.ALL, "non_existent");
    std.debug.print("ptr = {d}\n", .{@intFromPtr(ptr)});
}
```

Output:
```console
ptr = 0
```

Signed-off-by: Eric Joldasov <bratishkaerik@landless-city.net>
2024-07-16 00:27:56 +05:00
Linus Groh
b3afba8a70 std.c: Add setlocale() 2024-07-05 04:45:44 -04:00
Jakub Konka
2e1fc0dd14 handle visionos target OS tag in the compiler
* rename .xros to .visionos as agreed in the tracking issue
* add support for VisionOS platform in the MachO linker
2024-05-09 15:04:15 +02:00