feat(libc): implement __inet_ntoa #2208

Merged
reyani-dev merged 1 commit from upstream-pr/2208 into main 2026-10-10 06:28:39 +00:00
reyani-dev commented 2026-10-09 11:36:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T11:36:43Z.


What

Exports __inet_ntoa (the symbol behind inet_ntoa). It formats the four address bytes in network (memory) order as dotted decimal, as FreeBSD's lib/libc/inet/inet_ntoa.c does. The struct in_addr argument is passed by value; under the SysV ABI that is the 32-bit integer in edi, so the parameter is declared unsigned int.

FreeBSD returns a static buffer; this uses a per-thread buffer like basename in the same file, so concurrent callers don't overwrite each other's result. Each call still reuses the same buffer, which the test checks.

Titles: from the #1578 audit, imported from libSceLibcInternal (resolved through libc.prx) by PPSA99169 RetroArch, PPSA99764 Porpoise and PPSA99420 PS5MC. I haven't run any of these titles.

Related: #1848 (__inet_aton) and #1972 (__inet_addr) add the parsing side in the same file. This change sits after basename and adds no includes, so it merges cleanly with both and with #1812 (checked with git merge-tree).

Tested

Windows 11, WinLibs GCC 15.2.0 r7, Release, -DBUILD_TESTING=ON:

  • New checks in guest_string_tests, next to basename:
    • 127.0.0.1, 255.255.255.255, 0.0.0.0, 10.200.3.45;
    • 100.9.99.0, for a zero tens digit and single digits;
    • the same buffer is returned and overwritten on the next call.
  • Mutation check: host byte order (reversed bytes) and dropping a zero tens digit each make guest_strings fail.
  • cmake --build build --target libs: the patched libc.prx exports 6i5aLrxRhG0.
  • tools/check_conventions.py passes, and tools/pr_overlap.py --branch reports no overlap.

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

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4799865618 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2208). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-09T11:36:43Z. --- ### What Exports `__inet_ntoa` (the symbol behind `inet_ntoa`). It formats the four address bytes in network (memory) order as dotted decimal, as FreeBSD's `lib/libc/inet/inet_ntoa.c` does. The `struct in_addr` argument is passed by value; under the SysV ABI that is the 32-bit integer in `edi`, so the parameter is declared `unsigned int`. FreeBSD returns a static buffer; this uses a per-thread buffer like `basename` in the same file, so concurrent callers don't overwrite each other's result. Each call still reuses the same buffer, which the test checks. Titles: from the #1578 audit, imported from `libSceLibcInternal` (resolved through `libc.prx`) by PPSA99169 RetroArch, PPSA99764 Porpoise and PPSA99420 PS5MC. I haven't run any of these titles. Related: #1848 (`__inet_aton`) and #1972 (`__inet_addr`) add the parsing side in the same file. This change sits after `basename` and adds no includes, so it merges cleanly with both and with #1812 (checked with `git merge-tree`). ### Tested Windows 11, WinLibs GCC 15.2.0 r7, Release, `-DBUILD_TESTING=ON`: - New checks in `guest_string_tests`, next to `basename`: - `127.0.0.1`, `255.255.255.255`, `0.0.0.0`, `10.200.3.45`; - `100.9.99.0`, for a zero tens digit and single digits; - the same buffer is returned and overwritten on the next call. - Mutation check: host byte order (reversed bytes) and dropping a zero tens digit each make `guest_strings` fail. - `cmake --build build --target libs`: the patched `libc.prx` exports `6i5aLrxRhG0`. - `tools/check_conventions.py` passes, and `tools/pr_overlap.py --branch` reports no overlap. ### 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 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-09 11:37:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T11:37:08Z.


Progress report (c72d5ce → 471e537)

➖ System libraries: 85.7% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libc __inet_ntoa_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6080083731 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2208#issuecomment-6080083731). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T11:37:08Z. --- <!-- progress-report --> ### Progress report (c72d5ce → 471e537) ➖ **System libraries**: 85.7% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `__inet_ntoa_nid_postfix` | </details>
reyani-dev commented 2026-10-09 11:54:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T11:54:19Z.


Full Linux and Windows builds and tests for this head (5e4bf8ec), using the project's Build workflow. I can't start the upstream manual run, so I ran the same build.yml in my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into current main (d70b8998):

Job Result
linux success; full build, ctest: 516/516 passed
windows success; full build, ctest: 507/507 passed
relinker (Linux, Windows, macOS) success

Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37924809143

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6080332860 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2208#issuecomment-6080332860). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-09T11:54:19Z. --- Full Linux and Windows builds and tests for this head (`5e4bf8ec`), using the project's Build workflow. I can't start the upstream manual run, so I ran the same `build.yml` in my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into current `main` (`d70b8998`): | Job | Result | |---|---| | [linux](https://github.com/AchrafReyani/AnyPS5/actions/runs/37924809143/job/113801124929) | success; full build, `ctest`: 516/516 passed | | [windows](https://github.com/AchrafReyani/AnyPS5/actions/runs/37924809143/job/113801124784) | success; full build, `ctest`: 507/507 passed | | relinker (Linux, Windows, macOS) | success | Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/37924809143
MarcZX10 commented 2026-10-09 12:33:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T12:33:55Z.


PR #2231 is now the canonical, more complete IPv4-helper change. It includes this implementation along with the other parsing/formatting helpers, preserves the original author commits in its history, and adds cross-function round-trip coverage. The exact head has a local Linux full-build result with the documented GCC 12 SaveData workaround, and I requested the upstream Build. Please close this overlapping PR as superseded once the current-head Build on #2231 is reviewed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6080978721 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2208#issuecomment-6080978721). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T12:33:55Z. --- PR #2231 is now the canonical, more complete IPv4-helper change. It includes this implementation along with the other parsing/formatting helpers, preserves the original author commits in its history, and adds cross-function round-trip coverage. The exact head has a local Linux full-build result with the documented GCC 12 SaveData workaround, and I requested the upstream Build. Please close this overlapping PR as superseded once the current-head Build on #2231 is reviewed.
reyani-dev commented 2026-10-09 12:35:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T12:35:46Z.


Thanks for consolidating these. I checked #2231: my __inet_ntoa commit is in its history unchanged apart from the rebase (9f299a93), and the round-trip tests are a good addition. I'll close this PR as superseded once the Build on #2231's current head has been reviewed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081006532 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2208#issuecomment-6081006532). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-09T12:35:46Z. --- Thanks for consolidating these. I checked #2231: my `__inet_ntoa` commit is in its history unchanged apart from the rebase (`9f299a93`), and the round-trip tests are a good addition. I'll close this PR as superseded once the Build on #2231's current head has been reviewed.
MarcZX10 commented 2026-10-09 17:36:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T17:36:35Z.


Thanks for confirming that your __inet_ntoa commit is retained in #2231. I still consider my #2231 the better canonical merge target for this IPv4 helper family: it includes your formatter with __inet_aton and __inet_addr, plus cross-function round-trip tests.

The exact #2231 head 6923a54e now has a Windows guest_strings pass with no skipped cases. Its aggregate 519/519 CTest run needed local fixes to unrelated #1611, #1796, and #1824, so the required unmodified upstream Build is still pending. Please keep #2208 open until that Build is reviewed and a maintainer confirms the one-PR shape.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086036420 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2208#issuecomment-6086036420). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T17:36:35Z. --- Thanks for confirming that your `__inet_ntoa` commit is retained in #2231. I still consider my **#2231 the better canonical merge target** for this IPv4 helper family: it includes your formatter with `__inet_aton` and `__inet_addr`, plus cross-function round-trip tests. The exact #2231 head `6923a54e` now has a Windows `guest_strings` pass with no skipped cases. Its aggregate 519/519 CTest run needed local fixes to unrelated #1611, #1796, and #1824, so the required unmodified upstream Build is still pending. Please keep #2208 open until that Build is reviewed and a maintainer confirms the one-PR shape.
MarcZX10 commented 2026-10-09 17:42:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T17:42:17Z.


Update after rebase: #2231 is now on current main (f8c2f072) at 863ff49f; its Linux guest_strings test passes 1/1 and Conventions passes. The Windows results in its description are from the pre-rebase head 6923a54e, not this head, and the exact-head upstream Build is still pending.

I still consider #2231 the better canonical target for the IPv4 helper family because it preserves and combines the three implementations and adds cross-function tests. The overlapping PRs remain open until maintainers decide whether this cohesive family should land together; I am not treating the old Windows batch as current-head validation.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086123927 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2208#issuecomment-6086123927). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T17:42:17Z. --- Update after rebase: #2231 is now on current `main` (`f8c2f072`) at `863ff49f`; its Linux `guest_strings` test passes 1/1 and Conventions passes. The Windows results in its description are from the pre-rebase head `6923a54e`, not this head, and the exact-head upstream Build is still pending. I still consider #2231 the better canonical target for the IPv4 helper family because it preserves and combines the three implementations and adds cross-function tests. The overlapping PRs remain open until maintainers decide whether this cohesive family should land together; I am not treating the old Windows batch as current-head validation.
oneandonlydean commented 2026-10-09 20:15:15 +00:00 (Migrated from github.com)

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


Please keep this open. #1848 and #1972 go in as they are, and this one after them: RetroArch and Porpoise stop at __inet_ntoa once __inet_addr exists (CouchRiv's run on #2231). #2231 is being closed in favour of the three single PRs.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088518000 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2208#issuecomment-6088518000). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:15:15Z. --- Please keep this open. #1848 and #1972 go in as they are, and this one after them: RetroArch and Porpoise stop at `__inet_ntoa` once `__inet_addr` exists (CouchRiv's run on #2231). #2231 is being closed in favour of the three single PRs.
reyani-dev commented 2026-10-10 03:45:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T03:45:54Z.


Rebased onto current main (471e537c) now that #1848 and #1972 are in. There were no conflicts.

On Windows, guest_strings and guest_address_conversion pass, ctest -E "^agc_|video_out" is 297/297, and check_conventions.py passes. The full Linux and Windows build for this head is running and will be posted here.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6093438273 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2208#issuecomment-6093438273). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T03:45:54Z. --- Rebased onto current `main` (471e537c) now that #1848 and #1972 are in. There were no conflicts. On Windows, `guest_strings` and `guest_address_conversion` pass, `ctest -E "^agc_|video_out"` is 297/297, and `check_conventions.py` passes. The full Linux and Windows build for this head is running and will be posted here.
reyani-dev commented 2026-10-10 04:14:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-10T04:14:32Z.


Full Linux and Windows builds and tests for this head (471e537c), using the project's Build workflow. I can't start the upstream manual run, so I ran the same build.yml in my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into current main (d70b8998):

Job Result
linux success; full build, ctest: 587/587 passed
windows success; full build, ctest: 573/573 passed
relinker (Linux, Windows, macOS) success

Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/38021686529

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6093658157 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2208#issuecomment-6093658157). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-10T04:14:32Z. --- Full Linux and Windows builds and tests for this head (`471e537c`), using the project's Build workflow. I can't start the upstream manual run, so I ran the same `build.yml` in my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into current `main` (`d70b8998`): | Job | Result | |---|---| | [linux](https://github.com/AchrafReyani/AnyPS5/actions/runs/38021686529/job/114123862563) | success; full build, `ctest`: 587/587 passed | | [windows](https://github.com/AchrafReyani/AnyPS5/actions/runs/38021686529/job/114123862564) | success; full build, `ctest`: 573/573 passed | | relinker (Linux, Windows, macOS) | success | Run: https://github.com/AchrafReyani/AnyPS5/actions/runs/38021686529
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!2208
No description provided.