Commit Graph
2402 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5 f9bd5682db libkirk: let C++ callers include its headers directly
kirk_engine.h and amctrl.h guard their declarations, but AES.h and SHA1.h
never did, and kirk_engine.h includes them from outside its own guard. So the
AES_* and SHA1* functions got C++ linkage in any C++ file that reached them
through there, and only linked for callers that happened to wrap the whole
header in an extern "C" of their own. Nothing had called AES_* from C++
before, so it stayed hidden until something did.

Guarding the two headers instead lets every caller include them plainly, and
the wrappers scattered around the tree come out. Both are pure declarations
over kirk_common.h's typedefs with no system headers behind them, so there's
nothing in there that shouldn't be wrapped.

kirk_engine.h also uses size_t without including anything that defines it,
which only held together because its includers happened to have it already.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 11:15:15 -06:00
Katharine Chui 2731918f05 cleanup aemu_postoffice building in cmake project files 2026-09-06 14:09:33 +02:00
Henrik Rydgård a15e654f11 naett: Don't hand a closing response to backends that can't see its request
naettClose cleared res->request and then asked the backend to close the
response - but the request is what a backend needs to do that. On Windows it
owns the WinHTTP handles, so the close had nothing to work with, which is part
of why it did nothing at all. Backend first, then clear.

With that in place, the Windows close unhooks the status callback and shuts the
request handle, so a completion raised later can't write through the response
after it's freed. It stops short of a full cancel: a callback already running on
another thread isn't waited for, which needs the HANDLE_CLOSING handshake.

On Apple, invalidateAndCancel returns before the session has finished with its
delegate, so clear the delegate's pointer back to the response first and have
didReceiveData check it, the way didCompleteWithError already did.

Android is still the only backend that genuinely cancels and waits, so naett.h
now says a response should be complete before it's closed rather than leaving
that to be discovered.
2026-09-05 12:07:03 -06:00
Henrik Rydgård da2f30ad46 naett: Stop leaving threads attached to the JVM, and check JNI results
getEnv called AttachCurrentThread and nothing detached. processRequest gets away
with it by detaching its own thread at the end, but naettPlatformInitRequest and
naettPlatformFreeRequest run on whatever thread the caller is using - and a
thread that exits while still attached takes the process down on Android, with
"Native thread exiting without having called DetachCurrentThread". They now
attach only when the thread isn't already, and detach on the way out.

pthread_create's result was ignored. Without a worker nothing ever sets
res->complete, so the caller polls naettComplete forever.

getOutputStream throws for anything from a refused connection onwards, and the
calls after it ran with that exception still pending, which most of JNI doesn't
allow. GetMethodID also returns NULL for a method it can't find, and calling
with a NULL jmethodID aborts the VM - so the call helpers check. Same for a
header whose value list is empty, which handed GetStringUTFChars a null.

Checked with the NDK's clang; the other backends were syntax-checked the same
way, against stub headers.
2026-09-05 12:04:31 -06:00
Henrik Rydgård 60919a2ba9 naett: Fix the curl worker's pipe read, queueing and handle cleanup
The worker reads a queued CURL* out of a pipe eight bytes at a time, tracking
how much it has so far - but it always read into the start of the buffer rather
than at that offset. A short read would have resumed mid-pointer and eventually
handed curl_multi_add_handle a spliced pointer. It never bit because a write
that size to a pipe is atomic, so reads are all-or-nothing, but the code is
written as though it isn't.

The write that queues the request was unchecked. If it ever failed, the request
was never run and never completed, and the caller sits in naettComplete
forever. It reports the failure now, and retries on EINTR.

curl wants an easy handle out of its multi before cleanup; that needs
curl_multi_remove_handle, which meant adding it - and curl_multi_cleanup, for
the init failure paths that leaked the multi handle and the pipe - to the dlopen
table.

workerRunning is written by the worker and read by the request path, so it's an
atomic rather than a plain int. And the read/write callbacks passed the body
callbacks' int return straight back to curl, which takes a size_t: a negative
came through as an enormous count rather than the error it was.
2026-09-05 12:02:22 -06:00
Henrik Rydgård 0e9397b8b4 naett: Harden the WinHTTP backend's header and read paths
WinHttpQueryHeaders only writes the size it needs when it fails with
ERROR_INSUFFICIENT_BUFFER. Any other failure left bufSize at zero, so we
allocated nothing and unpackHeaders walked wcslen over it looking for the
double-null that terminates the list. Check the size, check the second query,
and allocate zeroed with room for a terminator.

winToUTF8, winFromUTF8 and wcsndup can all return NULL - on a failed conversion
or a failed allocation - and not one caller checked. packHeaders is the one that
mattered: its result goes straight into headers[0].

res->bytesLeft is a size_t counting down from what WinHTTP announced. If a read
ever returned more than that, it wrapped to an enormous count and the loop kept
reading.
2026-09-05 11:55:59 -06:00
Henrik Rydgård cb2de6317c naett: Fix the Apple backend's unregistered class and stack-sized headers
createDelegate built its NSURLSessionDataDelegate with objc_allocateClassPair
and then sent it +alloc without ever calling objc_registerClassPair. The runtime
requires registration before a class pair can be used; everything up to then is
still being assembled. Register it, after the methods and the ivar go on.

The response header arrays were VLAs sized from the count the server sent, so a
response with enough headers walked the stack off the end, and one with no
headers at all declared zero-length VLAs, which is undefined by itself. Heap
now, and skipped when there's nothing to read.

The NSURLSession was also kept in the response without retaining it, while the
autorelease pool it came from is drained on the way out of the function. It only
survived because a session keeps itself alive while it has tasks running. Retain
it, release it when the response closes.

Finally, addMethod/addIvar signalled failure with assert alone, which is
compiled out in release - a delegate missing its methods would just never
receive data and the request would hang with nothing logged.
2026-09-05 11:54:49 -06:00
Henrik Rydgård 28962036ef naett: Fix two leaks and the response buffer's overflow
naettFree frees the method and url it strdup'd but never the user agent, which
stringSetter allocates exactly the same way. We set a user agent on every
request, so that leaked on every one of them, on all platforms.

On Linux, headerCallback strndup's each header line and only hands it to the
header list when it finds a colon - the status line and the blank line that ends
the block don't have one, so it leaked those every response, and again per hop
when following redirects.

defaultBodyWriter grew its capacity by doubling an int until the new data fit.
Both the length and the resulting capacity come from the response, so that's
signed overflow on a large one, and a negative capacity then reaches realloc as
a huge size_t. It also assigned the realloc result straight over the old
pointer, so a failed allocation lost the buffer and the memcpy below went
through NULL. Grow in int64_t, cap at INT_MAX, and report failure by returning
short - which is what every caller already checks for.
2026-09-05 11:53:32 -06:00
Henrik Rydgård a0873e5b0e Enable HTTPS on Linux, through naett's libcurl backend
naett has had a complete libcurl backend all along; we just never built it,
so Linux ran with HTTPS_NOT_AVAILABLE. That means no homebrew store over
HTTPS, and RetroAchievements talking to plain http://retroachievements.org.

libcurl is loaded with dlopen rather than linked, the same way we handle the
Vulkan loader, so it stays a soft dependency: we need the curl headers at
build time, but a build made here still starts on a machine without libcurl
installed - it just reports HTTPS as unavailable, exactly like today. Distro
packagers get the behavior they'd expect either way, and certificate
validation comes free from the system CA store.

New net::HTTPSAvailable() answers "did that work", and SDLMain folds it into
SYSPROP_SUPPORTS_HTTPS, which everything downstream already degrades on.

Four fixes to the backend itself, all noted in ext/naett/README-ppsspp.md:

- panic() called exit(1) on a pipe or curl_multi_perform failure. Taking the
  emulator down because a download failed isn't acceptable - the backend now
  disables itself and requests complete with naettGenericError.
- CURLINFO_RESPONSE_CODE writes a long into res->code, which is an int. Eight
  bytes into four, getting away with it only because the next field absorbs
  the zeroes.
- curl_easy_setopt is varargs and wants a long for these options; int literals
  and int variables are UB on LP64.
- naettPlatformCloseResponse called through a null function pointer when
  libcurl was missing. Found by testing that path, which segfaulted.

CI needs libcurl4-openssl-dev (curl-dev on Alpine) or it would quietly keep
building without HTTPS.
2026-09-02 17:42:04 +02:00
Henrik Rydgård 2096df52f5 Vendor naett in-tree, de-amalgamated
naett has been a submodule pinned at v0.3.3; upstream has had no commits since
April 2024, and we want to carry local changes (next up: a libcurl-backed HTTPS
path for Linux). It's ~1500 lines of MIT C, smaller than several things we
already vendor, so bring it in-tree and drop the submodule.

Also drop the generated single-file amalgam (naett.c) that every build system
was compiling, and build src/*.c directly instead - otherwise the file you edit
isn't the file that gets compiled, which is a trap for anyone patching this.
example/ and testrig/ (a whole Android Studio project) are gone with it.

Two changes were needed to make the sources build on their own, both noted in
ext/naett/README-ppsspp.md along with the upstream commit:

- naett_internal.h now includes naett.h, which the amalgam pulled in first.
- naett_linux.c now includes stdio.h/stdlib.h. It calls exit/calloc/realloc/
  free/fprintf without ever including either, and only got away with it because
  naett_core.c sat above it in the concatenation.

No functional change - Linux still has HTTPS_NOT_AVAILABLE set, so it doesn't
build naett at all yet.

Rename naett to naett-lib
2026-09-02 17:35:14 +02:00
Henrik Rydgård 5cffcd34ad Get rid of the confusing old USING_WIN_UI define. Make a more clear system property for headless. 2026-08-16 12:19:41 +02:00
Henrik Rydgård 2d0e54f422 Headless (and main): Improve crash reporting 2026-08-11 22:36:47 +02:00
Henrik Rydgård 22ac7ad119 MemFault: move RISC-V and LoongArch fault analysis out of HandleFault
The RISC-V branch had its instruction-decode logic (including a locally
defined info struct) written directly inline in HandleFault(), unlike
the other three architectures which each delegate to a dedicated
AnalyzeLoadStore function in their disassembler file. Move it into
ext/riscv-disas.h/.cpp as RiscVAnalyzeLoadStore, matching the existing
X86AnalyzeMOV/Arm64AnalyzeLoadStore/ArmAnalyzeLoadStore pattern.
2026-08-11 22:36:47 +02:00
Henrik Rydgård ebc151f8f2 Warning fixes 2026-08-11 22:36:47 +02:00
Thomas Lamb bf67ed300d Fix assembly/disassembly for various VFPU opcodes
Update armips for VFPU instruction parsing changes (Kingcom/armips#257)
- fix transposed matrix register encodings (e.g. `vmidt.p E220` was assembling to `vmidt.p E202`)
- fix immediate size for `vwbn.s` (is 8 bits, was limited to 5 bits)
- fix `vd` register size for `vsocp.s/p`
- fix `vhtfm2.p` and `vhtfm3.t` encoding
- add missing instruction `vhtfm4.q`

Fix `v(h)tfmX` disassembly (handle irregular vector size encoding)

Fix `vsocp.s/p` disassembly (`vd` is double the size of `vs`)
2026-08-11 10:10:56 -04:00
Henrik Rydgård 8d2c1e7a66 Make the ImDebugger a bit less crash prone outside of games 2026-08-07 22:40:05 +02:00
Henrik Rydgård 25a146a11c Make the PPSSPP UI fit inside the imgui desktop 2026-08-07 17:56:09 +02:00
Henrik Rydgård 9c8a4035ef Buildfix, restore lost check 2026-08-07 11:27:45 +02:00
Henrik Rydgård da567f6a89 Discord cleanup 2026-08-07 08:49:29 +02:00
Katharine Chui c46c47522a bump aemu_postoffice
- check for remote disconnect during adhoc 'can send?' poll
- cleanup some compile time warnings
2026-07-26 14:43:00 +02:00
Henrik RydgårdandClaude Sonnet 5 e8f85f7804 Fix missing zstd include/link deps in Common and basis_universal
Common and basis_universal call zstd functions directly but never
declared the dependency after being split into their own
CMakeLists.txt files, relying on directory-scope include_directories()
that no longer reached them. Worked on Linux via system zstd.h, but
broke the Android NDK build which has no such fallback.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XMv4XdM5dThs9Avr5FPXRv
2026-07-24 20:49:29 +02:00
Henrik RydgårdandClaude Sonnet 5 bb6164e799 Move ten inline vendor libraries out of root CMakeLists.txt into ext/
gason, vma, cityhash, 7zip (ext/lzma-sdk), basis_universal, pugixml,
kirk (ext/libkirk), sfmt19937, xbrz, and xxhash were each defined with
a small add_library() block directly in the root CMakeLists.txt, even
though ext/CMakeLists.txt already exists and handles every other vendor
library (freetype, imgui, naett, discord-rpc, libchdr, zstd, miniupnp,
armips, glew, snappy, ...) via add_subdirectory(). Gave each one its
own ext/<name>/CMakeLists.txt to match that established pattern; xxhash
stays a loose file pair in ext/ (it never had its own directory) so its
add_library() lives directly in ext/CMakeLists.txt instead.

ext/libkirk/CMakeLists.txt already existed but was dead - nothing
add_subdirectory()'d it, and its source list was stale (missing
amctrl.c/.h, which the live inline definition in root had). Replaced
its contents with the current, correct list instead of leaving two
diverging definitions around.

Dropped several target_include_directories()/include_directories()
calls that came along with these (e.g. cityhash, kirk, xbrz, xxhash,
and the lzma-sdk one for 7zip): traced their actual consumers and found
each library's own sources resolve their sibling headers via the
default same-directory quote-include rule, and every external consumer
already uses the full "ext/<name>/..." path resolved through the global
root include - so these were dead weight regardless of position.

Replaced two single-value alias variables (LIB7ZIP_LIBRARY, always
"7zip"; BASISU_LIBRARIES, always "basis_universal") with their target
names directly in Common/CMakeLists.txt, rather than trying to carry
them across the new add_subdirectory boundary - plain set() variables
don't propagate back up out of a child scope without PARENT_SCOPE, so
keeping them as-was would have silently broken Common's link line.

Verified with a fully clean rebuild (removed build/ entirely), a
HEADLESS=ON UNITTEST=ON build, and a LIBRETRO=ON build.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PSNaZnHCjmryS3ziVN9gZU
2026-07-24 20:16:07 +02:00
Katharine Chui 01849c251e use new aemu_postoffice apis during polling 2026-07-19 11:30:27 +02:00
Katharine Chui ff83e8c896 bump aemu_postoffice
- Make GetPdpStat behave more like in P2P mode
  - Now fetches accumulated ready to be received amount of data
    instead of only the immediate to be received Pdp block
- Make GetPtpStat behave more like in P2P mode
  - Now fetches accumulated ready to be received amount of data
    instead of the size of the next server send block
- Make PtpRecv behave more like in P2P mode
  - Fix block like behavior where whole server send block has
    to be consumed before getting data from the next send block
  - Fix block like bahavior where sender sends in small PtpSend
    calls while receiver receive with less frequent but bigger
    buffer PtpRecv causes bloat(and eventually server kick)
    on relay
2026-07-19 11:30:27 +02:00
Thomas Lamb d1656d425a Improve debugger assemble/disassemble compatiblity
Update armips for VFPU instruction parsing changes:
- Kingcom/armips#255
- Kingcom/armips#256

Remove brackets from VFPU instruction `vpfx*` params

Rename VFPU instruction `vuc2i.s` to `vuc2ifs.s`

Add brackets to VFPU instruction `vpfxd` saturation operations (i.e. [0:1] & [-1:1])

Rename FPU instructions `c.$OP` to `c.$OP.s`

Fix VFPU instruction `vuc2ifs.s` `vd` size in disassembly

Replace `CC[imm3]` with `imm3` in VFPU instructions `vcmov*` & `bv*` disassembly
2026-07-07 20:30:51 -04:00
Henrik Rydgård a6325cecef Bump rcheevos to latest develop 2026-07-01 22:39:53 +02:00
Henrik Rydgård 8b0ddf88fe Qt buildfix, gitignore in ext 2026-06-16 11:49:40 +02:00
Henrik Rydgård 1e62cb7fc1 Finish the SDL3 port on Mac, update CI to 26.04 2026-06-16 11:39:57 +02:00
Henrik Rydgård ea8a648737 Refactor UI shader presets, prepare for some updates to the ImGe debugger 2026-06-14 11:08:56 +02:00
Henrik Rydgård 054a10d46b Fix imgui being upside down on some backends.
Fixes #21761
2026-06-01 10:53:41 +02:00
Kevin Reinholz bc2648edb1 Add experimental cmake port of ppsspp-ffmpeg as a standard module built from source 2026-05-29 19:06:04 -07:00
Henrik Rydgård 6f0a16a4a4 Fix Y flip 2026-05-18 14:14:25 +02:00
Henrik Rydgård 074beaa0f8 Bump rcheevos again 2026-05-13 18:41:21 +02:00
Henrik Rydgård 09d58584ed Bump rcheevos to latest 2026-05-01 12:12:48 +02:00
Henrik Rydgård fd7c5cdd6b Add pugixml dependency 2026-04-16 12:12:12 -06:00
Katharine Chui 8b95d96516 bump aemu_postoffice
- Take steps to avoid SIGPIPE being generated on unix platforms
2026-04-16 14:17:21 +02:00
Kevin Reinholz 4a5dd4caa6 Fix build with system rapidjson. Attempt to break out the lib7zip support--this fixes build on amd64 FreeBSD 2026-04-09 16:44:45 -07:00
Henrik Rydgård 5c082f8a2a Merge pull request #21499 from lrzlin/loong-handler
loongarch: Implement excepetion handler and JIT bug fix
2026-03-30 11:12:15 -06:00
Lin Runze 53338cf029 loongarch: Implement excepetion handler and JIT bug fix 2026-03-30 18:35:54 +08:00
Henrik Rydgård 116c31e7d9 Add the LZMA sdk 2026-03-27 14:34:15 -06:00
Kevin Reinholz d404040b21 Merge branch 'master' into master 2026-03-13 19:00:00 -07:00
Henrik Rydgård ce393a180b Update aemu_postoffice with the latest fixes. 2026-03-12 17:43:26 +01:00
Henrik Rydgård dcd4851171 CMakeLists.txt: Try to make sure freetype doesn't try to build in its source dir. May fix the next release on flathub. 2026-03-11 11:05:33 +01:00
Kevin Reinholz f020bcdd75 Create option to build with system freetype, libchdr, and rapidjson instead of bundled modules. Add a couple of FreeBSD-specific tweaks to CMakeLists.txt while at it 2026-03-10 18:03:06 -07:00
Katharine Chui 20424bc5bc Handle adhoc relay conection a bit better
- bump aemu_postoffice
  - timeout TCP connection attempts at 5s to not block the library user too much
  - set send and receive buffer sizes after connection to avoid some blocking cases on some platforms with small defaults (windows?)
- pop OSD message when relay connection fails
2026-03-05 19:09:51 +01:00
Henrik Rydgård c74e21243d Add support for installing plugins directly from zip files 2026-02-25 14:28:57 +01:00
Henrik Rydgård a3878c2148 Update libchdr to latest 2026-02-24 00:56:45 +01:00
Henrik Rydgård 5a5c7028b9 Assorted warning fixes and data initialization to please valgrind 2026-02-19 11:24:46 +01:00
Henrik Rydgård 72640514b5 Update rcheevos to v12.3.0 2026-02-18 09:56:46 +01:00
Katharine Chui e0f757c79d bump aemu_postoffice
Improve nonblock relay recv operation responsiveness, it helped a
few games on PSP get back to full speed during multiplayer, might
help severely underpowered devices on PPSSPP as well.
2026-02-16 15:15:21 +01:00