Commit Graph

11 Commits

Author SHA1 Message Date
fdfawef324 58669dc134 fix(libc): write each log line in one call
mingw's fprintf writes an unbuffered stream a character at a time and
holds the stream's lock for the whole line. The APS5_LOG_* lines that
carry a RecompileRequest ("Shader ... could not be prepared after
registration", 15-20 KB each) took one WriteFile per character, and every
other thread writing to stderr waited behind them, guest calls that log
included. Demon's Souls (PPSA01342 v1.005, Windows) stops on a black
screen after two frames on main: a BPE job worker waits for the stderr
lock in sceSaveDataDirNameSearch's trace while the shader preparation
pool prints its dumps, so GameCoreLoop never finishes a frame.

The log macros now format the line into memory and write it with one
fwrite, as Driver::reportSkip does since 8cf2f6580. The UCRT writes an
unbuffered stream's fwrite as one even-length block and the last byte,
so a line takes at most two writes on Windows and one on Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 13:23:21 -04:00
DariusHQ cf1545d751 feat(libkernel): implement getcontext, setcontext and makecontext
PSXS5, SwanStationPS5 and Nuvio stop at start-up on setcontext on main,
and EVO Player and ProsperoStore do on Windows. The three are imported
by the statically linked OpenSSL's ASYNC code.

The three use FreeBSD 11's amd64 ucontext_t (mcontext at 0x10, mc_len
800, uc_link at 0x330, 0x370 bytes), which the titles are built
against: EVO Player's ASYNC_is_capable captures into a 0x370-byte stack
buffer, and async_fibre_makecontext sets uc_link at 0x330 and uc_stack
at 0x338. getcontext saves every register at its call in assembly and
stores the context as FreeBSD's sys_getcontext does: rax and rdx as 0,
the carry flag clear, the FXSAVE image and the signal mask, and nothing
from uc_link on. setcontext checks mc_len and mc_flags as set_mcontext
does, installs the signal mask, masks MXCSR with the host's MXCSR_MASK
and returns through iretq, so every general register and the flags are
restored and nothing is written below the target stack pointer.
makecontext follows FreeBSD 11's amd64 libc.

Windows checks guard-page growth and exception unwinding against the
stack bounds in the TEB. setcontext and longjmp now set them to the
stack they switch to, which makecontext registers and pins writable as
libSceFiber does for fiber stacks. OpenSSL enters a context with
setcontext and then switches with _setjmp and _longjmp.
2026-10-11 13:00:38 +03:00
Zheorgyan eec5c18279 fix(libc): define APS5_LOG_OUT_DEBUG when APS5_DEBUG_LOG is set 2026-10-09 13:42:51 +02:00
boykopovar 94c443e32f refactor(agc): make frame timing logs optional by cmake option 2026-09-28 10:51:29 +03:00
boykopovar 65c6214a68 fix(agc): validate rect-list addressing model + logs refactor 2026-09-23 21:26:21 +03:00
boykopovar 8e95b27583 chore(cmake): add cmake option -DAPS5_AGC_CREATE_LOG 2026-09-13 17:44:17 +03:00
boykopovar 36c29c9a66 feat(libs): sysv abi macros for windows exports 2026-09-10 13:30:05 +03:00
boykopovar 74de895ac0 feat(libs): add new libSceAgc unknown functions 2026-09-10 09:43:59 +03:00
boykopovar 8400150f80 feat(libs): add new declarations to libSceAgc 2026-09-10 09:09:08 +03:00
boykopovar 411a4d00a5 feat(libs): add change export name macros 2026-09-10 08:22:39 +03:00
boykopovar abc72da741 feat(libs): define vabi macros + add to declarations 2026-09-10 08:07:03 +03:00