Re: [RFC PATCH 6/6] contrib/cgit-rs: add a subset of configset wrappers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024-09-04 at 17:30:53, Calvin Wan wrote:
> 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

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux