feat(libc): implement __inet_addr #1972

Merged
babyhuey merged 2 commits from upstream-pr/1972 into main 2026-10-09 22:35:34 +00:00
babyhuey commented 2026-10-09 03:27:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-09T03:27:05Z.


What

Implements __inet_addr (7p7kTAJcuGg) in libc on top of __inet_aton from #1848, as FreeBSD lib/libc/inet/inet_addr.c does: the address from __inet_aton in network byte order, or INADDR_NONE (0xFFFFFFFF) when it rejects the text. Titles import it from libSceLibcInternal.

Depends on #1848. Until that merges, this branch also contains its commit.

Why

It is a title's next stop on current main: PPSA19111 XashPS5 stops on it on Linux and Windows.

Title main f1451396 with #1848 and this branch
PPSA19111 XashPS5 (Linux) app.elf: symbol lookup error: app.elf: undefined symbol: 7p7kTAJcuGg undefined symbol: -nvxBWa0iDs (gethostname, #1594)
PPSA19111 XashPS5 (Windows, from an earlier run) FAIL: unresolved ELF import 7p7kTAJcuGg from libSceLibcInternal.prx not run

Tested

Linux (Ubuntu 24.04, GCC 13, Release): guest_strings passes with --repeat until-fail:3. It now checks __inet_addr against every invalid input of the __inet_aton test (INADDR_NONE), the dotted, shortened and hexadecimal forms, 0.0.0.0 and 255.255.255.255, by the byte order of the result. The test fails when the INADDR_NONE fallback is removed. check_conventions.py passes. Windows: StringExtensions.cpp compiles with MinGW-w64 GCC 13 (-Wall -Wextra -fsyntax-only).

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: #1848
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4795595939 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1972). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-09T03:27:05Z. --- ### What Implements `__inet_addr` (`7p7kTAJcuGg`) in libc on top of `__inet_aton` from #1848, as FreeBSD `lib/libc/inet/inet_addr.c` does: the address from `__inet_aton` in network byte order, or `INADDR_NONE` (0xFFFFFFFF) when it rejects the text. Titles import it from `libSceLibcInternal`. Depends on #1848. Until that merges, this branch also contains its commit. ### Why It is a title's next stop on current `main`: PPSA19111 XashPS5 stops on it on Linux and Windows. | Title | `main` f1451396 | with #1848 and this branch | |---|---|---| | PPSA19111 XashPS5 (Linux) | `app.elf: symbol lookup error: app.elf: undefined symbol: 7p7kTAJcuGg` | `undefined symbol: -nvxBWa0iDs` (`gethostname`, #1594) | | PPSA19111 XashPS5 (Windows, from an earlier run) | `FAIL: unresolved ELF import 7p7kTAJcuGg from libSceLibcInternal.prx` | not run | ### Tested Linux (Ubuntu 24.04, GCC 13, Release): `guest_strings` passes with `--repeat until-fail:3`. It now checks `__inet_addr` against every invalid input of the `__inet_aton` test (`INADDR_NONE`), the dotted, shortened and hexadecimal forms, `0.0.0.0` and `255.255.255.255`, by the byte order of the result. The test fails when the `INADDR_NONE` fallback is removed. `check_conventions.py` passes. Windows: `StringExtensions.cpp` compiles with MinGW-w64 GCC 13 (`-Wall -Wextra -fsyntax-only`). ### 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: #1848 - [x] AI-assisted: yes
MarcZX10 commented 2026-10-09 03:35:06 +00:00 (Migrated from github.com)

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


Correction to my earlier note: I verified the pinned FreeBSD inet_aton source. On amd64, one-part values above 32 bits are accepted and reduced by htonl; accumulation wraps in u_long. Therefore 4294967296 and 18446744073709551617 should not be asserted as INADDR_NONE for this FreeBSD-compatible wrapper. Please disregard that requested test change. Sorry for the incorrect note.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6073739920 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1972#issuecomment-6073739920). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T03:35:06Z. --- Correction to my earlier note: I verified the pinned FreeBSD `inet_aton` source. On amd64, one-part values above 32 bits are accepted and reduced by `htonl`; accumulation wraps in `u_long`. Therefore `4294967296` and `18446744073709551617` should not be asserted as `INADDR_NONE` for this FreeBSD-compatible wrapper. Please disregard that requested test change. Sorry for the incorrect note.
babyhuey commented 2026-10-09 03:42:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-09T03:42:46Z.


Since you withdrew that request on #1848 after checking FreeBSD inet_aton (one-part form unchecked, u_long accumulation wraps), INADDR_NONE would be wrong here: FreeBSD inet_addr returns whatever inet_aton accepted. I added assertions for the FreeBSD results instead, so this wrapper stays tied to #1848's behaviour: 4294967296 gives 0.0.0.0 and 18446744073709551617 gives 0.0.0.1 (6f564976).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6073814212 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1972#issuecomment-6073814212). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-09T03:42:46Z. --- Since you withdrew that request on #1848 after checking FreeBSD `inet_aton` (one-part form unchecked, `u_long` accumulation wraps), `INADDR_NONE` would be wrong here: FreeBSD `inet_addr` returns whatever `inet_aton` accepted. I added assertions for the FreeBSD results instead, so this wrapper stays tied to #1848's behaviour: `4294967296` gives `0.0.0.0` and `18446744073709551617` gives `0.0.0.1` (6f564976).
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:6080978731 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1972#issuecomment-6080978731). 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.
babyhuey commented 2026-10-09 13:59:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-09T13:59:06Z.


Leaving #1972 open until a maintainer chooses between the two shapes; I'll close it if #2231 merges.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6082416704 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1972#issuecomment-6082416704). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-09T13:59:06Z. --- Leaving #1972 open until a maintainer chooses between the two shapes; I'll close it if #2231 merges.
MarcZX10 commented 2026-10-09 17:36:33 +00:00 (Migrated from github.com)

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


I still consider my #2231 the better canonical merge target for this IPv4 helper family: it carries your __inet_addr contribution alongside __inet_aton and __inet_ntoa, and adds cross-function round-trip coverage. Your authorship is retained in its commit history.

The exact #2231 head 6923a54e now has a Windows guest_strings pass with no skipped cases. The accompanying 519/519 CTest result came from an aggregate build that needed local fixes to unrelated #1611, #1796, and #1824, so the required unmodified upstream Build is still pending. Please leave #1972 open until a maintainer decides whether to land the cohesive IPv4 change as one PR; I won't treat the aggregate run as the official Build.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6086035985 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1972#issuecomment-6086035985). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T17:36:33Z. --- I still consider my **#2231 the better canonical merge target** for this IPv4 helper family: it carries your `__inet_addr` contribution alongside `__inet_aton` and `__inet_ntoa`, and adds cross-function round-trip coverage. Your authorship is retained in its commit history. The exact #2231 head `6923a54e` now has a Windows `guest_strings` pass with no skipped cases. The accompanying 519/519 CTest result came from an aggregate build that needed local fixes to unrelated #1611, #1796, and #1824, so the required unmodified upstream Build is still pending. Please leave #1972 open until a maintainer decides whether to land the cohesive IPv4 change as one PR; I won't treat the aggregate run as the official Build.
MarcZX10 commented 2026-10-09 17:42:15 +00:00 (Migrated from github.com)

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


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:6086123571 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1972#issuecomment-6086123571). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-09T17:42:15Z. --- 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.
github-actions[bot] commented 2026-10-09 22:09:29 +00:00 (Migrated from github.com)

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


Progress report (e51d4e1 → 128d2e8)

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

✅ 1 implemented
Library Name
libc __inet_addr_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090081469 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1972#issuecomment-6090081469). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T22:09:29Z. --- <!-- progress-report --> ### Progress report (e51d4e1 → 128d2e8) ➖ **System libraries**: 85.62% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `__inet_addr_nid_postfix` | </details>
adriadam10 commented 2026-10-09 22:12:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:12:13Z.


Rebased onto current main (#1848 is merged, so its commit drops out; no conflicts in your two commits). Checked __inet_addr against FreeBSD lib/libc/inet/inet_addr.c (inet_aton result or INADDR_NONE, one-part form wrapping as on amd64); full build and ctest 544/544 pass on Linux, and guest_strings fails to link without the change. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6090113818 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1972#issuecomment-6090113818). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-09T22:12:13Z. --- Rebased onto current `main` (#1848 is merged, so its commit drops out; no conflicts in your two commits). Checked `__inet_addr` against FreeBSD `lib/libc/inet/inet_addr.c` (`inet_aton` result or `INADDR_NONE`, one-part form wrapping as on amd64); full build and ctest 544/544 pass on Linux, and `guest_strings` fails to link without the change. Merging.
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!1972
No description provided.