Crate c_gull

source ·
Expand description

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, sync-resolve, libm, realpath-ext, tz-rs, printf-compat, and rand.

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 many C-idiomatic things like printf 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.

This is part of the Mustang project, building Rust programs written entirely in Rust.

Using c-gull in non-mustang programs

c-gull can also be used as a drop-in (partial) libc replacement in non-mustang builds, 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" }

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.

Structs

af_alg_ivDeprecated
WARNING: The PartialEq, Eq and Hash implementations of this type are unsound and will be removed in the future.

Enums

Equivalent to C’s void type when used as a pointer.

Constants

maximum number of services provided on the same listening port
ENOATTRDeprecated
IP6 Auth Header
IP Payload Comp. Protocol
IP6 destination option
exterior gateway protocol
encapsulation header
IP6 Encap Sec. Payload
IP6 fragmentation header
General Routing Encap.
Hop-by-hop option header
group mgmt protocol
for compatibility
IPPROTO_MAXDeprecated
Multipath TCP
IP6 no next header
Protocol indep. multicast
raw IP packet
IP6 routing header
resource reservation
tp-4 w/ class negotiation
SIGUNUSEDDeprecated

Functions

abs
acct
atof
atoi
bind
brk
dup
dup2
dup3
exit
feof
fork
free
ftok
glob
GNU version of basename(3), defined in string.h.
kill
labs
link
mmap
nice
open
pipe
poll
POSIX version of basename(3), defined in libgen.h.
puts
rand
read
The 64-bit libc on Solaris and illumos only has readdir_r. If a 32-bit Solaris or illumos target is ever created, it should use __posix_readdir_r. See libc(3LIB) on Solaris or illumos: https://illumos.org/man/3lib/libc https://docs.oracle.com/cd/E36784_01/html/E36873/libc-3lib.html https://www.unix.com/man-page/opensolaris/3LIB/libc/
recv
sbrk
send
stat
sync
tee
time
vforkDeprecated
wait

Type Definitions

Unions