367 Commits

Author SHA1 Message Date
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
John Benediktsson
c104e86442
std.os.linux: adding recvmmsg() (#22651) 2025-01-31 15:44:50 +00:00
Meghan Denny
0bf57b7114 std: mkdir(2) mode uses mode_t 2025-01-29 14:57:07 +01:00
thejohnny5
78b7a446f0 std: add optional times pointer for futimes, futimens, utimes, utimensat 2025-01-29 09:17:20 +01:00
Enrique Miguel Mora Meza
24965af295
std.os.linux: Adding sigdelset (#22406) 2025-01-26 18:49:25 +01: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
Misaki Kasumi
021289a653 linux: make ptid and ctid in clone() optional 2024-12-31 05:24:10 +01:00
Meili C
0f17cbfc6a fix: allow std.linux.getgroups to accept null
looking at `man getgroups` and `info getgroups` this is given as an
example:

  ```c
       // Here's how to use ‘getgroups’ to read all the supplementary group
       // IDs:

            gid_t *
            read_all_groups (void)
            {
              int ngroups = getgroups (0, NULL);
              gid_t *groups
                = (gid_t *) xmalloc (ngroups * sizeof (gid_t));
              int val = getgroups (ngroups, groups);
              if (val < 0)
                {
                  free (groups);
                  return NULL;
                }
              return groups;
            }
  ```

getgroups(0, NULL) is used to get the count of groups so that the
correct count can be used to allocate a list of gid_t. This small changes makes this
possible.

equivalent example in Zig after the change:

  ```zig
    // get the group count
    const ngroups: usize = std.os.linux.getgroups(0, null);
    if (ngroups <= 0) {
        return error.GetGroupsError;
    }

    std.debug.print("number of groups: {d}\n", .{ngroups});
    const groups_gids: []u32 = try alloc.alloc(u32, ngroups);

    // populate an array of gid_t
    _ = std.os.linux.getgroups(ngroups, @ptrCast(groups_gids));
  ```
2024-12-22 21:48:47 +01:00
Alex Rønne Petersen
14c79203c4
std.os.linux: Fix fadvise64 syscall selection for n32/x32. 2024-12-01 02:23:55 +01:00
curuvar
53a232e51d
Add realtime scheduling calls to std.os.linux (issue #19671) (#19675)
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-11-16 20:55:39 +00:00
Benjamin Hetz
c59aee03c8 Flags for SIOC{G,S}IFFLAGS 2024-11-13 06:11:39 +01:00
Alex Rønne Petersen
2f003f39b2
Merge pull request #21599 from alexrp/thumb-porting 2024-11-03 14:25:30 +01:00
Alex Rønne Petersen
c9e67e71c1
std.Target: Replace isARM() with isArmOrThumb() and rename it to isArm().
The old isARM() function was a portability trap. With the name it had, it seemed
like the obviously correct function to use, but it didn't include Thumb. In the
vast majority of cases where someone wants to ask "is the target Arm?", Thumb
*should* be included.

There are exactly 3 cases in the codebase where we do actually need to exclude
Thumb, although one of those is in Aro and mirrors a check in Clang that is
itself likely a bug. These rare cases can just add an extra isThumb() check.
2024-11-03 09:29:30 +01:00
Alex Rønne Petersen
d61e4ef8b0
generate_linux_syscalls: Generate syscalls for x32.
Also update the syscalls file based on Linux 6.10. No diffs other than x32.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
270fbbcd86
std.Target: Add muslabin32 and muslabi64 tags to Abi.
Once we upgrade to LLVM 20, these should be lowered verbatim rather than to
simply musl. Similarly, the special case in llvmMachineAbi() should go away.
2024-11-02 10:42:53 +01:00
Nelson Crosby
b1361f237a Fix up Linux xattr syscalls
fgetxattr now doesn't accidentally call lgetxattr,
and argument types are more consistent.
2024-10-26 13:53:07 +02:00
Alex Rønne Petersen
2309d07e20 std.os.linux: Use the Thumb-specific syscall helpers for thumbeb too.
Fixes a "write to reserved register r7" compile error for thumbeb-linux-*.
2024-10-11 02:38:30 +02:00
Alex Rønne Petersen
be5378b038
Merge pull request #21587 from alexrp/hexagon-porting
Some initial `hexagon-linux` port work
2024-10-06 13:35:56 +02:00
Alex Rønne Petersen
cd6795fc06
std.os.linux: Fix mmap() syscall invocation for s390x.
The s390x mmap() syscall existed before Linux supported syscalls with 5+
parameters, so it takes a single pointer to an array of arguments instead.
2024-10-04 00:26:53 +02:00
Alex Rønne Petersen
fe30df6b8c
std.os.linux: Add hexagon arch bits. 2024-10-03 09:12:35 +02:00
Alex Rønne Petersen
c560e26fb7
std.os.linux: Rename some arch bits files to match std.Target.Cpu.Arch tags. 2024-10-03 09:12:35 +02:00
pseudoc
0d00c733de std.os.linux: extend rtattr.type to support IFA_*
This is a breaking change which updates the `rtattr.type` from `IFLA` to
`union { IFLA, IFA }`. `IFLA` is for the `RTM_*LINK` messages and `IFA`
is for the `RTM_*ADDR` messages.
2024-09-26 10:54:18 +08:00
Meghan Denny
5e4da1ff30
std: add arch bits for s390x-linux (#21342)
see #21402
2024-09-24 13:35:12 -07:00
Linus Groh
72fc164178 std.os.linux: Fix tc_oflag_t for PowerPC
std/os/linux.zig:6504:20: error: expected type 'os.linux.NLDLY__enum_11313', found 'comptime_int'
2024-09-19 16:55:00 -07:00
Alex Rønne Petersen
8043197995
std.os.linux: Add clock_nanosleep() syscall wrapper. 2024-09-06 20:03:00 +02:00
Alex Rønne Petersen
68bb788df5
std.os.linux: Make nanosleep() a compile error on riscv32.
This should eventually be converted to the void/{} pattern along with the other
syscalls that are compile errors for riscv32.
2024-08-31 03:31:58 +02:00
Alex Rønne Petersen
6364995d3f
std.os.linux: Also use kernel_timespec for riscv32 when libc is linked.
Both glibc and musl use time64 as the base ABI for riscv32. This fixes the
`sleep` test in `std.time` hanging forever due to the libc functions reading
bogus values.
2024-08-31 03:31:58 +02:00
mlugg
0fe3fd01dd
std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
mlugg
a3a737e9a6
lib,test,tools,doc: update usages of @export 2024-08-27 00:44:35 +01:00
Michał Drozd
206e5e4d7d
std.os.linux: Fix bunch of compilation errors (#21138)
* Correct layout of IntInfo according to https://www.kernel.org/doc/html/latest/bpf/btf.html#btf-kind-int

* Fix VFS errors

* Fix std.os.linux.sendmmsg

* Fix std.os.linux.sigismember. Add tests

* Fix futex2 functions
2024-08-23 14:21:19 +00:00
Andrew Kelley
60011d28d3
Merge pull request #21137 from Aransentin/af_packet
std.os.linux: Add support for AF_PACKET V3
2024-08-23 00:46:18 -07:00
Andrew Kelley
ee84deda98
Merge pull request #21095 from alexrp/mips64-tests
Get `mips64(el)-linux` working and start testing it
2024-08-22 20:09:08 -07:00
Jens Goldberg
c3214bcd96 Inline the variant union 2024-08-21 10:10:19 +02:00
Jens Goldberg
6f24c4485c Add tpacket_hdr and tpacket_block variant unions 2024-08-20 10:10:14 +02:00
Mohanavel S K
82b676ef79
Added Constants Related To Ioctl (sockios.h) 2024-08-19 20:21:26 +03:00
Jens Goldberg
1950e52c6c Remove FASTROUTE; invisible to userspace, and collides with USER 2024-08-19 16:19:05 +02:00
Jens Goldberg
af007ec1ff std.os.linux: Add support for AF_PACKET V3 2024-08-19 15:01:58 +02:00
Alex Rønne Petersen
ed9a502dff std.os.linux: Fix rlimit_resource for mips64; move out of arch bits.
It is usually generic, so no point having it in arch bits.
2024-08-18 07:27:23 +02:00
Alex Rønne Petersen
bcf41c8594 std.os.linux: Fix E definition for mips64. 2024-08-18 07:27:23 +02:00
reokodoku
20f4be4cf9 std.os.linux: add mseal syscall 2024-08-14 22:48:13 -07:00
Linus Groh
9ef16b36ce std.os.linux: Fix definition of tc_lflag_t on MIPS
Regressed in #21000.
2024-08-12 00:46:28 -07:00
Alex Rønne Petersen
ae5bf2faab std.os.linux: Retranslate and port some ioctl-related types and values. 2024-08-09 13:10:51 -07:00
YANG Xudong
a9b65b6fd4
std: add loongarch64 support (#20915)
Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>
2024-08-09 00:30:57 +00:00
YANG Xudong
b8705ed652
loongarch: various architecture specific fixes (#20912) 2024-08-07 13:06:29 -07: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
f9f8942008 std.os.linux: Move clone() here and stop exporting it. 2024-08-07 01:19:51 -07:00
Andrew Kelley
75f78bfb77
Merge pull request #20922 from alexrp/vdso
`std.os.linux`: Fix VDSO for mips, add VDSO for riscv
2024-08-07 01:18:35 -07:00
Alex Rønne Petersen
d71076c982
std.os.linux: Replace @hasDecl() with != void check for VDSO.
If there is a VDSO, it will have clock_gettime(). The main thing we're concerned
about is architectures that don't have a VDSO at all, of which there are a few.
2024-08-03 18:46:04 +02:00
Alex Rønne Petersen
f7d07b44d1
std.os.linux: Fix arm check in fadvise() to also include thumb. 2024-08-01 20:58:08 +02:00