This test was very dependent on details of the testing environment, and failed or succeeded according to details we don't seem to control in CI. In the end, this test was only reliable on macOS at desk. Accordingly,
we delete it.
Use String(unsafeUninitializedCapacity:initializingUTF8With:), through
the existing backwards-compatible helper, so the message is written
straight into the string's storage instead of a stack buffer that is
then copied. Also update the copyright year range of Errno.swift.
musl's message for an unknown error number doesn't include the number,
so skip that check when building against Musl, as on WASI.
strerror_s on Windows and bionic's strerror_r truncate without
returning an error, so detect a full buffer in the shim instead.
Also avoid the deprecated String(cString:) array overload in the test.
strerror(3) isn't guaranteed to be thread-safe: for an unknown error
number, it may format the message into a static buffer shared by all
threads, so concurrent calls to Errno.description could return each
other's text.
Add a csystem_strerror_r shim to CSystem that writes into a
caller-provided buffer. It hides the difference between the XSI
strerror_r (Darwin, BSDs, musl, WASI) and the GNU variant that glibc
and bionic provide under _GNU_SOURCE, and uses strerror_s on Windows.
Errno.description now formats into a stack buffer through this shim.
Also add tests for Errno.description, which were a TODO.
Fixes#156
When an operation failed, the blocking consume methods dropped its completion and only reported the `Errno`. The caller could not tell which request failed, since the `context` was lost. This breaks any user that matches completions to requests.
This PR makes `blockingConsumeCompletions` pass the completion of a failed operation together with its error. Errors of the ring itself, such as `.timeout`, are still passed without a completion. Additionally, `blockingConsumeCompletion(timeout:)` now returns the completion of a failed operation instead of throwing. It only throws errors of the ring itself.
I also added `Completion.error`, which is `nil` on success and the decoded `Errno` otherwise to make it easy to get to the error of a completion.
Fixes#364Fixes#395
To observe events on file descriptors IO_URING supports the `pollAdd` operation. This is useful when you want to observe a file descriptor becoming ready to read or write
This PR adds a new `IORing.Request.PollEvents` option set to model the poll masks. Furthermore, it adds a new `static func pollAdd` to the `IORing.Request`.
We can now use IO_URING to poll for events on file descriptors.