35 Commits

Author SHA1 Message Date
rpkak
6b4f45f782 system specific errno 2025-11-20 15:03:23 -08:00
Alex Rønne Petersen
508f676bb4
std.os.linux.IoUring: disable bind/listen/connect on s390x
https://github.com/ziglang/zig/issues/25956
2025-11-19 01:42:45 +01:00
John Benediktsson
74c23a237e
Merge pull request #25763 from mrjbq7/cancelled
rename Cancelled to Canceled
2025-10-30 04:40:13 +00:00
Andrew Kelley
0205ce4736 std.os.linux.IoUring: disable failing test
tracked by https://github.com/ziglang/zig/issues/25734
2025-10-29 06:26:05 -07:00
Andrew Kelley
c87fbd5878 std.os.linux.IoUring: use linux msghdr
it disagrees with posix msghdr
2025-10-29 06:20:51 -07:00
Andrew Kelley
750b1431bf std: fix some Io compilation errors 2025-10-29 06:20:49 -07:00
Andrew Kelley
47aa5a70a5 std: updating to std.Io interface
got the build runner compiling
2025-10-29 06:20:48 -07:00
Özgür Akkurt
99c4890559
implement registering NAPI on IoUring (#24850) 2025-08-16 09:18:49 +02:00
Seiichi Uchida
bbc21393b4 Add register_file_alloc_range 2025-05-06 18:01:07 +02: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
e1003e496e/src/setup.c (L454)
2025-03-05 13:35:52 +01:00
Igor Anić
85e2074878 io_uring: fix tests on 5.4.0 kernel
Found it failing in a new way on that kernel.
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
nikneym
408c817e1e linux/IoUring: add register_files_sparse 2025-02-11 13:19:05 +03: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
Jean-Baptiste "Jiboo" Lepesme
901f344be2 IoUring: fix an issue in tests where InvalidVersion might get thrown by skipKernelLessThan, due to some kernel versions not being SemVer compliant. 2024-10-11 17:07:34 +02:00
Andrew Kelley
33c7984183 add std.testing.random_seed
closes #17609
2024-07-23 11:43:12 -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
Jora Troosh
13070448f5
std: fix typos (#20560) 2024-07-09 14:25:42 -07:00
Igor Anić
b8890f8ee1 io_uring: don't assume completions order (2)
In my first [try](https://github.com/ziglang/zig/pull/20224) to fix
20212 I didn't reproduce bug on required kernel (6.9.2) and wrongly
concluded that first two completions have different order on newer
kernel.
On my current kernel (6.5.0) order of completions is: send1, recv,
send2. On 6.9.2 order is send1, send2, recv. This fix allows second two
completions to arrive in any order.
Tested on both kernels.

Fixes: #20212
2024-06-20 18:03:28 -04:00
Ryan Liptak
76fb2b685b std: Convert deprecated aliases to compile errors and fix usages
Deprecated aliases that are now compile errors:

- `std.fs.MAX_PATH_BYTES` (renamed to `std.fs.max_path_bytes`)
- `std.mem.tokenize` (split into `tokenizeAny`, `tokenizeSequence`, `tokenizeScalar`)
- `std.mem.split` (split into `splitSequence`, `splitAny`, `splitScalar`)
- `std.mem.splitBackwards` (split into `splitBackwardsSequence`, `splitBackwardsAny`, `splitBackwardsScalar`)
- `std.unicode`
  + `utf16leToUtf8Alloc`, `utf16leToUtf8AllocZ`, `utf16leToUtf8`, `fmtUtf16le` (all renamed to have capitalized `Le`)
  + `utf8ToUtf16LeWithNull` (renamed to `utf8ToUtf16LeAllocZ`)
- `std.zig.CrossTarget` (moved to `std.Target.Query`)

Deprecated `lib/std/std.zig` decls were deleted instead of made a `@compileError` because the `refAllDecls` in the test block would trigger the `@compileError`. The deleted top-level `std` namespaces are:

- `std.rand` (renamed to `std.Random`)
- `std.TailQueue` (renamed to `std.DoublyLinkedList`)
- `std.ChildProcess` (renamed/moved to `std.process.Child`)

This is not exhaustive. Deprecated aliases that I didn't touch:
  + `std.io.*`
  + `std.Build.*`
  + `std.builtin.Mode`
  + `std.zig.c_translation.CIntLiteralRadix`
  + anything in `src/`
2024-06-13 10:18:59 -04:00
Igor Anić
45b62c4529 io_uring: don't assume completions order
We are posting two submission (zero copy send and receive) and then
reading two completions. There is no guarantee that those completions
will be in the order of submissions.
This test was expecting fist send completion then receive.
Fix is allowing them to come other way too.
2024-06-08 15:35:41 -04:00
Andrew Kelley
63754916c5 disable failing IoUring test
tracked by #20212
2024-06-06 11:13:22 -07:00
Karl Bohlmark
6eb17a034a fix integer overflow in IoUring buffer ring size calculation 2024-05-09 16:00:01 -07: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
Igor Anić
254c05a9e1 io_uring: simplify copy_cqe logic
First copy as much as we can in this cycle. If there is more needed
wrap and start from the buffer 0 position.
2024-03-31 23:57:16 +02:00
Igor Anić
704660c81a io_uring: fix copy_cqes logic 2024-03-31 23:52:46 +02:00
Igor Anić
631c28c9e3 io_uring: add failing test
For issue: #19451
2024-03-31 23:51:40 +02:00
Andrew Kelley
cd62005f19 extract std.posix from std.os
closes #5019
2024-03-19 11:45:09 -07: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
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