#linux #libc

nightly no-std c-gull

A libc implementation in Rust

62 releases (9 breaking)

new 0.15.36 Dec 11, 2023
0.15.27 Nov 28, 2023
0.9.0 Jul 1, 2023
0.8.1 Mar 31, 2023
0.6.1 Nov 8, 2022

#56 in Date and time

Download history 1/week @ 2023-08-21 105/week @ 2023-08-28 28/week @ 2023-09-04 155/week @ 2023-09-11 436/week @ 2023-09-18 281/week @ 2023-09-25 290/week @ 2023-10-02 245/week @ 2023-10-09 301/week @ 2023-10-16 233/week @ 2023-10-23 332/week @ 2023-10-30 322/week @ 2023-11-06 801/week @ 2023-11-13 423/week @ 2023-11-20 395/week @ 2023-11-27 251/week @ 2023-12-04

1,912 downloads per month
Used in 4 crates (2 directly)


16K SLoC


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.

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, provided you're using nightly Rust. 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.


~327K SLoC