In a payload process on a PS5 (firmware 12.70), jrand48 and mrand48
return the high 32 bits of the new 48-bit state zero-extended to the
64-bit long, as FreeBSD 11.0 does, so a result with bit 31 set comes
back between 0x80000000 and 0xFFFFFFFF. Here they sign-extended it, as
FreeBSD 11.1 and later do with an (int32_t) cast. lrand48 and nrand48
already matched the payload process. The tests now pin its results for
three seeds and the first six mrand48 values after srand48(1), compare
with the host as 32-bit values, and the debt entry records the
measurement.
AI-assisted: yes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Port FreeBSD 11 lib/libc/stdlib/random.c (freebsd-src 4ab2e064): the
additive feedback generator with the default 128-byte TYPE_3 table,
good_rand seeding, state sizes rounded down to 8, 32, 64, 128 or 256
bytes, setstate returning the previous state, and initstate returning
null below 8 bytes without setting errno. Calls are serialised by one
lock; a null state throws.
The import audit of the homebrew catalog on main 262c0316 lists them as
absent libSceLibcInternal imports:
- random: PPSA74126 Stremio Plus, PPSA85300 VLC, PPSA99169 RetroArch,
PPSA99177 PS5VR, PPSA99420 PS5MC, PPSA99505 Jelly5, PPSA99515 Emby5,
PPSA99810 PSBox Cloud Gaming
- srandom: PPSA85300, PPSA99169, PPSA99420, PPSA99810
- initstate, setstate: PPSA99177, PPSA99420, PPSA99505, PPSA99515
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>