SOL-XPILE-002 // xpile
Fixed-Capacity C Ring Buffer to Rust Generics
Transpile an embedded C circular buffer into a panic-free Rust index step with compile-time bounds clarity.
Measured delta: 0 unsafe pointer arithmetic; checked modulo invariant enforced
Before (Failing Anti-Pattern)
unsigned int ring_raw(unsigned int idx, unsigned int cap) {
return (idx + 1) % cap; // division by zero UB if cap == 0 in C
}
After (Verified Code)
unsigned int ring_next(unsigned int idx, unsigned int cap) {
return (idx + 1) % cap;
}
Verification Contract
schema: xpile.contract.v1 source_lang: c99 target_lang: rust invariants: - cap_nonzero: true - no_integer_overflow: true
Verified CLI Command & Output
$ xpile transpile ring.c --target rust // xpile-generated from C module ring