Skip to content
/ c-ward Public
forked from sunfishcode/c-ward

An implementation of libc written in Rust

License

Notifications You must be signed in to change notification settings

rice7th/c-ward

This branch is 11 commits ahead of, 47 commits behind sunfishcode/c-ward:main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

836a977 · Feb 28, 2024
Dec 12, 2023
Dec 23, 2023
Feb 28, 2024
Feb 28, 2024
Sep 25, 2023
Nov 14, 2023
Feb 27, 2024
Sep 14, 2023
Sep 11, 2023
Sep 11, 2023
Sep 11, 2023
Feb 28, 2024
Sep 11, 2023
Sep 11, 2023
Sep 11, 2023
Sep 11, 2023
Feb 17, 2024
Feb 26, 2024

Repository files navigation

c-ward

An implementation of libc written in Rust

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

c-ward is an implementation of the libc ABI written in Rust.

It consists of two crates:

  • c-scape, which is no_std, and
  • c-gull, which pulls in c-scape and additionally provides features using std.

It is a goal of c-ward to be a C ABI layer on top of Rust-idomatic libraries, rather than to have significant implementation code of its own.

In theory c-ward could be extended to be ABI-compatible with different platforms, however currently it is only known to be ABI-compatible with *-unknown-linux-gnu* platforms.

The primary way this is used is through Mustang and Eyra, as their libc implementations. It can also be used as a regular library in "coexist-with-libc" mode.

Similar crates

Another libc implementation is relibc. tinyrlibc is a very minimal set of libc functions for bare-metal embedded platforms.

Where's the #![no_builtins]?

Normally, a libc implementation would use #[no_builtins] to prevent compilers from noticing the bodies of libc functions implement the semantics of libc functions and replacing them with calls, which effectively makes them uselessly recursive calls to themselves.

However, #[no_builtins] is too pessimistic, because we don't need to disable all pattern matching, just these specific cases.

So instead, c-scape and c-gull are just careful to avoid open-coding functions which are known to get pattern-matched into builtins, by just calling the compiler_builtins implementations directly themselves. This way, we can avoid using #![no_builtins].

About

An implementation of libc written in Rust

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%