Skip to content

feat(libc): implement __inet_addr - #1972

Merged
adriadam10 merged 2 commits into
boykopovar:mainfrom
babyhuey:feat/libc-inet-addr
Oct 9, 2026
Merged

adriadam10 merged 2 commits into
boykopovar:mainfrom
babyhuey:feat/libc-inet-addr

Conversation

@babyhuey

@babyhuey babyhuey commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

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 f145139 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: feat(libc): implement __inet_aton #1848
  • AI-assisted: yes

@MarcZX10

MarcZX10 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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.

@CouchRiv CouchRiv mentioned this pull request Oct 9, 2026
9 tasks done
@babyhuey

babyhuey commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

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 (6f56497).

@MarcZX10

MarcZX10 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

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

babyhuey commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

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

@babyhuey
babyhuey force-pushed the feat/libc-inet-addr branch from 2b229d4 to 3763277 Compare October 9, 2026 17:31
@MarcZX10

MarcZX10 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

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

MarcZX10 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

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 github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Progress report (e51d4e1 → 128d2e8)

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

✅ 1 implemented
Library Name
libc __inet_addr_nid_postfix

@adriadam10

Copy link
Copy Markdown
Collaborator

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.

@adriadam10
adriadam10 force-pushed the feat/libc-inet-addr branch from a06f701 to 128d2e8 Compare October 9, 2026 22:12
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 9, 2026
@adriadam10
adriadam10 merged commit e66180f into boykopovar:main Oct 9, 2026
6 checks passed
@reyani-dev reyani-dev mentioned this pull request Oct 11, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants