feat(libc): implement __inet_addr #1974

Closed
CouchRiv wants to merge 1 commit from upstream-pr/1974 into main
CouchRiv commented 2026-10-09 03:31:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-09T03:31:44Z.


What

Three homebrew apps from the PS5 homebrew catalog stop at load on main f1451396: XashPS5 (PPSA19111 1.3), RetroArch (PPSA99169 1.0.0-beta.1) and Porpoise (PPSA99764 2.7).

/work/runtime/app.elf: symbol lookup error: /work/runtime/app.elf: undefined symbol: 7p7kTAJcuGg

7p7kTAJcuGg is __inet_addr, imported from libSceLibcInternal. FreeBSD's libc exports inet_addr under that name too (__weak_reference(__inet_addr, inet_addr)), and nothing provides it yet. RetroArch and Porpoise were also reported stopping there in #1578.

This adds __inet_addr to libc, following inet_addr and inet_aton in FreeBSD's lib/libc/inet/inet_addr.c:

  • one to four parts, each decimal, octal (leading 0) or hex (0x); the last part fills the remaining bytes, so 127.1 is 127.0.0.1;
  • the input ends at a NUL or a whitespace character;
  • it returns the address in network order, or INADDR_NONE (0xffffffff) for invalid input, so 255.255.255.255 and an error look the same, as on FreeBSD;
  • a single part keeps the low 32 bits of its value (4294967297 gives 0.0.0.1), like FreeBSD. glibc rejects it, so the host's inet_addr is not used.

#1766 added __inet_addr and __inet_ntoa through the host's functions and was closed because no title stopped on them yet; LeandroLP23 later asked to reopen it when RetroArch and Porpoise were seen stopping here. This PR is __inet_addr alone; __inet_ntoa, the next stop, follows in its own PR. #1848 (__inet_aton) follows the same FreeBSD function; the two merge without conflicts.

Tested

CachyOS Linux, GCC 16.2.1, Release, RTX 4070 Ti (NVIDIA 615.71.09) and Radeon 610M (RADV, Mesa 26.2.4):

  • The three apps, relinked from their catalog releases and run headless, get past this import. XashPS5 now stops at -nvxBWa0iDs (gethostname), RetroArch and Porpoise at 6i5aLrxRhG0 (__inet_ntoa).
  • guest_strings has new checks: the four address forms, hex and octal parts, the largest last part of each form, trailing whitespace, 255.255.255.255, and 15 invalid inputs (an empty string, a leading space, five parts, parts out of range, 08, 1..2, letters, trailing garbage, a bare 0x, a trailing dot, a sign).
  • Full ctest passes on both GPUs (497 of 497).
  • tools/check_conventions.py and git diff --check pass.

Not tested on Windows or on a console. The behaviour comes from FreeBSD's source and was not measured on a PS5.

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 (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4795627717 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1974). Originally posted by [CouchRiv](https://github.com/CouchRiv) on 2026-10-09T03:31:44Z. --- ### What Three homebrew apps from the PS5 homebrew catalog stop at load on `main` f1451396: XashPS5 (PPSA19111 1.3), RetroArch (PPSA99169 1.0.0-beta.1) and Porpoise (PPSA99764 2.7). ``` /work/runtime/app.elf: symbol lookup error: /work/runtime/app.elf: undefined symbol: 7p7kTAJcuGg ``` `7p7kTAJcuGg` is `__inet_addr`, imported from `libSceLibcInternal`. FreeBSD's libc exports `inet_addr` under that name too (`__weak_reference(__inet_addr, inet_addr)`), and nothing provides it yet. RetroArch and Porpoise were also reported stopping there in #1578. This adds `__inet_addr` to libc, following `inet_addr` and `inet_aton` in FreeBSD's [`lib/libc/inet/inet_addr.c`](https://github.com/freebsd/freebsd-src/blob/dc36d6f9bb1753f3808552f3afd30eda9a7b206a/lib/libc/inet/inet_addr.c): - one to four parts, each decimal, octal (leading `0`) or hex (`0x`); the last part fills the remaining bytes, so `127.1` is `127.0.0.1`; - the input ends at a NUL or a whitespace character; - it returns the address in network order, or `INADDR_NONE` (`0xffffffff`) for invalid input, so `255.255.255.255` and an error look the same, as on FreeBSD; - a single part keeps the low 32 bits of its value (`4294967297` gives `0.0.0.1`), like FreeBSD. glibc rejects it, so the host's `inet_addr` is not used. #1766 added `__inet_addr` and `__inet_ntoa` through the host's functions and was closed because no title stopped on them yet; LeandroLP23 later asked to reopen it when RetroArch and Porpoise were seen stopping here. This PR is `__inet_addr` alone; `__inet_ntoa`, the next stop, follows in its own PR. #1848 (`__inet_aton`) follows the same FreeBSD function; the two merge without conflicts. ### Tested CachyOS Linux, GCC 16.2.1, Release, RTX 4070 Ti (NVIDIA 615.71.09) and Radeon 610M (RADV, Mesa 26.2.4): - The three apps, relinked from their catalog releases and run headless, get past this import. XashPS5 now stops at `-nvxBWa0iDs` (`gethostname`), RetroArch and Porpoise at `6i5aLrxRhG0` (`__inet_ntoa`). - `guest_strings` has new checks: the four address forms, hex and octal parts, the largest last part of each form, trailing whitespace, `255.255.255.255`, and 15 invalid inputs (an empty string, a leading space, five parts, parts out of range, `08`, `1..2`, letters, trailing garbage, a bare `0x`, a trailing dot, a sign). - Full ctest passes on both GPUs (497 of 497). - `tools/check_conventions.py` and `git diff --check` pass. Not tested on Windows or on a console. The behaviour comes from FreeBSD's source and was not measured on a PS5. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
CouchRiv commented 2026-10-09 03:37:27 +00:00 (Migrated from github.com)

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


Closing as a duplicate of #1972, which was opened first and implements the same __inet_addr. With __inet_addr, RetroArch (PPSA99169) and Porpoise (PPSA99764) move on to __inet_ntoa (6i5aLrxRhG0) and XashPS5 to gethostname; __inet_ntoa will follow in its own PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6073763098 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1974#issuecomment-6073763098). Originally posted by [CouchRiv](https://github.com/CouchRiv) on 2026-10-09T03:37:27Z. --- Closing as a duplicate of #1972, which was opened first and implements the same `__inet_addr`. With `__inet_addr`, RetroArch (PPSA99169) and Porpoise (PPSA99764) move on to `__inet_ntoa` (`6i5aLrxRhG0`) and XashPS5 to `gethostname`; `__inet_ntoa` will follow in its own PR.
github-actions[bot] commented 2026-10-09 03:38:34 +00:00 (Migrated from github.com)

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


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
#1972 core/libs/tests/GuestStrings.cpp L1 __inet_addr_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6073774120 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1974#issuecomment-6073774120). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T03:38:34Z. --- <!-- 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 | |---|---|---|---| | #1972 | `core/libs/tests/GuestStrings.cpp` [L1](https://github.com/boykopovar/AnyPS5/blob/f145139676a48306681d3a4d5fabf83938759daf/core/libs/tests/GuestStrings.cpp#L1) | `__inet_addr_nid_postfix` | |

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