• Stars
    star
    199
  • Rank 196,105 (Top 4 %)
  • Language
    Rust
  • License
    Other
  • Created about 1 year ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An implementation of libc written in Rust

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. And, #[no_builtins] interferes with LTO optimization.

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].

More Repositories

1

mustang

Rust programs written entirely in Rust
Rust
828
star
2

eyra

Rust programs written entirely in Rust
Rust
765
star
3

wasm-reference-manual

WebAssembly Reference Manual
564
star
4

origin

Program startup and thread support written in Rust
Rust
166
star
5

io-lifetimes

A low-level I/O ownership and borrowing library
Rust
94
star
6

hello-world-vs-io-errors

A repository about "Hello, World" programs and I/O errors
62
star
7

hello-wasi-http

Rust
57
star
8

nameless

Full-service command-line parsing
Rust
52
star
9

is-terminal

Test whether a given stream is a terminal
Rust
49
star
10

linux-raw-sys

Generated bindings for Linux's userspace API
Rust
39
star
11

llvm2cranelift

LLVM IR to Cranelift IR translator
Rust
30
star
12

origin-studio

An alternative `std`-like implementation built on origin
Rust
24
star
13

io-streams

Unbuffered and unlocked I/O streams
Rust
24
star
14

world-of-wasi-demo

A demo for my talk The World of WASI
Rust
21
star
15

hello-embedded

Hello Embedded!
Rust
21
star
16

io-extras

Non-owning unsafe I/O
Rust
20
star
17

ambient-authority

Ambient Authority
Rust
19
star
18

duplex

The Duplex trait: interactive streams
Rust
17
star
19

atomic-dbg

Atomic `dbg`/`eprintln`/`eprint` macros
Rust
17
star
20

eyra-c

Support for compiling C programs with Eyra
Rust
13
star
21

socketpair

Cross-platform socketpair functionality
Rust
10
star
22

office-hours

Open office hours
10
star
23

wasm-collection

A collection of miscellaenous valid wasm modules
8
star
24

mir2cranelift

Rust MIR to Cranelift IL translator (inactive; soon to be replaced)
Rust
8
star
25

rustix-futex-sync

Linux futex-based synchronization
Rust
8
star
26

utf8-io

Traits and types for UTF-8 I/O
Rust
6
star
27

io-arrays

Random-access I/O
Rust
6
star
28

basic-text

Basic Text strings and I/O streams
Rust
5
star
29

rustix-openpty

Rust
5
star
30

open-ambient

Open files and directories with constant paths
Rust
4
star
31

winx

A collection of miscellaneous Windows API utilities
Rust
4
star
32

linux-mount-api-documentation

Formatted copies of the Linux mount API manual page drafts
3
star
33

rustix-linux-procfs

Utilities for opening Linux procfs files and directories
Rust
3
star
34

terminal-io

Utilities for reading and writing on terminals
Rust
3
star
35

rustix-is-terminal

Test whether a given stream is a terminal, using rustix
Rust
2
star
36

dir-view

Views of cap-std's Dir
Rust
2
star
37

rustix-testing

Extra testing for rustix
Rust
2
star
38

cap-std-testing

Extra testing for cap-std
Rust
2
star
39

rustix-bench

Rust
2
star
40

char-device

Character Device I/O
Rust
2
star
41

nuttx-sys

Raw bindings to NuttX APIs
Rust
2
star
42

wasi-filesystem.wit

1
star
43

wasi-preview2

WASI Preview2 Proposal
1
star
44

intercomm

experiments in passing handles to std::process::Command
Rust
1
star
45

wasi-filesystem-presentation

1
star
46

codeexpr

Rust
1
star
47

windows-hello

Rust
1
star
48

wasi-random-presentation

Rust
1
star
49

layered-io

I/O traits extending Read and Write
Rust
1
star
50

annotated-types

An experiment which may turn into a WASI proposal
1
star
51

wasi-common-test

Rust
1
star
52

import-export-demo

Rust
1
star
53

sunfishcode.github.io

HTML
1
star
54

wasi-wiki

A Wiki for WASI designs
1
star