feat(libc): implement rewind #2354

Closed
Vabian124 wants to merge 1 commit from upstream-pr/2354 into main
Vabian124 commented 2026-10-09 16:11:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Vabian124 on 2026-10-09T16:11:32Z.


What

Guest programs import rewind from libSceLibcInternal (#1578). libc now implements it the way FreeBSD does: seek to the start of the stream, drop a pushed-back character, and clear the end-of-file and error indicators. fseek to the start leaves a guest encoding error set, so rewind clears that afterwards. Titles that import it from libSceLibcInternal already search libc.prx for the symbol.

Tested

Windows 11 (10.0.26200), WinLibs GCC 15.2.0, Ninja, Release. ctest --test-dir build -R guest_standard_streams passed. The test writes a byte, pushes another character back, rewinds, and reads the original byte. It then reaches end-of-file, sets an encoding error, and checks that rewind clears both indicators and returns to the start.

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:4802953630 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2354). Originally posted by [Vabian124](https://github.com/Vabian124) on 2026-10-09T16:11:32Z. --- ### What Guest programs import `rewind` from `libSceLibcInternal` (#1578). libc now implements it the way FreeBSD does: seek to the start of the stream, drop a pushed-back character, and clear the end-of-file and error indicators. `fseek` to the start leaves a guest encoding error set, so `rewind` clears that afterwards. Titles that import it from `libSceLibcInternal` already search `libc.prx` for the symbol. ### Tested Windows 11 (10.0.26200), WinLibs GCC 15.2.0, Ninja, Release. `ctest --test-dir build -R guest_standard_streams` passed. The test writes a byte, pushes another character back, rewinds, and reads the original byte. It then reaches end-of-file, sets an encoding error, and checks that rewind clears both indicators and returns to the start. ### 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
Kikoarl commented 2026-10-09 17:03:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:03:04Z.


Linux run: Linux 7.2 (x86_64), GCC 16.2.1, Release, -DBUILD_TESTING=ON, #2354 (e5f8fac9) checked out on current main (0fdda7be).

  • tests/guest_standard_stream_tests: passes cleanly (fscanf: suppressed conversion passed; assigning register arguments).
  • tools/check_conventions.py: passes cleanly.
  • No regressions observed across the libc standard streams test suite.
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6085516319 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2354#issuecomment-6085516319). Originally posted by [Kikoarl](https://github.com/Kikoarl) on 2026-10-09T17:03:04Z. --- Linux run: Linux 7.2 (x86_64), GCC 16.2.1, Release, `-DBUILD_TESTING=ON`, #2354 (`e5f8fac9`) checked out on current `main` (`0fdda7be`). - `tests/guest_standard_stream_tests`: passes cleanly (`fscanf: suppressed conversion passed; assigning register arguments`). - `tools/check_conventions.py`: passes cleanly. - No regressions observed across the `libc` standard streams test suite.
oneandonlydean commented 2026-10-09 20:12:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:12:16Z.


Closing: rewind comes from the #1578 import audit, and no title is shown to stop at it on main. Reopen with the title ID and the log line when one does.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088475543 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2354#issuecomment-6088475543). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:12:16Z. --- Closing: `rewind` comes from the #1578 import audit, and no title is shown to stop at it on main. Reopen with the title ID and the log line when one does.

Pull request closed

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!2354
No description provided.