Commit Graph

41 Commits

Author SHA1 Message Date
Adrià ca4ab0d5d6
Merge pull request #3687 from Lorkydey/fix/libc-atoi-guest-width
fix(libc): parse atoi through guest-width strtol
2026-10-11 23:51:52 +02:00
Lorkydey 6744880450 fix(libc): parse atoi through guest-width strtol 2026-10-11 17:20:39 +02:00
DariusHQ 6ef110af48 feat(libc): implement wcstok
PS5MC (PPSA99420) stops at start-up on wcstok once sendfile is in. It
follows FreeBSD's three-argument wcstok over the guest's 16-bit wchar_t:
leading delimiters are skipped, the token ends at the next delimiter,
which is overwritten with 0, and *last is set to null when the string
runs out.
2026-10-11 16:41:50 +03:00
Pouare514 5290f92876 fix(libs): share Sony CRT semantics between libc and libSceAmpr with tests 2026-10-11 11:42:31 +02:00
Adrià 379e5d8795
Merge pull request #3280 from MarcZX100/codex/libc-memset-s-freebsd-3166
fix(libc): follow FreeBSD memset_s errors
2026-10-11 09:18:14 +02:00
Fishybeing 007cc62555 fix(libc): follow FreeBSD's memset_s errors
FreeBSD's memset_s returns EINVAL for every constraint violation and writes nothing when smax or n exceeds RSIZE_MAX. The guest returned ERANGE when n exceeded smax and wrote up to min(n, smax) bytes even when smax or n exceeded RSIZE_MAX.

(cherry picked from commit bf08837cf929e40f1b646df82e140a33076d5587)
2026-10-11 05:05:02 +00:00
MarcZX100 890169e094 feat(libc): implement memrchr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 01:16:53 +02:00
Adrià ecafb64f28
Merge pull request #3083 from MarcZX100/codex/carry-3077-wide-conversions
feat(libc): implement Dinkumware wide conversion exports
2026-10-11 00:01:31 +02:00
David 51fca3cec3 feat(libc): implement _WStoul, _Iswctype and swscanf_s
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 23:44:00 +02:00
David 63cce467e7 fix(libc): stop strtol at a 0x prefix without hex digits on Windows
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-10 23:40:19 +02:00
Achraf Reyani 909158503d feat(libc): implement atol and atoll
Both parse like strtol and strtoll in base 10. The guest long is 64
bits wide on every host, so atol uses strtoll rather than the host
atol, whose long is 32 bits on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 03:25:22 +09:00
Adrià 7f1b6a0b30
Merge pull request #1507 from ArjenS-LA/fix/libc-wcsrtombs
fix(libc): convert wcsrtombs using guest characters
2026-10-10 03:05:55 +02:00
Claude 8c714f76af
fix(libc): stop the wcstol family at a binary prefix on Linux
wcstol, wcstoll, wcstoul and wcstoull parse the ASCII prefix of the
guest's UTF-16 text with std::strtoll and std::strtoull, which glibc 2.38
and later bind to the C23 __isoc23_* functions: wcstol(u"0b101", &end, 0)
returned 5 with the end pointer after the whole string. They now check
StopAtBinaryPrefix_nid_no_patch first, like the narrow functions, and the
end pointer maps back through ParseAsciiPrefix as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 21:26:13 +00:00
Claude b5c9945e1f
fix(libc): stop the strtol family at a binary prefix on Linux
C17 has no binary prefix: with base 0 or 2, strtol("0b101", &end, base)
reads the subject "0", returns 0 and leaves end at the 'b'. With glibc
2.38 or later, g++ (which defines _GNU_SOURCE) binds std::strtoll,
strtoull, strtoul, strtoimax and strtoumax to the C23 __isoc23_*
functions, which accept 0b/0B: the Linux exports returned 5 and
consumed the whole string. The Windows UCRT already follows C17, so the
same guest call gave different results on the two hosts.

strtol, strtoul, strtoll, strtoull, _Stoull, strtoimax, strtoumax and
_Stoul now return 0 with the end pointer after the '0' when, after
white space and an optional sign, the text starts with 0b or 0B and a
binary digit, in base 0 or 2. Everything else still goes to the host
function. The scanf family's %i has the same glibc behaviour; it is
recorded in TechnicalDebt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 21:26:13 +00:00
ArjenS-LA 74e1a6f5c4 fix(libc): convert wcsrtombs using guest characters 2026-10-08 11:32:21 -07:00
Fishybeing 5b0d28392c fix(libc): parse and collate guest wide strings as 16-bit units
wcstod, wcstof, wcstold, wcstol, wcstoll, wcstoul, wcstoull, wcscoll and wcsxfrm still forwarded to the host's wchar_t functions, which use 32-bit units on Linux. The wcsto* functions now parse the ASCII prefix of the guest string with the narrow parsers, as the C locale accepts only ASCII white space and digits. wcscoll compares like wcscmp and wcsxfrm copies, as strcoll and strxfrm do in the C locale.
2026-10-08 10:27:00 +02:00
Fishybeing cd39c8db54 fix(libc): read guest wide strings as 16-bit units
The guest's wchar_t is 16 bits, but wcslen, wcscmp, wcsncmp, wcscpy, wcsncpy, wcschr, wcsrchr, wcsstr, wcspbrk, wcsspn and the wmem functions forwarded to the host's wchar_t functions, which use 32-bit units on Linux. Implement them on char16_t. The wide conversions that still use the host's wchar_t are listed in TechnicalDebt.
2026-10-08 09:39:55 +02:00
Ethan Barr 0653b87497 fix(libc): reject overlapping memcpy_s ranges 2026-10-06 14:26:37 -07:00
Dean 7c0528a8f3
Merge pull request #718 from adriadam10/feat/libc-div
feat(libc): implement div
2026-10-06 08:00:09 +13:00
Adrià Franch afe2b14a84 feat(libc): implement div
Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-05 19:53:39 +02:00
Tomás Ortellado e1bfd03f23 fix(libc): return null when strdup allocation fails 2026-10-05 08:57:56 -03:00
Nicolas Abosch aa08977a59 fix(libc): preserve 64-bit long integer conversions 2026-10-04 23:27:17 -03:00
Pouare514 1c724c0228 feat(libs): Cyberpunk 2077 loading support (REDGalaxy + stubs)
# Conflicts:
#	core/libs/prx/libSceContentExport/Export.cpp
#	core/libs/prx/libScePlayGoDialog/Export.cpp
2026-10-02 23:14:04 +03:00
SamG-Coder 7f834fc415 feat(libc): add C locale conversion and sample runtime exports 2026-10-01 11:58:51 +03:00
Dean Galvin a599eca727 feat(libc): operator new/delete, bounds-checked functions, char locale facets and runtime helpers
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 14:22:48 +13:00
devilismyfriend a503d0b617 Merge remote-tracking branch 'origin/main' into feat/demons-souls-boot
Brings in main up to 9958d26 (homebrew runtime, POSIX wrappers in
libkernel, sce_module guest modules and --skip-sce-module, the --to-intel
general pipeline, libSceRandom, libSceRtc, libScePosixForWebKit,
libRenoirCore, test wiring).

Resolutions where both sides implemented the same thing:
- libkernel pthread: main's structure (lazy static initialisation,
  destroyed markers, MutexOperations/CondOperations, mutex protocol and
  condattr clock) with this branch's TimedWait deadlines and condition
  (precise timed lock/wait on Windows), wait tracing, the adaptive mutex
  type 4, POSIX default ERRORCHECK mutexes, EDEADLK/EPERM results instead
  of throws, and condition clocks honoured for absolute timeouts.
- libc locale: the guest Dinkumware ABI (_Locimp, facet vtables, short
  ctype/case tables, locale ids, stream storage) is kept because guest code
  inlines those layouts; main's C character functions are kept on top.
- libc stdio/strings/math: main's stream functions (guest FILE status
  sync), strerror/perror, remove, formatting, string and math exports win
  over this branch's duplicates.
- libc paths: main's working directory with this branch's path aliases
  resolved on the normalised guest path.
- libkernel file: this branch's sceKernel* results as SCE errors, main's
  POSIX wrappers and both fstat helpers.
- relinker: this branch's stub lowering keeps its trampolines through the
  main executable path; guest modules refuse lowerings that need stubs.
- AGC driver: main's rendering wait is executed by this branch's workers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-27 10:52:21 -07:00
devilismyfriend f3ac61000d feat(runtime): guest arena, kernel thread/sync/file APIs, crash hooks
- libc: reserve guest memory in one arena below the PS5 map limit with
  MEM_WRITE_WATCH (GuestArena) and a caching guest heap; the allocation
  registry gains a generation counter, an invalidator callback for the
  driver's page cache and a pin waiter for leased ranges. This replaces
  the fault-based GuestMemoryTracking/GuestMemoryBacking layer, whose
  files are removed.
- libkernel: mmap/mprotect/munmap on the arena, flexible memory budget,
  real sceKernelVirtualQuery; POSIX pthread layer, rwlocks, timed locks,
  TSD, event flags; 0.5 ms scheduler tick and high-resolution sleeps;
  TSC/clock/time functions; file APIs return SCE errno codes; the APR
  file-streaming API.
- libc: vectored crash reporter with backtraces for fatal exceptions,
  SIGABRT, UCRT invalid parameters and process exit; SSE4a EXTRQ/INSERTQ
  emulation for Intel hosts; %ls/%lc/%S/%C with the guest's 16-bit
  wchar_t; hand-written setjmp/longjmp for the guest jmp_buf; a path
  alias table for short save-data mount points; more string, stdio and
  math exports.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-25 16:27:49 -07:00
SamG-Coder 7d07187ac8 feat(libc): add floating-point string conversions 2026-09-25 06:55:31 +10:00
boykopovar 9f2b41b9a1 fix(libc): route guest allocations through application heap 2026-09-24 06:53:12 +03:00
boykopovar 3028c87491 feat(agc): add bda memory mapping and resource management (wip) 2026-09-21 18:54:06 +03:00
boykopovar b4db9fdd69 chore(sceSysmodule): log unknown module id loading 2026-09-12 18:00:34 +03:00
boykopovar 67b778055a refactor(libs): use local cmakelists in libc 2026-09-11 12:22:19 +03:00
boykopovar abc72da741 feat(libs): define vabi macros + add to declarations 2026-09-10 08:07:03 +03:00
boykopovar 81d7adea95 feat(log): log system detalization 2026-09-08 12:10:49 +03:00
boykopovar bc14e4743c fix(relinker): map zero-flag ps5 load segments as rwx 2026-09-07 10:10:00 +03:00
boykopovar 9d4c87b686 fix(nid): fix updates detections for nid_patcher rerun 2026-09-07 09:55:41 +03:00
boykopovar ec8faf3ed7 feat(libs): add general not implemented helper 2026-09-06 14:11:05 +03:00
boykopovar 4fd128a40d refactor(libc): remove strings.h linux specific 2026-09-06 12:45:37 +03:00
boykopovar 1752e1d78e refactor(libc): separate platform and compiler specifics in libc 2026-09-06 12:41:33 +03:00
boykopovar 271a850022 fix(libs): link std lib only to libc prx 2026-08-24 20:47:53 +03:00
boykopovar 5a1d7525f9 feat(libs): libc impl (wip) 2026-08-22 16:00:29 +03:00