Re: [PATCH 1/9] xdiff: use ssize_t for dstart/dend, make them last in xdfile_t
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 22, 2025, 21:38 UTC
- Message-ID
- <xmqqqzuuwra4.fsf@gitster.g>
- In-Reply-To
- <CAH=ZcbBmdWCBh9zH1Y1JxcnNS-E9AU6Q4rRXPhMOtDBmkxLd8g@mail.gmail.com>
Ezekiel Newren <ezekielnewren@gmail.com> writes:
Show 7 quoted lines
> In my compat/rust_types.h file (which was dropped) I defined isize > using ptrdiff_t rather than ssize_t. Maybe that file should be revived > so that we don't have confusion in code reviews when structs are being > expressly converted for the purpose of Rust FFI? I'd really like to > bring that file back so that everyone has a clear reference for how C > types map to Rust, but no one seemed to like it except me. Maybe it > should be an adoc file rather than a header?
I may be mistaken, but I thought that the latest agreement was to use conceptually the "same" type in each language, have each language call that type in its native way, and if needed convert at the FFI boundary. So if we agree to use, for example, 64-bit signed integer type for counting things plus returning error conditions via negative values, maybe C-side can agree to use i64 for it, without having to worry about how that thing is called in Rust side.
I am not sure in what way <compat/rust_types.h> should be used, and perhaps a documentation file may be sufficient as you suggest, but in any case, I agree that it should be made clear to everybody what C-types are to be mapped to what Rust types and vice versa, and if some C-types have no corresponding Rust type in that mapping, or if some Rust types have no corresponding C-type, that type needs to be converted before they reach the FFI boundary.