Skip to content

core: prune dead build/config hooks, guard allocs, optimize strcasecmp - #37

Merged
reinauer merged 4 commits into
mainfrom
cleanup/core-headers-and-build
Nov 25, 2026
Merged

reinauer merged 4 commits into
mainfrom
cleanup/core-headers-and-build

Conversation

@reinauer

@reinauer reinauer commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Small cleanups in shared headers, plus a 64-bit AROS allocation fix.

  • config: drop unreferenced feature and profile macros: removes
    ODFS_PROFILE_FULL, ODFS_FEATURE_CACHE_BLOCK, the LOG_SERIAL/KPRINTF/RINGBUF
    flags and ODFS_PLATFORM_HOST, none of which is tested anywhere. Also
    collapses ODFS_PROFILE_ROM conditionals whose two arms define the same
    value. No behaviour change. The CHARSET_BUILTIN/EXTERNAL flags stay:
    amiga: show names in Latin-1 instead of UTF-8 #56 uses them.
  • media: drop duplicate close callback check: odfs_media_close() tested
    m->ops->close twice.
  • alloc: pass allocation sizes to AROS AllocVec as IPTR: AROS declares the
    AllocVec() size as IPTR, so the ULONG cast truncated requests above
    4 GiB on 64-bit AROS. AmigaOS 3/4 keep the ULONG cast and return NULL for
    a size that does not fit; that check folds away on those 32-bit targets.
  • core: compare raw bytes before folding case in odfs_strcasecmp: the
    same order meta_name_eq() already uses. Results are unchanged. The
    function is used by the backends' linear lookups, namefix, CDDA virtual
    names and the virtual root map, not by the metadata cache.

The freshsubs submodule hook in the Makefile stays: it is there for the
planned libcodesets support.

Sizes (pinned version/date, vs the branch's base)

build main this PR delta
OS3 68000 83552 83224 -328
OS3 68020 81160 80772 -388
ROM 31508 31516 +12
OS4 CDFileSystem 152300 152028 -272

All of the change comes from the strcasecmp commit. The first three commits
build handlers of the same size as the base.

The branch is 94 commits behind main. On today's main the 68020 handler goes
from 81,688 to 81,452 bytes (-236).

Testing

make check passes on every commit. golden-check, malformed-check,
fuzz-check, amiga, amiga-020, rom and the OS4 build pass on the tip.
CI builds the AROS x86-64 handler.

  • Emulators: the 5,028-check regression tool and CDBench pass on OS 3.2
    (WinUAE), AmigaOS 4.1 FE Update 3 (QEMU pegasos2) and AROS i386 (QEMU), as
    they do on main.
  • Speed: CDBench on OS 3.2 with this series on top of main reads
    209,019 KiB/s sequentially (main 209,007); cold discovery is 9,873
    entries/s (main 9,906). The branch tip alone reads 203,736 KiB/s, which
    is its old base: that measures 203,760.
  • Not covered: the 64-bit allocation path at run time (AROS x86-64 was
    built, not run).

@reinauer
reinauer force-pushed the cleanup/core-headers-and-build branch from a16a680 to 4ccc917 Compare November 23, 2026 20:21
Remove ODFS_PROFILE_FULL, ODFS_FEATURE_CACHE_BLOCK, the
ODFS_FEATURE_LOG_{SERIAL,KPRINTF,RINGBUF} flags and ODFS_PLATFORM_HOST
from config.h. Nothing in the tree tests any of them.

The ODFS_FEATURE_CHARSET_{BUILTIN,EXTERNAL} flags are not tested yet
either, but they stay: the name character set conversion will use them.

Also collapse the ODFS_PROFILE_ROM conditionals whose two arms define
the same value (ROCK_RIDGE, JOLIET, MULTISESSION, LOG), so the file
shows only the settings that really differ between the default and the
ROM profile. No behaviour change.
odfs_media_close() returns early when m->ops->close is NULL, so the
second test of the same pointer right before the call is redundant.
odfs_malloc() and odfs_calloc() cast the byte count to ULONG before
calling AllocVec(). AROS declares the AllocVec() size as IPTR, so on
64-bit AROS, where size_t is 64 bits, a request above 4 GiB would be
truncated and could return an undersized buffer instead of NULL.

Cast to IPTR on AROS. Keep the ULONG cast for AmigaOS 3 and 4, whose
AllocVec()/AllocVecTags() take a ULONG, and return NULL there for a
size that does not fit. On those 32-bit targets size_t is no wider
than ULONG, so the check folds away at compile time.
odfs_strcasecmp() folds both bytes through odfs_ascii_tolower() before
comparing them. Compare the raw bytes first and fold only a pair that
differs, as meta_name_eq() in the metadata cache already does. A NUL
against any other byte still differs after folding, because no
character folds to NUL, so the result is unchanged.

The function is used by the backends' linear directory lookups, the
namefix table, the CDDA virtual file names and the virtual root map,
not by the metadata cache. In a linear scan most compares already
fail on the first byte, where the new order adds a compare and branch
before folding; a matching name now skips folding for every byte.

Being inlined at all those call sites, the shorter loop shrinks the
handlers: 68000 -328 bytes, 68020 -388, OS4 CDFileSystem -272; the
ROM profile grows by 12 bytes.
@reinauer
reinauer force-pushed the cleanup/core-headers-and-build branch from 4ccc917 to 9a5e768 Compare November 24, 2026 17:33
@reinauer
reinauer merged commit abfb994 into main Nov 25, 2026
3 checks passed
@reinauer
reinauer deleted the cleanup/core-headers-and-build branch November 27, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant