feat(libc): implement IPv4 address helpers #2231

Closed
MarcZX10 wants to merge 5 commits from upstream-pr/2231 into main
MarcZX10 commented 2026-10-09 12:33:35 +00:00 (Migrated from github.com)

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


What

Implement the guest libc IPv4 address helpers used by the current homebrew audit:

  • __inet_aton parses the FreeBSD one-to-four-part IPv4 forms, including octal and hexadecimal components, and leaves the output untouched on invalid input.
  • __inet_addr returns the parsed address in network byte order or INADDR_NONE, preserving FreeBSD's one-part unsigned wrap behavior.
  • __inet_ntoa formats the address bytes in network order into a per-thread buffer.

The tests cover dotted and abbreviated forms, octal and hexadecimal forms, whitespace termination, invalid input/output preservation, FreeBSD wrap cases, buffer reuse, and round trips across all three functions.

This PR consolidates the work in #1848, #1972, and #2208 into the previously reviewed IPv4-helper change from #1766. The original authors' commits are preserved in this branch history. Those three PRs currently overlap this implementation; this PR is intended as the single canonical change after the current-head Build is reviewed.

Tested

Linux x86-64, GCC 12.2, Release:

  • guest_strings passed (1/1) on the final source tree.
  • tools/check_conventions.py --base upstream/main passed.
  • git diff --check upstream/main...HEAD passed.
  • The libc and libs targets plus a full all-target build completed. GCC 12.2 cannot compile the unrelated std::chrono::clock_cast in current main, so the local full-build run temporarily applied the equivalent file-clock conversion from #1260; that unrelated source edit was restored before the final focused test and is not part of this PR.

A full upstream Build on this head is still needed. No PS5 hardware or title was run locally.

Additional title stop evidence (not run with this PR)

A contributor reported that RetroArch (PPSA99169) and Porpoise (PPSA99764) both stop on __inet_addr on current main, then stop on __inet_ntoa after adding only __inet_addr. The report used Linux title runs with an __inet_addr implementation and did not run this PR; it supports the imports' relevance but does not establish title compatibility. See the report.

Native Windows evidence on pre-rebase head 6923a54e

A Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release run passed guest_strings with no skipped cases. The aggregate CTest run passed 519/519, but that build included 38 other PRs and needed local fixes to unrelated #1611, #1796, and #1824. This is not an unmodified upstream Build for this PR. No title was run.

Current head after rebase

Current head 863ff49fed19b11b21d4c3974ef09d3bc3e14b47 is based on current upstream main f8c2f072463465f875dedb0d20b66c339160c1a1.

  • Linux x86-64, GCC 12.2, Release: rebuilt guest_string_tests; guest_strings passed (1/1).
  • python3 tools/check_conventions.py --base upstream/main and git diff --check upstream/main...HEAD pass.
  • The exact-head upstream Linux/Windows Build and relinker matrix is still required. The prior Windows results above are from before the rebase.

Checklist

  • Based on current main; #1848, #1972, and #2208 still overlap this IPv4 helper family. Their authors have been told why #2231 is the preferred combined target; maintainers decide whether to land it as one PR.
  • One topic: guest libc IPv4 parsing and formatting
  • No comments added to code
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation files, or images added
  • No third-party code added
  • Generic behavior
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4800461009 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2231). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T12:33:35Z. --- ### What Implement the guest libc IPv4 address helpers used by the current homebrew audit: - `__inet_aton` parses the FreeBSD one-to-four-part IPv4 forms, including octal and hexadecimal components, and leaves the output untouched on invalid input. - `__inet_addr` returns the parsed address in network byte order or `INADDR_NONE`, preserving FreeBSD's one-part unsigned wrap behavior. - `__inet_ntoa` formats the address bytes in network order into a per-thread buffer. The tests cover dotted and abbreviated forms, octal and hexadecimal forms, whitespace termination, invalid input/output preservation, FreeBSD wrap cases, buffer reuse, and round trips across all three functions. This PR consolidates the work in #1848, #1972, and #2208 into the previously reviewed IPv4-helper change from #1766. The original authors' commits are preserved in this branch history. Those three PRs currently overlap this implementation; this PR is intended as the single canonical change after the current-head Build is reviewed. ### Tested Linux x86-64, GCC 12.2, Release: - `guest_strings` passed (1/1) on the final source tree. - `tools/check_conventions.py --base upstream/main` passed. - `git diff --check upstream/main...HEAD` passed. - The `libc` and `libs` targets plus a full all-target build completed. GCC 12.2 cannot compile the unrelated `std::chrono::clock_cast` in current `main`, so the local full-build run temporarily applied the equivalent file-clock conversion from #1260; that unrelated source edit was restored before the final focused test and is not part of this PR. A full upstream Build on this head is still needed. No PS5 hardware or title was run locally. ### Additional title stop evidence (not run with this PR) A contributor reported that RetroArch (PPSA99169) and Porpoise (PPSA99764) both stop on `__inet_addr` on current `main`, then stop on `__inet_ntoa` after adding only `__inet_addr`. The report used Linux title runs with an `__inet_addr` implementation and did not run this PR; it supports the imports' relevance but does not establish title compatibility. See [the report](https://github.com/boykopovar/AnyPS5/pull/2231#issuecomment-6081524924). ### Native Windows evidence on pre-rebase head `6923a54e` A Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release run passed `guest_strings` with no skipped cases. The aggregate CTest run passed 519/519, but that build included 38 other PRs and needed local fixes to unrelated #1611, #1796, and #1824. This is not an unmodified upstream Build for this PR. No title was run. ### Current head after rebase Current head `863ff49fed19b11b21d4c3974ef09d3bc3e14b47` is based on current upstream `main` `f8c2f072463465f875dedb0d20b66c339160c1a1`. - Linux x86-64, GCC 12.2, Release: rebuilt `guest_string_tests`; `guest_strings` passed (1/1). - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check upstream/main...HEAD` pass. - The exact-head upstream Linux/Windows Build and relinker matrix is still required. The prior Windows results above are from before the rebase. ### Checklist - [ ] Based on current `main`; #1848, #1972, and #2208 still overlap this IPv4 helper family. Their authors have been told why #2231 is the preferred combined target; maintainers decide whether to land it as one PR. - [x] One topic: guest libc IPv4 parsing and formatting - [x] No comments added to code - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation files, or images added - [x] No third-party code added - [x] Generic behavior - [x] Depends on: none - [x] AI-assisted: yes
MarcZX10 commented 2026-10-09 12:34:01 +00:00 (Migrated from github.com)

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


The full local Linux build completed with the GCC 12 compatibility workaround documented above, and the focused guest_strings CTest and Conventions pass on the final source tree. Under CONTRIBUTING, the full Linux/Windows Build and relinker matrix needs an authorized collaborator. Could a collaborator run Actions → Build for PR #2231 so this exact head is checked before the overlapping PRs are closed?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6080980228 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2231#issuecomment-6080980228). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T12:34:01Z. --- The full local Linux build completed with the GCC 12 compatibility workaround documented above, and the focused `guest_strings` CTest and Conventions pass on the final source tree. Under CONTRIBUTING, the full Linux/Windows Build and relinker matrix needs an authorized collaborator. Could a collaborator run Actions → Build for PR #2231 so this exact head is checked before the overlapping PRs are closed?
github-actions[bot] commented 2026-10-09 12:40:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T12:40:30Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#2208 __inet_ntoa_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081079722 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2231#issuecomment-6081079722). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T12:40:30Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #2208 | | `__inet_ntoa_nid_postfix` | |
CouchRiv commented 2026-10-09 13:08:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-09T13:08:51Z.


On the "no title stop for __inet_ntoa" point: two catalog titles stop on it once __inet_addr exists. Linux (CachyOS, GCC, Release), titles relinked and run in a bubblewrap sandbox, main f1451396 plus an __inet_addr implementation (our closed #1974, same behaviour as #1972):

Title main with __inet_addr
RetroArch PPSA99169 1.0.0-beta.1 undefined symbol: 7p7kTAJcuGg (__inet_addr) undefined symbol: 6i5aLrxRhG0 (__inet_ntoa)
Porpoise PPSA99764 2.7 undefined symbol: 7p7kTAJcuGg undefined symbol: 6i5aLrxRhG0

Not run with this PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6081524924 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2231#issuecomment-6081524924). Originally posted by [CouchRiv](https://github.com/CouchRiv) on 2026-10-09T13:08:51Z. --- On the "no title stop for `__inet_ntoa`" point: two catalog titles stop on it once `__inet_addr` exists. Linux (CachyOS, GCC, Release), titles relinked and run in a bubblewrap sandbox, `main` f1451396 plus an `__inet_addr` implementation (our closed #1974, same behaviour as #1972): | Title | `main` | with `__inet_addr` | |---|---|---| | RetroArch PPSA99169 1.0.0-beta.1 | `undefined symbol: 7p7kTAJcuGg` (`__inet_addr`) | `undefined symbol: 6i5aLrxRhG0` (`__inet_ntoa`) | | Porpoise PPSA99764 2.7 | `undefined symbol: 7p7kTAJcuGg` | `undefined symbol: 6i5aLrxRhG0` | Not run with this PR.
MarcZX10 commented 2026-10-09 14:00:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T14:00:19Z.


Thanks for running the full Linux/Windows Build workflow for #2208 and confirming your __inet_ntoa commit is preserved in this PR. Would you be able to run the same fork workflow against #2231’s exact current head 6923a54e? Your #2208 run is strong evidence for the shared commit, but this head also integrates the other IPv4 helpers and round-trip tests, so an exact-head run would close the remaining Windows/full-suite gap while the upstream manual Build is pending.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6082438387 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2231#issuecomment-6082438387). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T14:00:19Z. --- Thanks for running the full Linux/Windows Build workflow for #2208 and confirming your `__inet_ntoa` commit is preserved in this PR. Would you be able to run the same fork workflow against #2231’s exact current head `6923a54e`? Your #2208 run is strong evidence for the shared commit, but this head also integrates the other IPv4 helpers and round-trip tests, so an exact-head run would close the remaining Windows/full-suite gap while the upstream manual Build is pending.
popcoder565 commented 2026-10-09 15:47:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:47:17Z.


Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 6923a54e, merged onto main d70b8998 in one build with 38 other PRs that had no Windows run.

  • This PR's tests pass: guest_strings. None of them reported skipping a case.
  • Full ctest in that build: 519 of 519. That needed local fixes to three other PRs in the batch that don't build or pass on Windows: #1611, #1796 and #1824 (reported there).

No title was run.

🤖 Addressed by Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6084285481 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2231#issuecomment-6084285481). Originally posted by [popcoder565](https://github.com/popcoder565) on 2026-10-09T15:47:17Z. --- Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head `6923a54e`, merged onto `main` d70b8998 in one build with 38 other PRs that had no Windows run. - This PR's tests pass: `guest_strings`. None of them reported skipping a case. - Full ctest in that build: 519 of 519. That needed local fixes to three other PRs in the batch that don't build or pass on Windows: #1611, #1796 and #1824 (reported there). No title was run. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
MarcZX10 commented 2026-10-09 17:34:28 +00:00 (Migrated from github.com)

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


Thanks for running the exact 6923a54e head and recording the Windows results. I added the focused guest_strings pass and the 519/519 batch CTest result to the PR description, with the three unrelated local Windows fixes clearly called out. The full upstream Build and title compatibility are still outstanding, so I have left those limitations explicit.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086002949 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2231#issuecomment-6086002949). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T17:34:28Z. --- Thanks for running the exact `6923a54e` head and recording the Windows results. I added the focused `guest_strings` pass and the 519/519 batch CTest result to the PR description, with the three unrelated local Windows fixes clearly called out. The full upstream Build and title compatibility are still outstanding, so I have left those limitations explicit.
MarcZX10 commented 2026-10-09 17:42:12 +00:00 (Migrated from github.com)

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


Update: #2231 is now rebased onto current main (f8c2f072) at head 863ff49f. The diff remains limited to StringExtensions.cpp and GuestStrings.cpp; Linux guest_strings passes 1/1 and Conventions passes. The Windows 519/519 aggregate evidence was on the pre-rebase head and is labeled that way in the description. Exact-head Windows and the required upstream Build matrix remain outstanding; could an authorized collaborator run the Build on this head?

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086122807 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2231#issuecomment-6086122807). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T17:42:12Z. --- Update: #2231 is now rebased onto current `main` (`f8c2f072`) at head `863ff49f`. The diff remains limited to `StringExtensions.cpp` and `GuestStrings.cpp`; Linux `guest_strings` passes 1/1 and Conventions passes. The Windows 519/519 aggregate evidence was on the pre-rebase head and is labeled that way in the description. Exact-head Windows and the required upstream Build matrix remain outstanding; could an authorized collaborator run the Build on this head?
MarcZX10 commented 2026-10-09 18:30:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T18:30:10Z.


Maintainer decision needed

The exact-head Conventions run 37968104485 fails because the checklist still reports open overlapping PRs. The successful run on the same head does not clear that finding.

The authors of #1848 and #1972 have said they prefer to keep their PRs open until a maintainer chooses which implementation to land. #2208 is also still open. The current #2231 branch contains the three original implementation commits with their authorship, plus round-trip tests. I recommend keeping #2231 as the canonical combined change.

The rebased head 863ff49f is based on current main f8c2f072; Linux guest_strings passes. The 519/519 Windows CTest report is from pre-rebase head 6923a54e, and the full upstream Build/relinker run on the current head is still missing.

Could a maintainer decide whether to keep #2231 or the three individual PRs? After that choice, the overlapping branches and checklist can be updated accurately, then the exact head can receive its required Build run.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086896341 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2231#issuecomment-6086896341). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T18:30:10Z. --- ### Maintainer decision needed The exact-head Conventions run [37968104485](https://github.com/boykopovar/AnyPS5/actions/runs/37968104485) fails because the checklist still reports open overlapping PRs. The successful run on the same head does not clear that finding. The authors of #1848 and #1972 have said they prefer to keep their PRs open until a maintainer chooses which implementation to land. #2208 is also still open. The current #2231 branch contains the three original implementation commits with their authorship, plus round-trip tests. I recommend keeping #2231 as the canonical combined change. The rebased head `863ff49f` is based on current `main` `f8c2f072`; Linux `guest_strings` passes. The 519/519 Windows CTest report is from pre-rebase head `6923a54e`, and the full upstream Build/relinker run on the current head is still missing. Could a maintainer decide whether to keep #2231 or the three individual PRs? After that choice, the overlapping branches and checklist can be updated accurately, then the exact head can receive its required Build run.
oneandonlydean commented 2026-10-09 20:10:33 +00:00 (Migrated from github.com)

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


Closing in favour of #1848, #1972 and #2208: each adds one of these functions with a title stop, and they'll go in in that order. The round-trip test can come as a follow-up once they're in.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6088450607 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2231#issuecomment-6088450607). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-09T20:10:33Z. --- Closing in favour of #1848, #1972 and #2208: each adds one of these functions with a title stop, and they'll go in in that order. The round-trip test can come as a follow-up once they're in.

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