Skip to content

util: Port os_strtod and os_dtostr to obs-util - #826

Merged
zackees merged 3 commits into
masterfrom
port/platform-number-rust
Oct 15, 2026
Merged

zackees merged 3 commits into
masterfrom
port/platform-number-rust

Conversation

@zackees

@zackees zackees commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Refs #262 (slice 2, numbers).

RED (util: Test os_strtod and os_dtostr against Rust stubs): rust/obs-util/src/platform_number.rs with todo!() cores and C ABI shims in ffi/platform_number.rs.

  • Tier 1 (tests/platform_number.rs): 1:1 ports of test_strtod, test_dtostr and test_dtostr_exponent. Aborts on todo!("os_dtostr port (#262)").
  • Tier 3 (tests/platform_number_parity.rs): edge values, every buffer size 0–71 and proptest over all f64 bit patterns and number-like strings, against the real platform-number.c compiled as oracle_*. The oracle's config-file now links that file instead of the copies in config_file_host.c (one fewer drifting stand-in, bug: Oracle stand-ins in test_stubs.c can diverge from libobs #145).
  • Tier 2: ENABLE_RUST_LIBOBS=ON drops util/platform-number.c; exports in rust-exports.d/obs-util-platform_number.txt.

GREEN (util: Port os_strtod and os_dtostr to obs-util): the existing strtod parser and %.17g formatter move out of config_file.rs into platform_number.rs, which now backs both the shims and config_get_double/config_set_double. os_dtostr applies C's size checks exactly (measured before the exponent is shortened; .0 needs length + 3 < size).

Locally: soldr cargo test -p obs-util all green, ./lint ok. Mutation check: changing the .0 check to + 2 fails dtostr_edge_values. Tier 2 OFF/ON is left to PR CI.

Intentional difference, documented on the shims: C swaps . for the LC_NUMERIC decimal point; Rust always uses .. Only a string already written with the locale's own point ("1,5" under a , locale) reads differently.

@zackees
zackees force-pushed the port/platform-number-rust branch from 11e20a9 to 3778584 Compare October 15, 2026 13:35
@zackees
zackees marked this pull request as ready for review October 15, 2026 13:41
@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Rust Tests failed on Linux and Windows: the new Tier 1 test tests/platform_number.rs didn't link the C oracle (use obs_c_oracle as _;), so the windows-gnu link had no blog/bmalloc. Fixed in the latest commit; ci/local_gate.py --lane rust-test passes locally.

Tier 1 ports test_strtod, test_dtostr and test_dtostr_exponent through
new os_strtod/os_dtostr shims over todo!() cores. Tier 3 compares them
with the real platform-number.c compiled as an oracle; the oracle's
config-file now uses that file instead of its own copies (#145).
ENABLE_RUST_LIBOBS=ON drops platform-number.c.

Refs #262
The strtod parser and %.17g formatter move out of config_file.rs into
platform_number.rs, which now backs both the os_strtod/os_dtostr shims
and config_get_double/config_set_double. os_dtostr applies C's buffer
size checks, including measuring before the exponent is shortened.

Refs #262
Like the other Tier 1 tests, it needs the oracle's test allocator and
log stubs; the windows-gnu link failed without them.

Refs #262
@zackees
zackees force-pushed the port/platform-number-rust branch from 6c75aab to 9e5dff0 Compare October 15, 2026 14:25
@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

#825 merged; rebased onto master (dropped the extraction commit, replaced head 9f… with the three port commits only) and removed the stacked note.

@zackees

zackees commented Oct 15, 2026

Copy link
Copy Markdown
Member Author

Correction to the comment above: the replaced head is 6c75aab2f; the new head is 9e5dff015.

@zackees
zackees added this pull request to the merge queue Oct 15, 2026
Merged via the queue into master with commit ec2e57c Oct 15, 2026
23 checks passed
@zackees
zackees deleted the port/platform-number-rust branch October 26, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant