On 2024-09-04 at 18:33:17, Junio C Hamano wrote: > Is it "we need to access the guts of Git implementation from Rust"? > Or does it merely serve as an example application to have Rust > bindings, a good goal to have to give us an incentive to clean up > the subsystem interactions in our code? > > If it is the former, we cannot reasonably achieve that goal until > some form of standardized foreign function interface becomes > available to wide audience. If it is the latter, on the other hand, > it does not have to be Rust---if the version of Rust that is > distirbuted to the mainstream users is not yet ready to be used in > such a way, we could pick another goal (like, "Can we clean-up the > interface cgit uses to call into us, so that the parts used by them > look more like a proper library?"). Traditionally, in Rust, you don't use the C-style types because that leads to portability problems. Look at how using "unsigned long" as "equivalent in size to void *" has gotten our C code to have sharp edges on Windows, where that isn't true. The approach one typically uses is to use things like int32_t, which is i32 in Rust, and size_t, which is usize in Rust. This leads to much more predictable behaviour on both sides of the FFI. The C-style types have long been available in libc and other crates that are designed to work with C FFI, and as a practical matter you do need to use that crate somewhere in your stack (or reimplement it) to call functions in libc and the other core system libraries, so you're not really lacking those types. They're also available in the `std::os::raw` module as of Rust 1.1; it's just that as of Rust 1.64, they're in `std::ffi` and `core::ffi` as well, mostly to help embedded systems (which don't have `std`, and thus, don't have `std::os::raw`). Using `std::os::raw` or `libc` should be fine for Git, since we're not targeting operating system kernels, bootloaders, or firmware such as UEFI (I hope). -- brian m. carlson (they/them or he/him) Toronto, Ontario, CA
Attachment:
signature.asc
Description: PGP signature