Skip to content

Split libc into types and impl crates #881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vi opened this issue Dec 19, 2017 · 4 comments
Closed

Split libc into types and impl crates #881

vi opened this issue Dec 19, 2017 · 4 comments

Comments

@vi
Copy link
Contributor

vi commented Dec 19, 2017

C libraries (including system ones like glibc or musl) change, but C fundamentals stay put.

I expect many FFI bindings may rely only on fundamental language-provided types like size_t and c_void, not on specific library-provided ones like sockaddr or FILE.

To bring more stability to such use case, libc may be split into something like libc-pure with only type-level things that are expected to change when C as a language changes and libc-sys with everything else. libc itself is just a bunch of re-exports.

Exact splitting line and naming details is left to further discussion. A simple no-brainer constraint maybe that unix:notbsd:fexecve and c_int should appear on opposite sides of the barricades.

@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 4, 2018

There has been discussion about exposing a ctypes crate somewhere: rust-lang/rust#36193

It's a bit tricky because c_void is something that one might want to expose in core.

@vi
Copy link
Contributor Author

vi commented Feb 4, 2018

As Rust as a language is somewhat defined in C terms (so inherently relies on it), maybe multiple low-level primitive C types should be in core?

If #[repr(C)] directly mentions C, why not core?

@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 4, 2018

Because core is platform-independent while std is platform dependent (and hence why the ctypes are already in std::os::raw). The only ctype that is platform independent is c_void AFAIK.

@gnzlbg
Copy link
Contributor

gnzlbg commented Nov 22, 2018

FYI c_void is already in core::ffi - if you only want ctypes, you should check out the cty crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants