* samples/database: include compat/strl.h in the scan test
The test calls strlcpy(), which mingw-w64 does not declare, so it did
not build for Windows.
* PS1 scan: PSX.EXE means no serial only as the BOOT target
A root directory can list a PSX.EXE ahead of the executable SYSTEM.CNF
boots: Tomb Raider (USA) lists one before SLUS_001.52. Stopping at the
first PSX.EXE in the probe window sent such discs to a whole-track CRC,
eight seconds for a CHD. Look for the BOOT target first, matched without
regard to case so cdrom:\psx.exe counts. A disc that boots PSX.EXE, or
has no SYSTEM.CNF so the BIOS boots PSX.EXE, has no serial and still
falls back to its CRC (#15241); any other disc is searched for its
serial with PSX.EXE directory records ignored.
* 3DS scan: identify .3ds, .cci and .cxi by the NCCH product code
These images took the default whole-file CRC, 0.5-4 GB a game. The
product code in the NCCH header (partition 0 of a cart image, or the
start of a bare NCCH) is the serial the 3DS database is keyed on, and
the header is plaintext in encrypted dumps too. A code held by one
record matches it outright. Revisions and regions that share a code fall
back to the file's CRC to choose, and to the first record when no CRC
matches; with scan_serial_and_crc on every match is confirmed by CRC, as
for PSP and Dreamcast, and a file none of whose records carry its CRC
goes on to the plain CRC lookup with the CRC already computed. A code no
record carries, or a header without valid magic such as a CIA, keeps the
CRC path, in first-match mode too. Like the CRC lookup, the serial pass
visits only databases an installed core claims the extension for, unless
Scan Without Core Match is on.
* scan: run ITERATE steps while the shared I/O window lasts
A file takes about twenty ITERATE steps, and the handler ran one per
call. On the regular task queue that is one step per frame: 1000 NES
zips took 335 s of pacing, 400 arcade sets 1639 s. The ITERATE states
now run in a loop under the same window the BEGIN states use, which
times the steps rather than counting them and grants every call at least
one. The scan test's unclaimed-database lane spends the window before
each check, so that it still counts steps.
* scan: hash file CRCs a quantum at a time across steps
A step that needed a CRC computed all of it in one handler call: a whole
CHD track with LZMA decode, or a multi-gigabyte 3DS image. On the
regular queue that froze a frame, and on the threaded queue it held the
worker for seconds. Each CRC site now opens its span and returns, and
later steps hash 256 KiB quanta while the shared I/O window lasts, at
least one per call. The lookup that wanted the CRC runs when it is in,
at the same entry. The one-shot CRC helpers, which nothing else called,
are gone.
* scan: walk each database once for its crc and serial indexes
The first file to reach the serial lookup built a crc index and then a
serial index for every database, a full walk each: 47 MB of Mobile -
J2ME twice in one handler call, the second for an index that came out
empty. The crc walk now reads serials as well. It notes whether a
database has any, so the serial lookup passes over one with none, and
for the serial lookup it builds the serial index in the same pass. Index
contents, matches and the split of the index budget are unchanged.
* scan: let a database's indexes be built a run of records at a time
A database's crc and serial indexes were built by one walk and a qsort
in a single call: 50-70 ms for Mobile - J2ME. libretrodb_scan_begin(),
_step() and _end() walk a run of records per call, and
database_info_index_job_*() builds both indexes over as many calls as it
takes, each walking a run of records or merging a run of entries in a
resumable merge sort. libretrodb_scan_field2() and
database_info_index_new() are built on them and answer as before.
* scan: build each database's indexes over steps
The first file to reach a database built its indexes in one handler
call: 52-68 ms on the regular queue for Mobile - J2ME, 13-17 frames'
worth of the 4 ms window. The build now runs over the steps that follow
the lookup that began it, a run of records walked or entries merged at a
time while the window lasts, and the lookup takes the indexes when they
are done. A database counts as size-checked only then. Cancelling frees
a build in flight. The one-shot builders, database_info_crc_index_new(),
database_info_serial_index_new(), database_info_index_new() and
libretrodb_scan_field() and _field2(), lose their last caller here and
go; the tests build through the job and the stepped scan.
* task_queue samples: build on macOS, run on GCD in a macOS job
No sample ran the GCD runner and nothing in CI built HAVE_GCD. Apple's
ld has no --wrap, so on Darwin the switch and init-failure tests
redirect the wrapped calls from task_queue.c by macro instead, and
libdispatch comes from libSystem there. The switch test gets a GCD=1
build, and a macOS job runs every task_queue sample plain, under
ASan+UBSan and TSan, threaded and, where it has a GCD=1 build, on GCD.
* task_queue: a switch waits out a wake from another thread
task_queue_wake() is documented as safe from any thread, but a switch
between the threaded and the unthreaded queue frees the threaded
runner's lock and condition variable while a waker on another thread can
still be inside it. Toggling Threaded Video makes that switch at the
next frame. Two seq_cst counters now keep them apart without a lock: a
switch that finds a waker inside is put off to the next
task_queue_check(), and a waker that finds a switch under way leaves its
task to it. A wake on the thread that drives the queue cannot meet a
switch and skips the counters.
A switch now ends every park, and the new runner takes wakes again
before it runs any task, so a parked task loses nothing to a wake
dropped during the switch. A wake dropped while a switch is put off and
then taken back, or for a task whose park a switch keeps because it
leaves a stuck handler behind, waits for that park's horizon.
The switch test holds a waker inside the queue across a switch, wakes
from four threads through 1000 switches, and holds the main thread where
the new runner first runs a task while that task's first pass wakes it.
GCD builds leave out the threaded runner's own code, which they never
used and which warned there. The switch test also checks that its
realloc() wrapper ran, since on macOS that wrap is a macro rather than a
link option.
* scan: a scan of one file only adds to its playlist
A Content Location that is a file is scanned as one file, which the Scan
button, --scan=FILE and iOS "open in" already rely on. Such a scan
cleared the playlist when Overwrite was on, and recorded the file, and
its core, as what the playlist refreshes with, so Refresh Playlist later
rescanned that file alone. Overwrite is now ignored for a file, and the
playlist's scan record and default core are left as they were. Validate
Existing Entries is skipped too: a file scan's extensions can differ
from its folder's, so validating with them could drop entries the folder
scan added. A later folder scan or Refresh still prunes. With no
database and an automatic target playlist, a file is filed under its
folder's name, as a scan of that folder files it, rather than in a
playlist named after the file. A Content Location that is missing, as on
a drive that is offline, counts as a file, so Overwrite no longer
empties its playlist while the drive is away.
* menu: Content Location takes a file or a folder
Content Scan's Content Location now opens one browser that lists folders
and files in every scan method: OK on a file picks it, <Use This
Directory> picks the folder. In Automatic it lists every file, as an
Automatic scan reads every file; Custom keeps listing the scan's
extensions. The Scan Single File toggle, which switched the browser to
files and was shown only in Custom with Search Recursively off, goes
with its setting and strings, and a scan of a file no longer turns
Search Recursively off behind the user's back. Import Content drops Scan
Directory and Scan File, as the Scan Directory list already had, leaving
Content Scan as the one way in; Scan File no longer started a scan. On
Apple, File > Open and the iOS document picker opened from Content
Location set the location as OK on a file does.
* task_queue: hold pushes from other threads for the main thread
task_queue_push() from another thread could meet a switch between the
threaded and the unthreaded queue, which frees the lock and condition
variable the push takes. On the unthreaded queue, with no switch at all,
it put the task on a list the main thread walks without a lock. Windows
pushes from the video thread under threaded video, and HID builds from
libusb's thread. Such a push now goes through the switch's gate: when
the gate is shut, or the unthreaded queue is up, the task goes onto a
lock-free list that the next gather pushes on the main thread, and the
push returns true. A push is also held while earlier ones still wait, so
a thread's pushes start in the order it made them. A BLOCKING task
refused there is cancelled, and its callback still runs. The switch test
pushes from four threads on the unthreaded queue and through 1000
switches, checks a held BLOCKING push, and holds the main thread inside
the gather that reopens the queue to show that a thread's next push does
not pass its held one.
* task_queue: cancel by ident and find safely from other threads
task_queue_cancel_task() and task_queue_find() from another thread met
the same switch and the same unlocked lists as a push did.
task_queue_cancel_ident() cancels by ident from any thread: a locked
walk when the threaded queue is up with nothing held, otherwise an ident
left for the next gather, which applies it after its pushes, to a held
push as well. A held push cancelled so retires cancelled without
running, and its callback runs. A find from another thread goes through
the switch's gate and reports false when it cannot walk the lists. The
queue's own workers and GCD threads skip the gate, and a find on the
main thread also sees held pushes. Each worker keeps its thread id in a
slot of its own and clears it before it reports that it left, so a
thread that reuses a joined worker's id is not taken for one. The switch
test cancels and finds from other threads on both queues and across a
put-off switch, and holds the main thread in the gather to show that a
thread's cancel of its own held push is not lost. Once extra workers
start, finds from handlers on the one worker and on an extra still skip
the gate, and a find with a joined extra worker's id from inside deinit
is refused.
* autoconfig: make connects reported on other threads on the main thread
libusb's hotplug thread and the Wii's HID poll thread report pads from
their own threads, where task_queue_find() can no longer answer exactly:
at a switch, or on the unthreaded queue, it reports false. Off the main
thread, input_autoconfigure_connect_ex() and
input_autoconfigure_disconnect() now copy the request into a main-thread
task and return true. Its callback makes the call on the main thread, in
the order the requests were made, so the duplicate check, the port's
sequence number and the settings it reads are the main thread's. A new
sample drives task_autodetect.c on the task queue with the rest stubbed,
reports pads from another thread, and checks that every find runs on the
main thread, that a pad reported twice queues one connect, that a
disconnect handed off is made and that a cancelled request is not.
* task_queue: wait, reset and deinit see pushes held for the main thread
On the unthreaded queue every push from another thread is held for the
next gather. A wait with nothing running returned without running it,
and a reset, the exit drain's included, left it to run normally
afterwards. Cancels held for the gather were never freed at deinit.
The unthreaded wait now drains held pushes first, and a reset drains
them into the runner before it cancels, so a held task meets a queued
one's fate. Deinit applies and frees held cancels; held pushes stay held
for the next runner's first gather, so no callback runs inside deinit.
* task_queue: make the Threaded Tasks flag atomic
Task handlers on the worker read it through task_queue_is_threaded(),
and the main thread writes it when the setting changes, so changing the
setting while a task ran was a data race. ThreadSanitizer shows it on a
database scan whose queue is switched under it.
* task_queue: a parallel task names the extra workers it needs
retro_task_t gains parallel_workers, which task_init() clears. A
parallel push starts the extra workers it finds missing, up to the
larger of task_queue_set_parallel_workers() and the task's number, at
most 8. They serve every parallel task and stay until deinit, as before,
so the pool only grows; 0 keeps the frontend's number. The started count
is atomic, so a push that finds enough takes no lock, and one that needs
more claims the next entries under running_lock.
The parallel test has a task asking for three, a later one asking for
fewer, one asking for more than eight, a plain task whose number is
ignored, the frontend's number holding for a task asking for fewer, and
a task that leaves the number alone.
* task_queue: let deinit leave extra workers behind in detachable handlers
A parallel task may now also be detachable, and then runs on the extra
workers like any other parallel task. Deinit gives every worker the one
bound it gave the one worker, the extra workers first. One still inside
a detachable handler past it is left behind to finish alone, as the one
worker was, and one inside any other handler is still waited for. The
primitives of an init are held by deinit and by each worker it leaves
behind, and the last of them to let go frees them, so the one worker and
several extras can be left behind together.
A worker left behind, the one or an extra, now runs the task's cleanup
once the handler returns, then frees the task, so a detachable task
releases what it holds however it ends. Its callback still never runs;
its cleanup, like its handler, may touch only what the task owns.
The parallel test runs a detachable parallel task on an extra worker,
leaves one stuck past the bound, waits for a slow one that is not
detachable, and leaves the one worker and two extras behind together
with a new queue running beside them. Each task left behind is cleaned
up once, by its own worker, after its handler returns, and one not left
behind at its retirement as before. The switch test switches to the
unthreaded queue and back with extra workers live.
* task_queue: on Emscripten, sleep after a pass on the one worker only
On Emscripten every worker sleeps 1 ms after each handler call, a
pthreads workaround from when the one worker ran every task. The extra
workers run parallel tasks, which work in many short passes, and the
sleep cost each of those passes 1 ms, more than the pass itself. The
extra workers no longer sleep; the one worker still does.
* emscripten: ask for at most 4 extra workers, and start 5 threads
In the browser a pthread the pool has not started is made on demand by
the main thread, and with the JS file system, where every thread's file
calls go through the main thread, 8 extra workers made each of those
calls about 40% dearer than 4 did. The frontend asked for cores - 3
extra workers, up to 8; on Emscripten it now asks for at most 4, and the
build starts 5 pthreads up front, enough for the one worker and those 4.
* scan: read small plain files on parallel reader tasks, in list order
A database scan on the threaded queue pushes min(4, cores) reader tasks,
none below 2, as parallel tasks that ask for that many extra workers, in
HAVE_THREADS builds with lock-free atomics, except on Wii U, whose C
library and FAT layer take no locks, and on Vita, where Vita3K's sceIo
tables take none. With Threaded Tasks off none starts and the scan
reads every file itself, stepped as before.
The scan hands the plain files and archives it would CRC whole to the
readers, up to 64 per reader ahead of it, each with its own copy of the
path. A reader claims them in list order, opens and sizes each, leaves
one over 128 MiB to the scan unread and CRCs the rest a quantum per
call. The scan takes each result at its own place in the content list,
so the databases see files in the same order as before, parks while the
next one is still being read, and reads itself whatever a reader could
not.
The scan never waits for its readers. At its end, on cancel and once
the queue is unthreaded, each reader leaves at its next call and hands
back the file in hand. Each reader drops its reference to what they
share in its cleanup, and the last reference frees it. A queue deinit
leaves a reader stuck in a read behind after its 1 s bound and never
calls it again; the worker left with it runs its cleanup once the read
returns, which hands back the file in hand and drops the reference.
The scan test covers list order, files over the cutoff, failed pushes,
cancels and quits with a reader stuck in a read, and queue switches
under a scan; CI runs it under TSan, without threads and with no
readers.
* scan: run the command-line scan with no menu on the threaded queue
A command-line scan with no menu waits for the task queue to run dry,
and only a scan on the threaded queue gets readers. In threaded builds
that run now uses the threaded queue whatever Threaded Tasks says; the
setting is not changed.
* menu: Import Content offers Scan Directory and Scan File
Both entries sit beside Content Scan when the database is built in.
OK on a file in Scan File's browser scans that file, as the Scan
action does. The load_content_filter harness checks that the
entries are listed and that OK on a file starts its scan.
* manual scan: Content Location holds a full file path
The location can now be a file, so it is kept in a PATH_MAX_LENGTH
buffer, as is the scan task's copy. A file whose path does not fit
is refused in the browser instead of being joined short. The
load_content_filter harness sets a location deeper than a folder
buffer and checks that it is kept whole.
---------
Co-authored-by: LibretroAdmin <[email protected]>
Emscripten, RS90, Android (Android.mk and the legacy NativeActivity
project) and UWP define HAVE_RCHD with HAVE_CHD, so every build reads
CHD images through formats/chd/rchd.c and griffin leaves libchdr out.
Each platform already builds the codecs rchd calls for the formats it
had before.
The configure builds, Android, Apple, UWP and webOS were on the
built-in codec, HAVE_RZSTD; nobody set HAVE_ZSTD, the reference
library, any more; and the console and handheld makefiles - 3DS,
PSP, PS2, Wii U, GameCube, Wii, Vita, Switch, Orbis, Emscripten, DOS,
the Dingux family, the Pandora, the Win32 griffin build - had
neither, so .zst archives, Zstandard CHD hunks, RVZ hashing and
compressed input replays were absent there. HAVE_RZSTD everywhere:
one C file with no dependency, compiled into griffin builds through
griffin.c and into the others through Makefile.common.
stb_truetype was optional and seven targets turned it off - the
Dingux-family handhelds (rg350, rg350_odbeta, retrofw, rs90, miyoo,
lfx000), which also build without FreeType, leaving
bitmap_font_renderer as their only font renderer.
The cost of always having it is small: 8.2 KB of text at -Os, against
a multi-megabyte binary. The cost of it being optional is 44
references across fifteen makefiles, the configure script, three
feature-reporting sites and two preprocessor conditionals in
menu_screensaver.c that are unreadable precisely because they encode
which platforms happen to enable it.
Drop the option. stb is now guaranteed present, which is also what
lets the next commit make it the single fallback renderer.
The two menu_screensaver.c conditionals become unconditional: both
were asking "is any font renderer available", and now one always is.
* Emscripten libretro-common fixes
* memmap: gate the reserve/commit path off for emscripten instead of dropping mman
Emscripten was added to the "No mman available" platform list in
memmap.h, which reaches further than intended. That branch does not
just disable things: it makes memmap.c define mmap(), munmap() and
mprotect() as global symbols with malloc/free semantics on a platform
whose libc already provides working ones, and it declares mmap() with
a size_t offset where <sys/mman.h> uses off_t, so any translation unit
that pulls in both headers gets conflicting declarations. The shim's
mmap() also ignores fildes and offset, so a file-backed request would
return uninitialised memory; that is invisible today only because
Makefile.emscripten never sets HAVE_MMAP and the mapping path in
vfs_implementation.c is therefore compiled out.
What is actually unusable on emscripten is the reserve/commit model,
and that is unusable by construction rather than by omission: a wasm
linear memory grows monotonically, is committed in full, and has no
unmap, no shrink and no page protection. An anonymous PROT_NONE
mapping is a memalign of the whole length followed by a memset over
it, so memreserve() commits and touches every byte the reservation
existed to avoid, mprotect() and madvise() cannot make commit or
decommit mean anything, and munmap() only accepts an exact length
match, so the range cannot be released. Opening large content through
data_transfer would allocate the whole file up front and never give it
back.
Leave memmap.h alone and gate MEMMAP_HAVE_RESERVE instead, so
mempagesize() reports 0, memreserve() returns NULL and callers take
the bounded-allocation fallback they already have for platforms
without virtual memory. memsync() is excluded from the msync() branch
for the same reason: emscripten's msync() only accepts the exact base
of a live mapping and returns -EINVAL for an arbitrary range, while a
wasm linear memory has no separate instruction cache to flush, so the
fallthrough's 0 is both correct and the only honest answer.
mmap(), munmap(), mprotect() and memprotect() keep working through
libc as before.
* memmap: round memrelease() to the page size memreserve() rounded to
memreserve() rounds the requested length up to a whole number of pages
and maps that, but memrelease() passed the caller's unrounded length
straight to munmap(). Linux rounds the length up internally so the
mismatch is invisible there, which is how it survived; an
implementation that takes the length literally and declines a partial
unmap fails the call outright and leaks the entire reservation
whenever the length was not already page-aligned.
Apply the same rounding on the way out. mempagesize() is non-zero
wherever this branch compiles - MEMMAP_HAVE_RESERVE is only defined
when _SC_PAGESIZE is available - but the guard costs nothing and keeps
the expression from dividing the range by zero if that ever changes.
* Revert "memmap: gate the reserve/commit path off for emscripten instead of dropping mman"
This reverts commit 11b85a9421.
* Fix remaining uses of EMSCRIPTEN define
---------
Co-authored-by: libretroadmin <[email protected]>
The emscripten backend sat on emscripten_async_wget2_data(), and that
API is the root cause of how far this file had drifted from
tasks/task_http.c. It takes the request body as a single
NUL-terminated `const char*` and offers nothing for request headers, a
user agent, or reading response headers back, so everything the native
path provides beyond "GET a URL into memory" was silently dropped or
stubbed out. emscripten_fetch() covers all of it; switching over
closes six defects at once.
- Request headers were accepted and discarded on every entry point.
task_push_http_transfer_with_headers() sent none, which meant no
Authorization header, so cloud sync could not authenticate at all.
All five webdav helpers logged "Response headers not supported,
webdav won't work" and then did exactly that. RetroArch passes
headers as a raw CRLF blob and fetch wants a NULL-terminated
key/value array, so http_req_headers_parse() converts between them.
- task_push_webdav_put() passed put_data as a NUL-terminated string
and dropped the `len` argument entirely, truncating any binary
payload at its first zero byte. Length now travels explicitly.
- Response headers are recovered via
emscripten_fetch_get_response_headers() and split into the same
string_list of "Name: Value" lines net_http.c produces.
- resp->status was hardcoded to 200, and the error callback recorded
no status at all, so callers branching on data->status -- webdav's
401 digest challenge, the thumbnail downloader's 404 check -- saw a
NULL task_data and could not distinguish "not found" from "the
network died". Both paths now settle with the real status, and
error bodies are kept since 4xx/5xx routinely carry one.
- wget_onload_cb() returned early when its malloc failed, leaking the
whole response buffer. The fetch is now closed unconditionally.
- Cancelling a task never aborted the transfer. http_handle_free()
closes the fetch, which emscripten guarantees suppresses any further
callback.
Two lifetime fixes carried over from task_http.c:
task_push_http_transfer_file() assigned t->title after
task_queue_push(), the exact use-after-free already fixed and
commented in the native file -- harmless single-threaded, a genuine
race under -pthread/PROXY_TO_PTHREAD. And emscripten_fetch does not
copy requestData or requestHeaders, so http_handle now owns both for
the fetch's lifetime rather than retaining a caller's buffer.
Also drops the local http_transfer_progress_cb(), which called
video_display_server_set_window_progress() unconditionally while its
header was behind #ifdef RARCH_INTERNAL, in favour of the shared
task_window_progress_cb() the native path uses; and sets
RETRO_TASK_FLG_ALTERNATIVE_LOOK, which was missing here.
network/cloud_sync/webdav.c matches the digest challenge
case-insensitively now. Browsers lower-case response header names, so
"WWW-Authenticate: Digest " never matched on this backend. Header
names are case-insensitive per RFC 9110 5.1, so the consumer was what
needed fixing; webdav_create_digest_auth() skips a fixed byte count
past the prefix, so the offset is unaffected.
Makefile.emscripten passes -sFETCH=1, which the fetch API requires.
Adds samples/tasks/http/http_emscripten_headers_test.c covering both
conversions against hand-built blobs of the kind
task_push_webdav_move() and task_push_http_transfer_with_content()
produce: bare LF, missing trailing CRLF, empty values, embedded
colons, malformed lines, and growth past the initial array capacity.
A header dropped here is an auth failure rather than a crash, so the
degenerate cases are worth pinning. 33 checks, clean under ASan and
UBSan. Verified with emcc 6.0.5: the file compiles clean at -Wall and
-sFETCH=1 links.
ZLIB_LIBS is never assigned anywhere, so every makefile target that set
HAVE_ZLIB=1 compiled trans_stream_zlib.c and archive_file_zlib.c against
<zlib.h> and then failed to link -- there is no longer a vendored
implementation behind them. psl1ght hit this first; MSVC hit the
compile-side variant once the compat/zlib headers went away.
Take HAVE_ZLIB out of every platform. RetroArch decodes PNG with rpng,
so the -lpng that pulled zlib in on vita and wiiu was only ever a
convenience for statically linked cores, and android's -lz went with it.
No target enables zlib by default any more: trans_stream_zlib.c is now
reachable only through the explicit HAVE_ZLIB=1 opt-in in
Makefile.common and its matching guard in griffin.
psl1ght additionally drops freetype for stb font: libfreetype pulls
inflate/inflateEnd in through ftgzip, which is the same undefined
reference by another route.
Also repair damage from the earlier -I removal, which deleted the last
entry of several line-continued lists and left the preceding line with a
trailing backslash: vita and ctr swallowed the following 'else' (vita
lost main() entirely), orbis ended up with a literal '\' argument, and
psp1 and griffin were left with an empty continuation and a bare
'CFLAGS +='.
The database sample never built archive_file_7z's strldup dependency;
add compat_strldup.c. test_rpng and the json sample both compiled
trans_stream_zlib.c without a zlib to link against; point them at the
built-in DEFLATE backend instead.
archive_file_7z.c now reads archives through r7z_archive, and CHD
decodes LZMA through r7z_lzma, so nothing in the tree depends on the
bundled LZMA SDK any more. This deletes it.
The backend rewrite is the substance of the change. r7z_archive parses
from a buffer rather than a stream, so the archive is read in whole
instead of through a CLookToRead2 over a CFileInStream. That suits how
this backend is used: callers already hold the file open and go on to
decode entire members into memory, and 7z cannot decode a solid folder
without holding all of it regardless. It also removes the SDK's
allocator plumbing, its file wrappers and the 16 KiB lookahead buffer
from the context.
One behavioural detail changed for the better. The old iterate step
handed back a pointer into the middle of a decoded folder
(output + offset); the new one hands back the member itself. The caller
in archive_file.c writes exactly `size` bytes from that pointer, so
this is equivalent and no longer depends on the folder buffer
outliving the member.
The per-member compressed size reported during iteration is now the
uncompressed size. It was never meaningful for 7z: members of a solid
folder share one compressed stream and have no individual packed size.
Callers use the value only for progress reporting.
CHD's LZMA path no longer has an SDK implementation to fall back to, so
the HAVE_RLZMA fork in Makefile.common collapses to always building
r7z_lzma. In the griffin unity build the two consumers are separated by
a guard, since libchdr and the 7z backend can each be enabled without
the other but the translation unit may only appear once.
Also drops -Ideps/7zip from every platform makefile, the Xcode header
search paths, the qb configure step and the database sample, and the
now-meaningless _7ZIP_ST define from all of them plus the MSVC project
files. Nothing in the tree references deps/7zip or _7ZIP_ST after this.
Verified: 50 files extracted across 11 archives covering every
supported codec and both header forms, byte-identical to the source
tree; 48,645 captured CHD LZMA streams still decode byte-exact; the
LZMA2, BCJ2 and streaming-LZMA corpora all still pass. Every 7z module
and the rewritten backend build C89 clean with -pedantic-errors -Wall
-Wextra -Werror.
stb_truetype.h and stb_rect_pack.h are no longer referenced by
anything in the tree (the rect packer had been unused since the
plain stb renderer was removed). Drop the vendored headers and the
dead -Ideps/stb include paths from all platform Makefiles.
The vendored ibxm dependency is gone; the module replayer is now a
libretro-common citizen (formats/mod/rmodtracker.c) built like the
other decoders. Mechanical flag migration across the tree:
- Makefile.common: flag block renamed, object path moved from
$(DEPS_DIR)/ibxm/ibxm.o to
$(LIBRETRO_COMM_DIR)/formats/mod/rmodtracker.o (the rvorbis /
rflac object pattern).
- griffin: define and single-TU include swapped to the new file.
- qb/config.params.sh and Makefile.griffin: flag renamed.
- 15 platform Makefiles (dingux, dos, dos.salamander, emscripten,
lfx000, libnx, miyoo, ngc, retrofw, rg350, rg350_odbeta, rs90,
switch, webos, wii): flag renamed, values preserved (including
ngc's =0).
- retroarch.c, msg_hash.c, audio/audio_driver.c,
menu/cbs/menu_cbs_deferred_push.c: the mod/s3m/xm extension
gates renamed.
- msvc-uwp vcxproj: 9 PreprocessorDefinitions entries renamed
(define-only; UWP compiles via griffin, so there is no per-file
entry to swap). BOM and line endings preserved.
- The iOS9 xcodeproj needed nothing: its apparent matches are the
substring 'ibxm' inside 'libxml2'.
- deps/ibxm: removed.
Tree-wide residual check: zero HAVE_IBXM / deps/ibxm references
remain; the only 'ibxm' tokens left are the provenance attribution
and licence retention inside rmodtracker itself.
The DDS loader landed with only the core wiring (Makefile.common,
griffin, qb). Enable it everywhere the WebP loader (HAVE_RWEBP) is
enabled, so DDS decodes on every target rather than only default builds.
- platform Makefiles: mirror every HAVE_RWEBP toggle and inline
-DHAVE_RWEBP with HAVE_RDDS (ctr, dingux, dos, emscripten, griffin,
lfx000, libnx, miyoo, ngc, openpandora, orbis, ps2, psl1ght, psp1,
retrofw, rg350, rg350_odbeta, rs90, switch, vita, webos, wii, wiiu,
msvc).
- MSVC .vcxproj (2010-2022, 360, UWP) and the Android NativeActivity
project: add the HAVE_RDDS preprocessor define next to HAVE_RWEBP.
- Apple .xcodeproj (OSX107, PPC, iOS6-11 incl. Metal/static): add
-DHAVE_RDDS to OTHER_CFLAGS next to -DHAVE_RWEBP.
- pkg/android Android.mk: add -DHAVE_RDDS.
- feature reporting: SUPPORTS_RDDS (config.features.h), the retroarch
--features string, the menu Core Information image-format list, and
the imageviewer core extension list (adds |dds).
All these targets build the image loaders through the griffin unity TU,
which already includes rdds.c under HAVE_RDDS, so defining the flag is
sufficient to compile and enable the loader.
The WebP decoder was only enabled through the qb configure default, so
platforms with static build files never compiled it. Wire HAVE_RWEBP
everywhere HAVE_RPNG is wired, following each file's existing style:
- Variable assignments (routed through Makefile.common's define/object
block or Makefile.griffin's CFLAGS emit): dingux, dos, emscripten,
lfx000, libnx, miyoo, msvc, ngc, retrofw, rg350, rg350_odbeta, rs90,
webos, wii, and every per-platform block in Makefile.griffin, which
also gains the matching CFLAGS emit.
- Platforms with both a griffin branch (inline -D defines) and a
default Makefile.common branch (variable assignments) get both:
ps2, ctr, switch, orbis, wiiu.
- Continuation-style define lists: psl1ght, psp1, vita, openpandora,
and the Android NDK build.
- MSVC project files (griffin-based, PreprocessorDefinitions):
msvc-2010 through msvc-2022, UWP, Xbox 360, and the legacy Android
NativeActivity project.
- Xcode projects (griffin-based, -D flag lists): all eleven, including
the PPC and legacy iOS projects.
The decoder itself is C89-clean scalar C on platforms without SSE2 or
NEON (the SIMD paths are compile-time gated), so no platform needs
anything beyond the define. The salamander Makefiles are deliberately
left alone: the loaders do not decode images beyond their existing
boot path. Console targets are not buildable in this environment; the
edits mechanically mirror the existing HAVE_RPNG wiring in each file,
and the Makefile.common route they rely on is the same one exercised
by the regular Linux build.
These decoders were carved from vendored single-header libraries
(dr_flac, stb_vorbis, dr_mp3) and kept that shape: the implementation
lived in the header behind an X_IMPLEMENTATION / HEADER_ONLY macro.
That is wrong for first-class in-tree source and it broke the griffin
build - rmp3.h was pulled into one translation unit twice (via rmp3.c
and via audio_transfer.c) with its implementation block outside the
include guard and no inner guard, so every type and function was
defined twice.
Move each implementation into its .c file (rflac.c, rvorbis.c,
rmp3.c); leave the headers as declarations only (typedefs, struct
definitions, enums, prototypes). Drop the X_IMPLEMENTATION /
HEADER_ONLY machinery: the .c files are ordinary translation units and
the headers may be included anywhere, any number of times.
Also fix the emscripten link failure (audio_mixer.o: undefined
audio_transfer_*): emscripten enabled vorbis with a bare -DHAVE_RVORBIS
define but never set the HAVE_RVORBIS make variable, so Makefile.common
added neither rvorbis.o nor audio_transfer.o. Set it as a make variable
like the other codecs.
Carve the vendored stb_vorbis single-header decoder into a first-party
in-tree decoder (rvorbis), wire it under the codec-agnostic audio_transfer
layer as the AUDIO_TYPE_VORBIS backend, repoint the audio mixer's OGG voice
onto audio_transfer, and remove deps/stb/stb_vorbis.h.
rvorbis is the whole stb_vorbis decoder with file I/O stripped
(RVORBIS_NO_STDIO) and every exported symbol namespaced from
stb_vorbis/STB_VORBIS/STBVorbis/VORBIS_ to rvorbis/RVORBIS/RVorbis/RVORBIS_,
so a statically-linked console core vendoring its own stb_vorbis cannot
collide at link with RetroArch's copy: the object exports rvorbis_* symbols
only. The header carries its own <stdint.h>/<stddef.h> and keeps the
fixed-width types the vendored copy already used.
Vorbis is a float-internal codec with no integer decode API, so the backend
reads f32 natively and quantises to s16 at the boundary (round-half-away,
clamp) rather than round-tripping. The mixer's OGG voice holds an opaque
audio_transfer context and drives it through
new/start/info/read_f32/seek/free; loop-to-start routes through
rvorbis_seek_start, since stb_vorbis's seek(0) does not rewind.
Build: HAVE_STB_VORBIS is renamed HAVE_RVORBIS across the platform
makefiles, the qb knob and Android.mk. Makefile.common gains a HAVE_RVORBIS
branch adding formats/vorbis/rvorbis.o (and audio_transfer.o once, guarded
against the FLAC branch). griffin includes rvorbis.c under HAVE_RVORBIS and
shares audio_transfer.c across both backends.
* Actually read CLI args in emscripten
* Fix fetchfs manifest parsing, increase download chunk size
The chunk size should probably be made a parameter in the future. The
larger chunk size trades longer hitches for fewer hitches.
* Add exec command driver and API functions for emscripten.
Under WASMFS, stdin/stdout can't be customized the way they can with
the JS FS implementation. Also, this approach frees up stdin/stdout
and simplifies interaction with the command interface for web embedders.
* fixup upload paths, show use of new emscripten cmd interface
* Add JS library function names to EXPORTS as well as EXPORTED_FUNCTIONS for older emsdk versions
* workerized RA
* Workerized (non-async) web player, using OPFS
This patch eliminates the need for asyncify and uses modern filesystem
APIs instead of the deprecated, unmaintained BrowserFS.
This is a WIP patch because it won't fully work until these two
Emscripten PRs land and are released:
https://github.com/emscripten-core/emscripten/pull/23518https://github.com/emscripten-core/emscripten/pull/23021
The former fixes an offscreen canvas context recreation bug, and the
latter adds an equivalent to BrowserFS's XHR filesystem (but without
the hazardous running-XHR-on-the-main-thread problem).
The biggest issue is that local storage of users who were using the
old version of the webplayer will be gone when they switch to the new
webplayer. I don't have a good story for converting the old BrowserFS
IDBFS contents into the new OPFS filesystem (the move is worth doing
because OPFS supports seeking and reading only bits of a file, and
because BrowserFS is dead).
I've kept around the old libretro webplayer under
pkg/emscripten/libretro-classic, and with these make flags you can
build a non-workerized RA that uses asyncify to sleep as before:
make -f Makefile.emscripten libretro=$CORE HAVE_WORKER=0 HAVE_WASMFS=0 PTHREAD=0 HAVE_AL=1
I also moved the default directory for core content on emscripten to
not be a subdirectory of the local filesystem mount, because it's
confusing to have a subdirectory that's lazily fetched and not
mirrored to the local storage. I think it won't impact existing users
of the classic web player because they already have a retroarch.cfg in
place.
* Get fetchfs working without manifest support
* makefile fixes
* fix scaling, remove zip dependency
* Support asset/cheats/etc downloaders for emscripten
- Add http transfer support for emscripten
- At the task_http level, not the net_http level --- so no netplay
or webdav.
- Change default paths to be more like other platforms
- Gives us smaller bundles and a faster boot time
- Had to work around a task queue bug on Emscripten
- I made the smallest possible change to do it, but it may be better
to fix in rthread.c
* Load an emscripten file_packager package on first run
If no ozone assets are present, load a libretro_minimal package
created using Emscripten's built-in file packager.
* updated readme, removed indexer from wasmfs libretro-web
* Put back zip dependency, load asset bundle into opfs on first run
* fix upload path
* Remove unused function
* easy testing setup for two multithreaded conditions
1. make PROXY_TO_PTHREAD=1 (slower)
2. make PROXY_TO_PTHREAD=0 (bad audio, because doesn't sleep in
openal.c)
* Remove condition on sleep in openal
also make input_driver check existence of drv->axis, drv->button
before calling them.
* Fix resizing under EGL
* Don't force config file path on emscripten
* Add time.h include to netplay, default HAVE_NETPLAYDISCOVERY to 0
* Remove nearly all proxied joypad calls under emscripten
* Fix file uploads under firefox
* Fix safari API uses, but Safari still hangs in OPFS filesystem mount
I think this can be fixed by moving the backend creation off the main
thread.
* Move filesystem init into emscripten C entry point
* Setup filesystems off of main thread
* re-set default player to async
Also improve Safari compatibility under proxy-to-pthread condition
* Safari upload file fixes
* Remove some excess prints
* Fix typo
* workerized RA
* Workerized (non-async) web player, using OPFS
This patch eliminates the need for asyncify and uses modern filesystem
APIs instead of the deprecated, unmaintained BrowserFS.
This is a WIP patch because it won't fully work until these two
Emscripten PRs land and are released:
https://github.com/emscripten-core/emscripten/pull/23518https://github.com/emscripten-core/emscripten/pull/23021
The former fixes an offscreen canvas context recreation bug, and the
latter adds an equivalent to BrowserFS's XHR filesystem (but without
the hazardous running-XHR-on-the-main-thread problem).
The biggest issue is that local storage of users who were using the
old version of the webplayer will be gone when they switch to the new
webplayer. I don't have a good story for converting the old BrowserFS
IDBFS contents into the new OPFS filesystem (the move is worth doing
because OPFS supports seeking and reading only bits of a file, and
because BrowserFS is dead).
I've kept around the old libretro webplayer under
pkg/emscripten/libretro-classic, and with these make flags you can
build a non-workerized RA that uses asyncify to sleep as before:
make -f Makefile.emscripten libretro=$CORE HAVE_WORKER=0 HAVE_WASMFS=0 PTHREAD=0 HAVE_AL=1
I also moved the default directory for core content on emscripten to
not be a subdirectory of the local filesystem mount, because it's
confusing to have a subdirectory that's lazily fetched and not
mirrored to the local storage. I think it won't impact existing users
of the classic web player because they already have a retroarch.cfg in
place.
* Get fetchfs working without manifest support
* makefile fixes
* Increase emscripten stack size and decrease path size to fix emscripten builds broken since de45fc2
* use modularize flags for better-behaved javascript output
* makefile and loader changes
* use specialHTMLTargets to support modular access to canvas
* bind key events to canvas, not document
This way focus means focus and we can have multiple RA instances in
one page.
* Work around an emscripten bug in strict mode
* (Emscripten) Use console.error() for error messages
* increase asyncify stack size
* Fix `-lm` flag-related compile warnings in emscripten
---------
Co-authored-by: Rob Loach <[email protected]>
* change bsv file suffix to replay, update strings
* add trivial RPLY block to save states
* WIP rerecording support, doesn't load states properly yet--issue with checking identifiers?
* Fixed a type error to get time identifiers working right, ready for testing
* handle case where state without replay data is loaded during replay
* cleanups
* whitespace cleanup
* Cleanups, change replay file format magic, fix logic around future states
* Remove failed future message
* Add play-replay-from-slot command, fix load-state-from-slot to use given slot
* build fixes
* Fix race conditions in emscripten build and incorrect replay state incrementing
* Style fix for single line if
---------
Co-authored-by: Joseph C. Osborn <[email protected]>
* add more documentation to emscripten, pthread support, and flag to not show asset warnings
* typo in docs
---------
Co-authored-by: thelamer <[email protected]>
ever implemented for OpenGL2 driver, lots of code debt, best to
instead just keep improving the overlay system instead which is
already available for most video drivers