82 releases (14 breaking)

0.20.3 Nov 27, 2024
0.19.2 Oct 9, 2024
0.16.1 May 22, 2024
0.15.41 Feb 29, 2024
0.6.1 Nov 8, 2022

#213 in Unix APIs

Download history 168/week @ 2024-08-19 18/week @ 2024-08-26 14/week @ 2024-09-02 5/week @ 2024-09-09 18/week @ 2024-09-16 71/week @ 2024-09-23 611/week @ 2024-09-30 963/week @ 2024-10-07 460/week @ 2024-10-14 124/week @ 2024-10-21 42/week @ 2024-10-28 139/week @ 2024-11-04 26/week @ 2024-11-11 59/week @ 2024-11-18 256/week @ 2024-11-25 73/week @ 2024-12-02

423 downloads per month
Used in 5 crates (2 directly)

Apache-2.0…

645KB
18K SLoC

c-gull

A libc implementation in Rust

Github Actions CI Status zulip chat crates.io page docs.rs docs

c-gull is a libc implementation. It is an implementation of the ABI described by the libc crate.

It is implemented in terms of crates written in Rust, such as c-scape, rustix, origin, libm, realpath-ext, tz-rs, printf-compat, num-complex, and posix-regex.

Currently it only supports *-*-linux-gnu ABIs, though other ABIs could be added in the future. And currently this mostly focused on features needed by Rust programs, so it doesn't have all the C-idiomatic things like qsort yet, but they could be added in the future.

The goal is to have very little code in c-gull itself, by factoring out all of the significant functionality into independent crates with more Rust-idiomatic APIs, with c-gull just wrapping those APIs to implement the C ABIs.

This is currently highly experimental, incomplete, and some things aren't optimized. And it depends on Nightly Rust.

c-gull's two modes

c-gull has two main cargo features: "take-charge" and "coexist-with-libc". One of these must be enabled.

In "take-charge" mode, c-gull takes charge of the process, handling program startup (via Origin) providing malloc (via c-scape), and other things. This requires some additional setup; see the c-gull-example example crate for more details.

In "coexist-with-libc" mode, c-gull can be used as a drop-in (partial) libc replacement. To use it, just change your typical libc dependency in Cargo.toml to this:

libc = { version = "<c-gull version>", package = "c-gull", features = ["coexist-with-libc"] }

and c-gull will replace as many of the system libc implementation with its own implementations as it can. In particular, it can't replace malloc or any of the pthread functions in this configuration, but it can replace many other things. See the libc-replacement example for more details.

Dependencies

~11–20MB
~365K SLoC