Re: [RFC PATCH 6/6] contrib/cgit-rs: add a subset of configset wrappers
- From
brian m. carlson <sandals@crustytoothpaste.net>
- Date
- Sep 4, 2024, 17:49 UTC
- Message-ID
- <ZtidjMThNwiI_QG8@tapette.crustytoothpaste.net>
- In-Reply-To
- <20240904173053.1220621-1-calvinwan@google.com>
On 2024-09-04 at 17:30:53, Calvin Wan wrote:
Show 8 quoted lines
> After getting rid of the `home` crate, the only other issue we ran into
> downgrading the version to 1.63 was with `std::ffi{c_char, c_int}`.
> Those were only made available in 1.64 and they are obviously quite
> necessary for us to be able to call C functions. Do you know of any
> alternatives we can use? I also don't think reinventing the wheel with
> our own implementation makes sense in this case, and even if Debian were
> to upgrade stable to a higher version today, we would still need to
> support oldstable for another year.I think we can do this with libc, which you're importing at the moment. You can do something like this:
src/types.rs: ---- pub use libc::{c_char, c_int}; ----
and then do `use crate::types::{c_char, c_int}` wherever you want them.Then, when we upgrade to 1.64 or newer, we can simply replace the contents of `src/types.rs` with this:
---- pub use std::ffi::{c_char, c_int}; ----
and that's the only thing we'll need to change.
If we switch to using rustix instead, then it will look like this:
---- pub use rustix::ffi::c_char;
pub type c_int = i32; ----
While the C standard requires that `int` only has 16 bits, Git doesn't target any platforms where `int` is anything but 32 bits and it won't work with any other configuration without serious changes.
-- brian m. carlson (they/them or he/him) Toronto, Ontario, CA