feat(libkernel): implement readv and writev #3382

Merged
babyhuey merged 1 commit from upstream-pr/3382 into main 2026-10-11 09:43:46 +00:00
babyhuey commented 2026-10-11 09:36:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T09:36:55Z.


What

Exports readv (I7ImcLds-uU) and writev (Z2aKdxzS4KE) from libkernel as POSIX wrappers over the existing sceKernelReadv and sceKernelWritev, the same way #3005 did preadv and pwritev: a failure returns -1 and sets the guest errno from the SCE error.

Ruffle Flash (PPSA68091) imports both and stops at readv on main c6ca798f, now that _umtx_op (#1482) and cpuset_setaffinity (#3323) are in (catalog build, eboot.bin and sce_module/libc.prx unwrapped as #2605 requires; tracked in #1578):

  • Linux: app.elf: symbol lookup error: app.elf: undefined symbol: I7ImcLds-uU
  • Windows: FAIL: unresolved ELF import I7ImcLds-uU (readv) from libkernel.prx
  • with this PR, Linux: app.elf: symbol lookup error: app.elf: undefined symbol: 1t1-JoZ0sZQ (sinhf)
  • with this PR, Windows: FAIL: unresolved ELF import 1t1-JoZ0sZQ (sinhf) from libSceLibcInternal.prx

@AchrafReyani had a branch for the same two functions and withdrew it in favour of this one on #1578.

Tested

Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release: guest_file_vector passes 5/5 (--repeat until-fail:5) on both, with no warnings in Stdio.cpp or GuestFileVector.cpp. The new cases read two buffers at the file position with readv and check the bytes, the position after it, a short read at the end and 0 at EOF; write the two buffers in swapped order with writev and check the file and the position, then write them back; and check EINVAL for a negative count and EFAULT for a null vector through errno. check_conventions.py passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818100274 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3382). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-11T09:36:55Z. --- ### What Exports `readv` (`I7ImcLds-uU`) and `writev` (`Z2aKdxzS4KE`) from libkernel as POSIX wrappers over the existing `sceKernelReadv` and `sceKernelWritev`, the same way #3005 did `preadv` and `pwritev`: a failure returns -1 and sets the guest `errno` from the SCE error. Ruffle Flash (PPSA68091) imports both and stops at `readv` on `main` c6ca798f, now that `_umtx_op` (#1482) and `cpuset_setaffinity` (#3323) are in (catalog build, `eboot.bin` and `sce_module/libc.prx` unwrapped as #2605 requires; tracked in #1578): - Linux: `app.elf: symbol lookup error: app.elf: undefined symbol: I7ImcLds-uU` - Windows: `FAIL: unresolved ELF import I7ImcLds-uU (readv) from libkernel.prx` - with this PR, Linux: `app.elf: symbol lookup error: app.elf: undefined symbol: 1t1-JoZ0sZQ` (`sinhf`) - with this PR, Windows: `FAIL: unresolved ELF import 1t1-JoZ0sZQ (sinhf) from libSceLibcInternal.prx` @AchrafReyani had a branch for the same two functions and withdrew it in favour of this one on #1578. ### Tested Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release: `guest_file_vector` passes 5/5 (`--repeat until-fail:5`) on both, with no warnings in `Stdio.cpp` or `GuestFileVector.cpp`. The new cases read two buffers at the file position with `readv` and check the bytes, the position after it, a short read at the end and 0 at EOF; write the two buffers in swapped order with `writev` and check the file and the position, then write them back; and check `EINVAL` for a negative count and `EFAULT` for a null vector through `errno`. `check_conventions.py` passes. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-11 09:37:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T09:37:26Z.


Progress report (097f4e2 → 63a4014)

➖ System libraries: 85.44% (+0.0%, +2 implemented functions)

✅ 2 implemented
Library Name
libkernel readv_nid_postfix
libkernel writev_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107655786 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3382#issuecomment-6107655786). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T09:37:26Z. --- <!-- progress-report --> ### Progress report (097f4e2 → 63a4014) ➖ **System libraries**: 85.44% (+0.0%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libkernel | `readv_nid_postfix` | | libkernel | `writev_nid_postfix` | </details>
adriadam10 commented 2026-10-11 09:43:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T09:43:43Z.


Checked the build and guest_file_vector on Linux; the new cases fail without the change (no link) and pass with it. The wrappers follow the existing preadv/pwritev PosixFailure pattern and errno values match the tests. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6107701740 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3382#issuecomment-6107701740). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T09:43:43Z. --- Checked the build and `guest_file_vector` on Linux; the new cases fail without the change (no link) and pass with it. The wrappers follow the existing `preadv`/`pwritev` `PosixFailure` pattern and errno values match the tests. Merging once CI is green.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!3382
No description provided.