Skip to content

feat(c): C port, with a header-only C++17 wrapper - #37

Merged
4matic merged 22 commits into
mainfrom
feat/c-port
Nov 15, 2026
Merged

4matic merged 22 commits into
mainfrom
feat/c-port

Conversation

@4matic

@4matic 4matic commented Nov 15, 2026

Copy link
Copy Markdown
Owner

A fifth port: libtrackparse, a C11 library under c/, translated file by file from the Go port, plus trackparse.hpp, a header-only C++17 wrapper on top of it.

Results

  • Fixtures: 13,130 / 13,130 pass with an empty skip list, and every output is valid against the schemas.
  • compare-ports --only=c: 0 differences.
  • fuzz-ports --only=c --n=500000 --seed=7: 500,000 single-track cases and 290,000 tracklists with edits, 0 differences.
  • ASan and UBSan (GCC, Clang), MSan and TSan: clean. Under Valgrind, all 13,130 fixtures and the API, OOM and properties tests show 0 errors and 0 leaks.
  • Allocation failures: a sweep fails every allocation in turn on 60 inputs. Every call returns NULL or a correct result, with no leak.
  • Other tests: the SPEC invariants (invariant 6 included) and R13.11 with the time ceilings, 16 threads against a sequential run, and the German and Turkish locales.
  • Fuzzing: six libFuzzer targets, no findings so far.

Shape

  • Public API (c/include/trackparse.h):
    • Input is UTF-8 with an explicit length. Results are read-only structs with one _free each.
    • Options are opaque handles, and so is an immutable, thread-safe trackparse_parser.
    • Tracklists and edits are covered, and _to_json writes the exact JSON.stringify bytes.
  • Memory: inside the library, every call runs in an arena, and running out of memory longjmps back to the public entry point, which returns NULL. Each result is a single allocation.
  • Numbers: parsing and formatting are exact and done by hand, with no strtod, no float printf and no locale. FMA contraction is blocked. The Unicode tables are generated from Node, the same way as for Go.
  • Linkage: the installed library (static or shared) is built from the amalgamation, so no internal symbol is visible. CMake package, pkg-config, FetchContent and the two-file amalgamation are all tested as a consumer would use them.

Release

  • A sixth linked component, c. Merging the next release PR tags c-v0.7.0.
  • publish-c attaches the source tarball (built and tested alone, without Node), the amalgamation zip, SHA256SUMS and a provenance attestation.
  • spec.yml checks six versions.
  • The c environment is created when the job first runs.

CI (c.yml)

  • Builds and tests: GCC, Clang, ARM64, shared, macOS, MSVC static and DLL, 32-bit, and GCC 9 with CMake 3.16.
  • Analysis: sanitizers, Valgrind, locales, compare and fuzz-ports against JS.
  • Lint: clang-format 19.1.7, the banned-call grep, codegen drift, and the Unicode sample compared with Go's.
  • Fuzzing: weekly.
  • MSVC and macOS have never been compiled locally, so their jobs may need follow-ups.

Docs

  • Every site example has a C tab (68 groups, every block compiled and run).
  • The playground generates C programs, and the install switch shows the FetchContent snippet.
  • c/README.md is new, the root and package READMEs are updated, and AGENTS.md now covers the C commands, the hazards the port ran into, the release flow and the known gaps.

…, vectors, maps, stable sort, exact JS number parsing and formatting
…, and a C runner in compare-ports and fuzz-ports
…ers, tracklists, edits and JSON output, with the same output as the other ports
…source tarball, amalgamation, checksums and provenance on the GitHub Release
… CMake package, pkg-config and exported-symbol checks, and examples
…ential run, locales, allocation failure sweeps, benchmarks and libFuzzer targets
…C 9 with CMake 3.16, sanitizers, Valgrind, locales, compare against JS, weekly fuzzing
…nitizer link flags for consumers in the build tree
…e the C port, its commands, hazards, release and known gaps
…arena mark and release): 1 GB to 5 MB on a 10,000-code-point input
…tion, no leak in the C++ string copy, no view of a temporary track, lock-free reads of the built tables, mark/release keeps chunk growth; CI: CMake 3.16.8 and a Windows DLL job
…1 memset bound on 32-bit, GCC 13 -Wclobbered in test_num, Clang -Wstring-concatenation in test_oom
…es sanitizer symbols, test_num avoids -Wclobbered on 32-bit
@4matic
4matic merged commit e83db4e into main Nov 15, 2026
62 checks passed
@4matic
4matic deleted the feat/c-port branch November 15, 2026 01:52
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