feat(libc): implement getline and getdelim with guest allocations #2060
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2060"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by QRMOE on 2026-10-09T06:19:05Z.
What
Adds
getdelim(e0iUSkl6-uU) andgetline(EFEe73sCz-8). Reads complete records under the native stream lock, includes the delimiter in the signed 64-bit result, keeps embedded NUL bytes, and grows the caller buffer through the application heap. Tracks library-generated stream errors and read access fromfopen,fdopenandfreopen; this gives guestEBADFfor write-only streams even when UCRT leaves errno unchanged. Allocation failures retain the caller buffer and capacity. Reference: FreeBSD getdelim.Tested
guest_line_inputandguest_line_input_allocation_failurepass. Cases include empty input, blank/binary records, custom NUL delimiters, final unterminated records, EOF state, buffer growth/reuse, 128 KiB input, invalid arguments, write-only stream errors, and 300 complete records consumed by two threads sharing a stream. A guest allocator forced to fail checks ENOMEM, stream error state, unchanged buffer/capacity and recovery without losing the next byte. Existingguest_standard_streamsandguest_errorsalso pass. The Linux nonblocking EAGAIN rollback and extreme EOVERFLOW path are not exercised on this Windows host.Windows 11, WinLibs MinGW-w64 GCC 15.2.0 r7 UCRT/posix/SEH, Ninja Release,
BUILD_TESTING=ON,ANYPS5_ENABLE_SPIRV_TOOLS=ON; basef145139676a48306681d3a4d5fabf83938759daf.Combined validation of these three independent branches: full
libstarget built successfully, including NID patching;guest_memmem,guest_bcopy, both line-input tests,guest_standard_streams, andguest_errorspass (6/6). All four NIDs are present in patchedlibc.prx. Conventions, diff whitespace and test registration checks pass. The branches were also built and tested individually before integration.Before publication, actual library diffs of 559 candidate PR heads were checked for these names and NIDs, including broad PRs and newer heads; no other implementation of these four exports was found. The candidates cover the cached open-PR list and every newer PR head; some candidates may have closed since that list was read.
Linux, console behavior, games and the complete CTest suite have not been run. This adds documented libc interfaces; no particular title starting successfully is claimed.
Checklist
main; no other open PR implements the same functionsImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T06:48:09Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)__error_nid_postfix__error_nid_postfixcore/libs/prx/libc/src/FileAndHeap.cppL106-107__error_nid_postfixImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T08:57:44Z.
Same as #2058, for
getlineandgetdelim.Pull request closed