Skip to content

feat(libc): export the C rune locale - #1781

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libc-rune-locale
Oct 10, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libc-rune-locale

Conversation

@babyhuey

@babyhuey babyhuey commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What

Exports the FreeBSD C rune locale from libc: _DefaultRuneLocale (lWGF8NHv880), _CurrentRuneLocale (chlN6g6UbGo) and __mb_sb_limit (fGYLBr2COwA). Titles built against FreeBSD <ctype.h>/<wctype.h> read _CurrentRuneLocale->__runetype[c] inline, bounded by __mb_sb_limit, and fall back to &_DefaultRuneLocale; they import these as libSceLibcInternal data.

  • _RuneLocale follows FreeBSD 11 include/runetype.h, checked with static_asserts: __runetype at 64, __maplower at 2112, __mapupper at 3136, ranges at 4160, 4224 bytes.
  • The C table is generated, not copied. It matches FreeBSD 11 lib/libc/locale/table.c for all 256 __runetype, __maplower and __mapupper entries (compared offline against a parse of that file): ASCII classes, the digit value in the low byte of digits and hex letters, no class above 0x7f, magic RuneMagi, encoding NONE, __invalid_rune 0xFFFD, empty _ext ranges.
  • _CurrentRuneLocale points at _DefaultRuneLocale, and __mb_sb_limit is 256, as in FreeBSD table.c and none.c for the C locale, the only locale setlocale accepts.

Found with tools/import_audit.py on the catalog homebrew titles: _DefaultRuneLocale is absent in 11 of 36 audited titles, _CurrentRuneLocale and __mb_sb_limit in 9.

Tested

Linux (Ubuntu 24.04, GCC 13, Release): new guest_rune_locale and existing guest_locale pass with --repeat until-fail:3. The test reads the export at raw FreeBSD offsets and checks every entry against the existing is*, tolower and toupper exports, the digit values, the header fields and __mb_sb_limit. It fails when the _CTYPE_N bit is dropped from digits. check_conventions.py passes. Windows: both files compile with MinGW-w64 GCC 13 (-Wall -Wextra -fsyntax-only); not run on Windows.

import_audit.py with the patched libraries, absent imports before → after: PPSA19111 66 → 63, PPSA59322 ccleste 50 → 47, PPSA68091 Ruffle 71 → 68, PPSA97510 74 → 71, PPSA98510 74 → 71, PPSA99002 74 → 71, PPSA99010 vkQuake 51 → 48, PPSA99764 80 → 77, PPSA99810 64 → 61. No title run.

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

@popcoder565

Copy link
Copy Markdown
Contributor

Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head 8aa4040b, merged onto main d70b899 in one build with 38 other PRs that had no Windows run.

No title was run.

🤖 Addressed by Claude Code

@babyhuey
babyhuey force-pushed the feat/libc-rune-locale branch 6 times, most recently from fa18211 to 7c876d4 Compare October 10, 2026 04:43
@babyhuey
babyhuey force-pushed the feat/libc-rune-locale branch from 7c876d4 to 64be5f1 Compare October 10, 2026 05:18
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked the NIDs against aerolib, the _CTYPE_* bits and digit/hex values against FreeBSD runetype.h, and the layout asserts. guest_rune_locale passes on Linux and fails to link without the change; popcoder565 also ran it on Windows. Merging.

@adriadam10
adriadam10 merged commit 4a01974 into boykopovar:main Oct 10, 2026
10 checks passed
SleglJan pushed a commit to SleglJan/AnyPS5 that referenced this pull request Oct 10, 2026
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