libc: implement guest getenv and store setenv values #2452
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2452
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2452"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@yasaiiko on GitHub · 2026-11-20 12:11 UTC · original
yasaiiko:libc-guest-getenv→main· +178 −0 · 3 files · 1 commits · openSummary
Implements guest
getenvand makessetenvstore its value, as the corrected analysis in #2000 suggests: the imports are missing implementations, not version aliases.init_envseeds a guest-only environment from the entryenvp(entries without=or with an empty name are skipped; the first of duplicate names wins).getenv(smbQukfxYJM) returns the stored value, ornullptr. A null or empty name, or one starting with=, setsEINVAL; a name containing=is looked up by the part before it, as FreeBSD'sgetenvdoes.setenvkeeps its existing argument checks and now stores the value, replacing an existing one only whenoverwriteis nonzero. It still never touches the emulator's host environment.init_enventry clears the guest environment.Both homebrew eboots I checked import
smbQukfxYJM: Syobon Action (PPSA47402, kvaps/syobon-action-ps5 01.001.000) and Apotris (PPSA98513, darkxex/Apotris-PS5 v1.0.0).This supersedes the closed #2007 (bobrass), which took the same approach but was not built or tested.
Fixes the
getenvpart of #2000; the other unresolved symbols listed there are not addressed.Testing
Windows 11 build 26300, Build Tools 2022 clang-cl 19.1.5, Release,
-DKYTY_BUILD_LAUNCHER=OFF.libc_environment_tests(registered withadd_testand inkyty_tests): resolvesinit_env,getenvandsetenvby NID throughInitLibC_1and checks the entry environment, invalid names andEINVAL,overwrite0 and 1, and that a null entry clears the environment.src/libs/libC.cppfrommain: exit 1 (getenvis not registered)http_uri_parse_testsbuilds unchanged.src/libs/libC.cppformatted with clang-format 22.1.3 (the pre-commit hook's version).kyty_emulatorstops before loading on this machine's Intel iGPU (shaderResourceMinLod is not supported, the same check as #2434), so the change is not verified on a running homebrew.AI-assisted: yes (Claude Code)
🤖 Generated with Claude Code
@coderabbitai[bot] on GitHub · 2026-11-20 12:16 UTC · original
No actionable comments were generated in the recent review.
Walkthrough
LibC now stores guest environment variables in a mutex-protected map initialized from
envp.setenvinserts or updates values according to the overwrite argument, andgetenvlooks up values in the guest map. The change registersgetenvas a LibC symbol. A new test executable checks initialization, invalid inputs, overwrite behavior, and clearing the environment. CMake adds the executable to CTest and the aggregate test target.Suggested reviewers:
nmzikChange: Feature
Merge Risk:
Minimal · up to
e03e5This change adds guest getenv and makes setenv store values in a guest-only environment. No merge-blocking risk was identified, and the new tests cover the main behaviors.
Pre-merge checks:
4
#2007, is closed. It is background only and does not supply coding requirements for this pull request. No active directly linked targets remain. Issue#2000appears in …Full details: Title check
Explanation
The title names the main change: guest getenv is implemented and setenv stores values in the libc change. It matches the libC.cpp changes (GuestEnvironment map, getenv registration in InitLibC_1, setenv storing values) and the new test. It is specific and concise.
Full details: Description check
Explanation
The description states that it implements guest getenv and changes setenv to store values, and it lists the init_env seeding, EINVAL handling, overwrite rules, and the libc_environment_tests registration. It matches the changeset in libC.cpp, CMakeLists.txt, and the new test file.
Full details: Linked Issues check
Explanation
The only directly linked issue,
#2007, is closed. It is background only and does not supply coding requirements for this pull request. No active directly linked targets remain. Issue#2000appears in the PR description and objectives, but it is not a linked target here. Because no active coding requirements apply, no requirement-level compliance check is needed.Full details: Out of Scope Changes check
Explanation
All changes relate to the stated purpose: implementing guest getenv and storing setenv values. In src/libs/libC.cpp, the change adds a guest-only environment map, seeds it in init_env from envp, adds getenv (registered in InitLibC_1), and updates setenv to store values with overwrite handling. CMakeLists.txt adds the libc_environment_tests target and its CTest registration. tests/LibCEnvironmentTests.cpp covers these functions. The PR excludes other unresolved
#2000symbols, and the diff does not add them. The summary shows no unrelated changes. The summary was used as evidence; no repository inspection was needed to reach this result.Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
0f0fefa1-09a0-49fe-9e16-d4185fe025c8Reviewing files that changed from the base of the PR and between
a1fc5ae438ande03e5a71e7.CMakeLists.txtsrc/libs/libC.cpptests/LibCEnvironmentTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@zearkreast on GitHub · 2026-11-23 18:31 UTC · original · approved these changes
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.