Skip to content

feat(libkernel): export setrlimit - #3980

Merged
adriadam10 merged 3 commits into
boykopovar:mainfrom
MarcZX10:codex/carry-libkernel-setrlimit
Oct 12, 2026
Merged

adriadam10 merged 3 commits into
boykopovar:mainfrom
MarcZX10:codex/carry-libkernel-setrlimit

Conversation

@MarcZX10

Copy link
Copy Markdown
Contributor

What

Implements the unclaimed setrlimit export from #3558. The call validates a null limit before the resource number, maps negative values to RLIM_INFINITY, and clamps a soft limit that exceeds the hard limit, following FreeBSD 11. It returns success when the normalized request matches what getrlimit reports. A change throws because the emulator does not store guest limit state; resources that getrlimit cannot report remain unsupported.

This PR contains only setrlimit. The credential setters and the separate getrlimit work are tracked by their own changes.

Tested

  • Linux x86-64, GCC 12.2.0, Release: built guest_setrlimit_tests; CTest guest_setrlimit passed 1/1.
  • Locally: tools/check_conventions.py --base upstream/main and git diff --check passed.
  • Windows and console hardware were not tested locally.

Checklist

  • Based on current main
  • One topic per PR
  • Unsupported changes throw explicitly
  • No new third-party code
  • AI-assisted: yes

Depends on: none

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Progress report (529f7bf → f89c7fb)

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

✅ 1 implemented
Library Name
libkernel setrlimit_nid_postfix

@babyhuey

Copy link
Copy Markdown
Contributor

I checked this PR on both OSes with XPSemu (PPSA97358) and PS5MC (PPSA99420), catalog builds. With #3580 merged, both stop at setrlimit on main 5aaf26b:

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Conflicts with main in core/libs/prx/libkernel/System/src/Process.cpp and docs/dev/TechnicalDebt.md; please rebase.

@screamm screamm mentioned this pull request Oct 12, 2026
10 tasks done
@MarcZX10
MarcZX10 force-pushed the codex/carry-libkernel-setrlimit branch from d57e7f5 to 1ea062e Compare October 12, 2026 16:14
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@Nixitov

Nixitov commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Build verification on Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release fails on this branch:

core/libs/prx/libkernel/System/src/Process.cpp:322:5: error: 'getrlimit_nid_postfix' was not declared in this scope; did you mean 'setrlimit_nid_postfix'?

setrlimit_nid_postfix calls getrlimit_nid_postfix at line 322, but that function is only defined at line 489 of the same file, with no declaration in scope before the call (no header declares it on this branch either).

A forward declaration before the call fixes it, e.g. in Process.cpp:

extern "C" int APS5_VABI getrlimit_nid_postfix(int resource, GuestResourceLimit* limit);

I could not run the setrlimit titles (PPSA50011, PPSA97358, PPSA99420) against this branch because the library does not build, so the "gets past 4X0QwvuCfjc" evidence is still untested. Happy to re-run once it compiles.

AI-assisted: yes

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@MarcZX10
MarcZX10 force-pushed the codex/carry-libkernel-setrlimit branch 2 times, most recently from ae53466 to fef2251 Compare October 12, 2026 18:47
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 12, 2026
@MarcZX10

Copy link
Copy Markdown
Contributor Author

Thanks for catching this. I confirmed the current head calls getrlimit_nid_postfix before its definition and has no earlier declaration, so the Windows compile failure is valid. We will update the head before asking you to rerun the build or title checks.

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Fixed in commit 2db6f669 with a forward declaration before setrlimit_nid_postfix. On Linux, the guest_setrlimit_tests target builds and ctest -R '^guest_setrlimit$' passes 1/1; git diff --check and tools/check_conventions.py --base origin/main pass. This environment has no MinGW cross-compiler, so I could not reproduce the Windows build locally. @Nixitov, could you confirm the current head builds on Windows and rerun the title checks now that the compile error is fixed?

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Additional validation: I installed Debian MinGW-w64 GCC 12 and cross-compiled the affected Process.cpp as a Windows target (x86_64-w64-mingw32-g++ -std=gnu++20 -fno-asynchronous-unwind-tables, project include paths). The translation unit compiles successfully with the declaration on this head. This is not the repository-supported WinLibs GCC 15.2 toolchain and does not replace a native Windows run; @Nixitov, please still confirm on your supported build and retry the title checks when available.

@adriadam10

Copy link
Copy Markdown
Collaborator

Checked against FreeBSD 11 kern_setrlimit (null limit before resource, negative → infinity, soft clamped to hard), built libkernel and ran guest_setrlimit and guest_getrlimit on Linux (pass). The Windows forward-declaration fix is already on the head.

Added in our own commit: moved the TechnicalDebt line next to the getrlimit one, so it no longer sits at the end of the section where #4651 and #4740 also append.

Not verified here: a native Windows build (@Nixitov's MinGW GCC 15.2 run) and behaviour on the console. Merging once CI is green.

@adriadam10
adriadam10 merged commit 2fabe44 into boykopovar:main Oct 12, 2026
8 checks passed
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.

5 participants