Skip to content

feat(libkernel): add getdtablesize - #5069

Closed
ErenYeager1836 wants to merge 1 commit into
boykopovar:mainfrom
ErenYeager1836:carry/libkernel-getdtablesize
Closed

ErenYeager1836 wants to merge 1 commit into
boykopovar:mainfrom
ErenYeager1836:carry/libkernel-getdtablesize

Conversation

@ErenYeager1836

Copy link
Copy Markdown
Contributor

What

getdtablesize (NID sZuwaDPATKs, aerolib) is a throwing export. FreeBSD 11.4 makes it system call 89, sys_getdtablesize (sys/kern/kern_descrip.c:338-355): min(lim_cur(RLIMIT_NOFILE), maxfilesperproc). Neither the console's RLIMIT_NOFILE soft limit nor kern.maxfilesperproc is published; getrlimit keeps throwing for RLIMIT_NOFILE for the same reason. Recorded in technical debt.

VLC (PPSA85300) and XPSemu (PPSA97358) import it and call it only from their own closefrom:

void closefrom(int lowfd)
{
    int max = getdtablesize();
    for (int fd = lowfd < 0 ? 0 : lowfd; fd < max; fd++) {
        close(fd);
    }
}

so the value decides how many close calls run. With the export, the unresolved import error is resolved.

Carried from @screamm / David with author attribution preserved.

Tested

  • Windows 11: guest_getrlimit test suite passes.
  • tools/check_conventions.py passes.
  • tools/check_test_registration.py passes.

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 under Silent stubs in their library's technical debt file
  • 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
  • Unblocks: PPSA85300, PPSA97358
  • AI-assisted: no

getdtablesize (sZuwaDPATKs, aerolib) is a throwing export. FreeBSD
11.4 makes it system call 89, sys_getdtablesize
(sys/kern/kern_descrip.c:338-355, freebsd-src
8c639945a44588f6cfdddfb057bb5aad88735da0):
min(lim_cur(RLIMIT_NOFILE), maxfilesperproc); FreeBSD 11.4 has no
lib/libc/gen/getdtablesize.c. Neither the console's RLIMIT_NOFILE soft
limit nor kern.maxfilesperproc is published: shadPS4 443f0224 has no
getdtablesize or RLIMIT_NOFILE (its posix_sysconf table answers
_SC_OPEN_MAX with -1, without a stated source), KytyPS5 4733b7e and
OpenOrbis 0a1aaf9d have neither, fpPS4 04cefd43 returns High(Integer)
as a placeholder, SharpProspero 5dfdb4b0 only binds it. getrlimit
keeps throwing for RLIMIT_NOFILE for the same reason. Recorded in
technical debt.

VLC (PPSA85300) and XPSemu (PPSA97358) import it and call it only from
their own closefrom (ZiZc3/VLC f3253020 and ZiZc3/XPSemu 8eec07b4,
ps5/compat/libc_stubs.c:67-73).
@github-actions

github-actions Bot commented Oct 13, 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
#3870 docs/dev/debt/libkernel.md L165
#4374 core/libs/prx/libkernel/System/src/Process.cpp L541
docs/dev/debt/libkernel.md L165
#4379 docs/dev/debt/libkernel.md L165
#4725 docs/dev/debt/libkernel.md L165
#4796 docs/dev/debt/libkernel.md L165
#4920 docs/dev/debt/libkernel.md L165
#4968 docs/dev/debt/libkernel.md L165
#5061 core/libs/prx/libkernel/System/src/Process.cpp L541
core/libs/tests/GuestGetrlimit.cpp L16, L125
getdtablesize_nid_postfix

@github-actions

Copy link
Copy Markdown

Progress report (c7632f0 → 79fcbf2)

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

✅ 1 implemented
Library Name
libkernel getdtablesize_nid_postfix
⚪ 1 behaviourally empty (constant return or throw)
Library Name
libkernel getdtablesize_nid_postfix

@adriadam10

Copy link
Copy Markdown
Collaborator

Closing as a duplicate: #5061 (opened earlier) adds the same getdtablesize export in the same three files (Process.cpp, GuestGetrlimit.cpp, docs/dev/debt/libkernel.md), and CONTRIBUTING asks that no two open PRs implement the same function. This PR also only adds a throwing body, so it resolves the import but gives no behaviour.

Feel free to reopen if #5061 is closed without merging, or if you add a real implementation backed by a measured value.

@adriadam10 adriadam10 closed this Oct 13, 2026
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.

2 participants