Skip to content

feat(libc): implement __inet_addr - #1974

Closed
CouchRiv wants to merge 1 commit into
boykopovar:mainfrom
CouchRiv:feat-libc-inet-addr
Closed

CouchRiv wants to merge 1 commit into
boykopovar:mainfrom
CouchRiv:feat-libc-inet-addr

Conversation

@CouchRiv

@CouchRiv CouchRiv commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

What

Three homebrew apps from the PS5 homebrew catalog stop at load on main f145139: 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

Homebrew that links FreeBSD's inet_addr imports __inet_addr from
libSceLibcInternal and fails to load without it. The parser follows
FreeBSD's inet_aton instead of the host's, whose overflow checks
differ, and returns INADDR_NONE for invalid input.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@CouchRiv

CouchRiv commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

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.

@CouchRiv CouchRiv closed this Oct 9, 2026
@github-actions github-actions Bot mentioned this pull request Oct 9, 2026
9 tasks done
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

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

@CouchRiv CouchRiv mentioned this pull request Oct 9, 2026
8 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant