Skip to content

Consistent c_char #1261

Closed
Closed
@Stebalien

Description

@Stebalien

At the moment, there are three possible configurations for rustix on linux:

  1. libc.
  2. linux-raw-sys with the "std" feature.
  3. linux-raw-sys without the "std" feature.

It's not currently feasible to support all three configurations, at least when the "std" feature in rustix is enabled.

  1. rustix::ffi::c_char will always be the same as core::ffi::c_char (given that the "std" feature is enabled in rustix).
  2. linux_raw_sys::ctypes::c_char will be i8 or u8 depending on the platform and whether or not "std" is enabled.

If I use linux_raw_sys::ctypes::c_char in my project (xattr) when, e.g., calling rustix::fs::listxattr, I'm able to support the linux-raw-sys backend both with and without the "linux-raw-sys/std" feature, but the libc backend won't work as expected. If, instead, I use rustix::ffi::c_char, I can support the libc and linux-raw-sys backends when the "linux-raw-sys/std" feature is enabled (explicitly, see #945 because it's not enabled by default) but the linux-raw-sys backend won't work without said feature.

So ether:

  1. rustix needs to re-export the correct c_char. E.g., rustix::ffi::c_char needs to be linux_raw_sys::ctypes::c_char when the linux_raw_sys backend is in use.
  2. linux_raw_sys needs to use core::ffi::c_char.

Ideally the second option for maximum compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions