Commit graph

283 commits

Author SHA1 Message Date
Nikita
e1d4cf67ca Add two new io_uring flags to linux.zig 2024-07-03 05:28:55 -04:00
Peng Guanwen
82a934bb91 Fix futex2_waitv syscall
The syscall gives immediate compile error in zig 0.12. This fix that.
2024-06-13 16:51:13 -04:00
Wes Koerber
4239a0d9c3 fix: incorrect field sizes in std.os.linux.ifmap 2024-05-20 13:50:06 +03:00
Nameless
aecd9cc6d1 std.posix.iovec: use .base and .len instead of .iov_base and .iov_len 2024-04-28 00:20:30 -07:00
Jared Baur
c352845e88 Fix usage of unexpectedErrno
`unexpectedErrno` comes from `std.posix`, not `std.os`.
2024-04-20 19:37:41 -07:00
Jacob Young
5a41704f7e cbe: rewrite CType
Closes #14904
2024-03-30 20:50:48 -04:00
Jacob Young
2dd74cd312 haiku: debitrot 2024-03-23 18:11:32 +01:00
Andrew Kelley
5d389535e8 std: fix inconsistent errno size on linux
Now it's always u16
2024-03-20 00:36:41 -07:00
Andrew Kelley
cd62005f19 extract std.posix from std.os
closes #5019
2024-03-19 11:45:09 -07:00
Jacob Young
d10c52c194 AstGen: disallow alignment on function types
A pointer type already has an alignment, so this information does not
need to be duplicated on the function type.  This already has precedence
with addrspace which is already disallowed on function types for this
reason.  Also fixes `@TypeOf(&func)` to have the correct addrspace and
alignment.
2024-03-17 03:06:17 +01:00
Igor Anić
3ea1276eeb
io_uring: ring mapped buffers (#17806)
* io_uring: ring mapped buffers

Ring mapped buffers are newer implementation of ring provided buffers, supported
since kernel 5.19. Best described in Jens Axboe [post](https://github.com/axboe/liburing/wiki/io_uring-and-networking-in-2023#provided-buffers)

This commit implements low level io_uring_*_buf_ring_* functions as mostly
direct translation from liburing. It also adds BufferGroup abstraction over those
low level functions.

* io_uring: add multishot recv to BufferGroup

Once we have ring mapped provided buffers functionality it is possible to use
multishot recv operation. Multishot receive is submitted once, and completions
are posted whenever data arrives on the socket. Received data are placed in a
new buffer from buffer group.

Reference: [io_uring and networking in 2023](https://github.com/axboe/liburing/wiki/io_uring-and-networking-in-2023#multi-shot)

Getting NOENT for cancel completion result, meaning:
  -ENOENT
    The request identified by user_data could not be located.
    This could be because it completed before the cancelation
    request was issued, or if an invalid identifier is used.

https://man7.org/linux/man-pages/man3/io_uring_prep_cancel.3.html
https://github.com/ziglang/zig/actions/runs/6801394000/job/18492139893?pr=17806

Result in cancel/recv cqes are different depending on the kernel.
on older kernel (tested with v6.0.16, v6.1.57, v6.2.12, v6.4.16)
  cqe_cancel.err() == .NOENT
  cqe_crecv.err() == .NOBUFS
on kernel (tested with v6.5.0, v6.5.7)
  cqe_cancel.err() == .SUCCESS
  cqe_crecv.err() == .CANCELED
2024-03-15 22:34:31 -04:00
Tristan Ross
6067d39522
std.builtin: make atomic order fields lowercase 2024-03-11 07:09:10 -07:00
Tristan Ross
9d70d614ae
std.builtin: make link mode fields lowercase 2024-03-11 07:09:10 -07:00
mlugg
265f42d472
std.os.linux: rework io_uring support
* `linux.IO_Uring` -> `linux.IoUring` to align with naming conventions.
* All functions `io_uring_prep_foo` are now methods `prep_foo` on `io_uring_sqe`, which is in a file of its own.
* `SubmissionQueue` and `CompletionQueue` are namespaced under `IoUring`.

This is a breaking change.

The new file and namespace layouts are more idiomatic, and allow us to
eliminate one more usage of `usingnamespace` from the standard library.
2 remain.
2024-03-08 08:02:45 +00:00
mlugg
229800482d
std.os.linux: do not use usingnamespace to define getauxval
This usage of `usingnamespace` was removed fairly trivially - the
resulting code is, IMO, more clear.

Eliminates one more usage of `usingnamespace` from the standard library.
2024-03-08 08:02:44 +00:00
mlugg
14ab9fb154
std.os.linux: remove unnecessary use of usingnamespace
This is a trivial change - this code did `usingnamespace` into an
otherwise empty namespace, so the outer namespace was just unnecessary.

Eliminates one more usage of `usingnamespace` from the standard library.
2024-03-08 08:02:44 +00:00
OK Ryoko
0b2e23b066 std.os.linux: enforce null-terminated path arguments 2024-03-05 20:11:49 +02:00
Andrew Kelley
5f92558290 std.posix.termios: bring V back
In d7563a7753, I misunderstood what `cc_t`
was supposed to do. Those V enum values are indices into the array.
2024-02-13 20:10:32 -08:00
Andrew Kelley
ae107cf71b std.os.speed_t: add type safety
and collect the missing flag bits from all the operating systems.
2024-02-12 21:49:09 -07:00
Andrew Kelley
a280ff2767 std.os.termios: add type safety to lflag field
This creates `tc_cflag_t` even though such a type is not defined by
libc.

I also collected the missing flag bits from all the operating systems.
2024-02-12 21:21:45 -07:00
Andrew Kelley
e97fa8b038 std.os.termios: add type safety to cflag field
This creates `tc_cflag_t` even though such a type is not defined by
libc.

I also collected the missing flag bits from all the operating systems.
2024-02-12 18:24:07 -07:00
Andrew Kelley
20abc0caee std.os.termios: add type safety to oflag field
This creates `tc_oflag_t` even though such a type is not defined by
libc.

I also collected the missing flag bits from all the operating systems.
2024-02-12 17:28:09 -07:00
Andrew Kelley
47643cc5cc std.os.termios: add type safety to iflag field
This creates `tc_iflag_t` even though such a type is not defined by
libc.

I also collected the missing flag bits from all the operating systems.
2024-02-12 16:43:51 -07:00
Andrew Kelley
0c88f927f1 std.os.termios: consolidate and correct 2024-02-12 16:21:21 -07:00
Andrew Kelley
9a64318554 std.c.NCSS: consolidate and correct 2024-02-12 15:52:13 -07:00
Andrew Kelley
5258c3caad std: add type safety to cc_t 2024-02-12 15:41:38 -07:00
Andrew Kelley
fad5e7a997
Merge pull request #18898 from psnszsn/iouring_waitid
io_uring: add waitid operation
2024-02-12 12:20:12 -08:00
Andrew Kelley
7680c5330c some API work on std.c, std.os, std.os.wasi
* std.c: consolidate some definitions, making them share code. For
  example, freebsd, dragonfly, and openbsd can all share the same
  `pthread_mutex_t` definition.
* add type safety to std.c.O
  - this caught a bug where mode flags were incorrectly passed as the
    open flags.
* 3 fewer uses of usingnamespace keyword
* as per convention, remove purposeless field prefixes from struct field
  names even if they have those prefixes in the corresponding C code.
* fix incorrect wasi libc Stat definition
* remove C definitions from incorrectly being in std.os.wasi
* make std.os.wasi definitions type safe
* go through wasi native APIs even when linking libc because the libc
  APIs are problematic and wasteful
* don't expose WASI definitions in std.posix
* remove std.os.wasi.rights_t.ALL: this is a footgun. should it be all
  future rights too? or only all current rights known? both are
  the wrong answer.
2024-02-11 13:38:55 -07:00
Vlad Pănăzan
20ea0012f0 linux: add missing io_uring opcodes 2024-02-11 15:43:12 +01:00
Andrew Kelley
9f3165540e std.os.linux.MAP: use a packed struct
Introduces type safety to this constant. Eliminates one use of
`usingnamespace`.
2024-02-06 21:12:11 -07:00
Stephen Gregoratto
3200fae9c5 Linux: Add syscall bindings, enhance documentation.
- Add syscall bindings/structures for the `futex2` family.
  The documentation is taken from the syscall definitions.
- Add documnentation for the `cachestat` bindings and structures.
  Taken from work I did in Cosmopolitian libc.
- Add binding for `map_shadow_stack`.
  No documentation for this one, since the kernel devs didn't bother to
  do it ¯\_(ツ)_/¯.
2024-01-15 20:05:03 +11:00
Stephen Gregoratto
cf6751ae55 Add fchmodat2 bits to os/linux.zig 2024-01-13 23:52:01 -07:00
David Rubin
2f8e4347b1
Optimized std.mem.eql with SIMD (#18389)
* optimized memeql
* add `sched_setaffinity` to `std.os.linux`

Co-authored-by: Protty <45520026+kprotty@users.noreply.github.com>
Co-authored-by: Ryan Liptak <squeek502@hotmail.com>
2024-01-09 02:50:22 -05:00
xdBronch
7a46c20a79 switch to mem.span
Co-authored-by: erikarvstedt <36110478+erikarvstedt@users.noreply.github.com>
2023-12-08 15:58:08 +02:00
xdBronch
e9bd10cfda add getName helper to inotify_event 2023-12-08 15:58:08 +02:00
mlugg
51595d6b75
lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
Kai Jellinghaus
7ee7c90274 Fix regressing #17290 from #17734 2023-11-01 18:30:56 +02:00
Andrew Kelley
3fc6fc6812 std.builtin.Endian: make the tags lower case
Let's take this breaking change opportunity to fix the style of this
enum.
2023-10-31 21:37:35 -04:00
joadnacer
0005e7e70b std.linux: Update io_uring structs and consts for kernel 6.3.8 2023-10-27 00:31:52 +01:00
Prokop Randacek
fee09009a8 gettimeofday takes nullable pointers 2023-10-20 00:15:34 -04:00
Ratakor
8ce33795e9 Add pause() to linux.zig 2023-10-06 11:49:31 -07:00
Ratakor
cef90eab57 Add filled_sigset to os.linux
filled_sigset is equivalent to sigfillset() as empty_sigset is
equivalent to sigemptyset().
2023-10-06 11:49:31 -07:00
Jacob Young
2a5335d7b6 x86_64: implement C abi for 128-bit integers 2023-10-04 14:42:35 -04:00
nikneym
9f0d2f9417 linux: add fanotify API 2023-10-04 13:48:22 +03:00
Kai Jellinghaus
11489bb04f
Update IORING_OP to reflect upstream (#17388)
Reference [upstream io_uring.h](cbf3a2cb15/include/uapi/linux/io_uring.h (L234))
2023-10-04 09:18:14 +00:00
Stephen Gregoratto
bc0bf4e97a Linux: Add cachestat wrapper.
Can be tested using this program I whipped up:
https://gist.github.com/The-King-of-Toasters/aee448f5975c50f735fd1946794574f7
2023-09-28 18:58:05 +10:00
Kai Jellinghaus
d1e39b6914 Add new fields to io_sqring_offsets & io_cqring_offsets
`user_addr`s were introduced in `03d89a2` ([github link](03d89a2de2) which was shipped in v6.5
`flags` was introduced even earlier
2023-09-26 18:16:36 -07:00
kcbanner
2e2d6d2c3d linux: fixup for platforms that don't support extern functions yet 2023-08-27 19:50:57 -04:00
kcbanner
fb0cef8522 linux: only export getauxval if not linking libc 2023-08-27 16:52:43 -04:00
kcbanner
fba81cd606 linux: instead of export elf_aux_maybe, export getauxval itself 2023-08-27 11:12:31 -04:00