Commit Graph

380 Commits

Author SHA1 Message Date
Alex Rønne Petersen 9dfdf35032 Merge pull request #22337 from ruihe774/fix-app-mask
* std.os.linux: remove app_mask
* std.posix: on libc-less linux, block all signals in raise(), not just app_mask
2025-04-02 17:36:59 +02:00
wooster0 263ba34619 linux: don't export getauxval when not required 2025-03-26 20:37:35 +01:00
Igor Anić 94b36dbe50 io_uring: refactor buf_reg flags
Use packed struct instead of or-ed integers.

Thanks to @linsug for pr comments: https://github.com/ziglang/zig/pull/23062
2025-03-05 13:35:52 +01:00
Igor Anić c133171567 io_uring: incremental provided buffer consumption
[Incremental provided buffer
consumption](https://github.com/axboe/liburing/wiki/What's-new-with-io_uring-in-6.11-and-6.12#incremental-provided-buffer-consumption)
support is added in kernel 6.12.

IoUring.BufferGroup will now use incremental consumption whenever
kernel supports it.

Before, provided buffers are wholly consumed when picked. Each cqe
points to the different buffer. With this, cqe points to the part of the
buffer. Multiple cqe's can reuse same buffer.
Appropriate sizing of buffers becomes less important.

There are slight changes in BufferGroup interface (it now needs to track
current receive point for each buffer). Init requires allocator
instead of buffers slice, it will allocate buffers slice and head
pointers slice. Get and put now requires cqe becasue there we have
information will the buffer be reused.
2025-03-05 13:35:52 +01:00
Igor Anić 4df039d235 io_uring: add setsockopt/getsockopt
ring.cmd_sock is generic socket operation. Two most common uses are
setsockopt and getsockopt. This provides same interface as posix
versions of this methods.

libring has also [sqe_set_flags](https://man7.org/linux/man-pages/man3/io_uring_sqe_set_flags.3.html)
method. Adding that in our io_uring_sqe. Adding sqe.link_next method for setting most common flag.
2025-03-05 13:35:52 +01:00
Igor Anić d98c0893b0 io_uring: probe capabilities function
ring.get_probe returns io_uring_probe which can be use to probe
capabilities of the current running kernel.

Ref:
https://unixism.net/loti/ref-liburing/supported_caps.html
https://github.com/axboe/liburing/blob/e1003e496e66f9b0ae06674869795edf772d5500/src/setup.c#L454
2025-03-05 13:35:52 +01:00
Igor Anić 2da8eff9d6 io_uring: add bind and listen 2025-03-05 13:35:52 +01:00
Jari Vetoniemi aa5c6c027c linux: add UDP socket options 2025-02-21 06:05:04 +01:00
Jari Vetoniemi c41bc20ec7 linux: add IORING_RECVSEND_BUNDLE 2025-02-20 12:09:38 +01:00
Andrew Kelley 2c5113f6d1 std.os.linux.mmap: remove logic that does not belong here 2025-02-06 14:23:23 -08:00
Andrew Kelley a4d4e086c5 introduce std.posix.mremap and use it
in std.heap.page_allocator
2025-02-06 14:23:23 -08:00
Misaki Kasumi cc65eaf0a9 std.os.linux: remove app_mask 2025-02-05 06:25:04 +01:00
John Benediktsson 6a1b76a02c std.os.linux: re-add missing timerfd_create() constants 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
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