Skip to content

feat(libc): implement _Atomic_assert and daemon - #4079

Closed
Mouad-Scriptz-0 wants to merge 1 commit into
boykopovar:mainfrom
Mouad-Scriptz-0:feat/libc-remaining-exports
Closed

Mouad-Scriptz-0 wants to merge 1 commit into
boykopovar:mainfrom
Mouad-Scriptz-0:feat/libc-remaining-exports

Conversation

@Mouad-Scriptz-0

Copy link
Copy Markdown
Contributor

What

tools/progress.py lists six libc exports that still throw. Two of them are already implemented by open pull requests (__powidf2 in #2465, collate<wchar_t>::_Getcat in #3990) and two have unknown signatures and no importing title (sceLibcInternalBacktraceForGame, sceLibcInternalHeapErrorReportForGame, which keep their TechnicalDebt entries). This implements the remaining two.

  • std::_Atomic_assert(const char*, const char*) prints the message and location and aborts, as _Assert does; Dinkumware's <atomic> calls it when an atomic's alignment or lock-freedom check fails. It was kept as a throwing dead import of Cyberpunk 2077 (PPSA04029) for the Windows loader.
  • daemon(nochdir, noclose) continues in the calling process: chdir("/") unless nochdir, descriptors 0 to 2 redirected to the null device unless noclose (_open("NUL")/_dup2 on Windows), return 0. FreeBSD's daemon also forks, exits the parent and calls setsid, which a title cannot observe through the call itself; TechnicalDebt records the difference. PPSA85300 (VLC 3.0) imports it and calls it only with its daemon option.

guest_daemon now expects success: it checks the three redirected descriptors against /dev/null (POSIX) and the working directory / after the nochdir == 0 call, restoring its own stdout and stderr in between.

Tested

Fedora 44 (kernel 7.2.8, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON), worktree on main 1342c4b: ctest -R '^guest_': 263 of 277 pass; the 14 failures are the relinker Python tests, which need the relinker binary this build did not include. guest_daemon, guest_math and guest_collate pass. tools/check_conventions.py --base origin/main and git diff --check pass. tools/pr_overlap.py --branch reports no overlap after dropping the two functions above. No title was run. Not tested on Windows.

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

Dinkumware's _Atomic_assert prints the message and location and aborts like
_Assert instead of throwing. daemon continues in the calling process: it
changes to / unless nochdir is set, redirects descriptors 0 to 2 to the null
device unless noclose is set, and returns 0; the fork, parent exit and setsid
of FreeBSD's daemon are not observable through the call itself.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Progress report (325e0a8 → a231130)

📈 System libraries: 86.53% (+0.06%, +2 implemented functions)

✅ 2 implemented
Library Name
libc _ZSt14_Atomic_assertPKcS0__nid_postfix
libc daemon_nid_postfix

@github-actions

github-actions Bot commented Oct 12, 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
#4138 docs/dev/TechnicalDebt.md L658-660

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing: neither function is reached by a title (PPSA85300 only imports daemon, and the _Atomic_assert import has no call sites), so the throw on main already covers them; a daemon that doesn't fork would also point the emulator's own stdout and stderr at the null device. Reopen when a title calls one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants