1c4c45267SYuki Okushi# libc - Raw FFI bindings to platforms' system libraries 283298283Sgnzlbg 35b2bdd11SYuki Okushi[![GHA Status]][GitHub Actions] [![Cirrus CI Status]][Cirrus CI] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License] 468fe98bdSAlex Crichton 583298283Sgnzlbg`libc` provides all of the definitions necessary to easily interoperate with C 683298283Sgnzlbgcode (or "C-like" code) on each of the platforms that Rust supports. This 783298283Sgnzlbgincludes type definitions (e.g. `c_int`), constants (e.g. `EINVAL`) as well as 883298283Sgnzlbgfunction headers (e.g. `malloc`). 913418a50SAlex Crichton 1013418a50SAlex CrichtonThis crate exports all underlying platform types, functions, and constants under 1113418a50SAlex Crichtonthe crate root, so all items are accessible as `libc::foo`. The types and values 1213418a50SAlex Crichtonof all the exported APIs match the platform that libc is compiled for. 1313418a50SAlex Crichton 146a4da8f2STrevor GrossWindows API bindings are not included in this crate. If you are looking for 156a4da8f2STrevor GrossWinAPI bindings, consider using crates like [windows-sys]. 165951de50SStepan Koltsov 17bbf73dedSAlex CrichtonMore detailed information about the design of this library can be found in its 18bbf73dedSAlex Crichton[associated RFC][rfc]. 19bbf73dedSAlex Crichton 2007f7c833SJosh Triplett[rfc]: https://github.com/rust-lang/rfcs/blob/HEAD/text/1291-promote-libc.md 215951de50SStepan Koltsov[windows-sys]: https://docs.rs/windows-sys 22bbf73dedSAlex Crichton 235d234d26STrevor Gross## v1.0 Roadmap 24f8c19f5cSYuki Okushi 255d234d26STrevor GrossCurrently, `libc` has two active branches: `main` for the upcoming v1.0 release, 265d234d26STrevor Grossand `libc-0.2` for the currently published version. By default all pull requests 275d234d26STrevor Grossshould target `main`; once reviewed, they can be cherry picked to the `libc-0.2` 285d234d26STrevor Grossbranch if needed. 29f8c19f5cSYuki Okushi 305d234d26STrevor GrossWe will stop making new v0.2 releases once v1.0 is released. 31f8c19f5cSYuki Okushi 325d234d26STrevor GrossSee the section in [CONTRIBUTING.md](CONTRIBUTING.md#v10-roadmap) for more 336a4da8f2STrevor Grossdetails. 34f8c19f5cSYuki Okushi 3583298283Sgnzlbg## Usage 3613418a50SAlex Crichton 3783298283SgnzlbgAdd the following to your `Cargo.toml`: 3813418a50SAlex Crichton 3983298283Sgnzlbg```toml 4083298283Sgnzlbg[dependencies] 4183298283Sgnzlbglibc = "0.2" 4283298283Sgnzlbg``` 4313418a50SAlex Crichton 4483298283Sgnzlbg## Features 4513418a50SAlex Crichton 466a4da8f2STrevor Gross* `std`: by default `libc` links to the standard library. Disable this feature 476a4da8f2STrevor Gross to remove this dependency and be able to use `libc` in `#![no_std]` crates. 4813418a50SAlex Crichton 4983298283Sgnzlbg* `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`. 50cd49efc9Sgnzlbg This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`. 51524e1374SAlex Crichton 52674cc1f4STrevor GrossThe following features are deprecated: 53674cc1f4STrevor Gross 54674cc1f4STrevor Gross* `use_std`: this is equivalent to `std` 55674cc1f4STrevor Gross* `const-extern-fn`: this is now enabled by default 56674cc1f4STrevor Gross* `align`: this is now enabled by default 575dfc2c82SAaron Hill 5883298283Sgnzlbg## Rust version support 59524e1374SAlex Crichton 6093052d15STrevor GrossThe minimum supported Rust toolchain version is currently **Rust 1.63**. 61cba130bcSKai Noda 6293052d15STrevor GrossIncreases to the MSRV are allowed to change without a major (i.e. semver- 635d234d26STrevor Grossbreaking) release in order to avoid a ripple effect in the ecosystem. A policy 645d234d26STrevor Grossfor when this may change is a work in progress. 6593052d15STrevor Gross 6693052d15STrevor Gross`libc` may continue to compile with Rust versions older than the current MSRV 6793052d15STrevor Grossbut this is not guaranteed. 68cba130bcSKai Noda 6983298283Sgnzlbg## Platform support 70cba130bcSKai Noda 716a4da8f2STrevor GrossYou can see the platform(target)-specific docs on [docs.rs], select a platform 726a4da8f2STrevor Grossyou want to see. 7397a158b3SAlex Crichton 74*81c931f9SMohamed AttiaSee [`ci/verify-build.sh`](https://github.com/rust-lang/libc/blob/HEAD/ci/verify-build.sh) for 756a4da8f2STrevor Grossthe platforms on which `libc` is guaranteed to build for each Rust toolchain. 766a4da8f2STrevor GrossThe test-matrix at [GitHub Actions] and [Cirrus CI] show the platforms in which 776a4da8f2STrevor Gross`libc` tests are run. 7897a158b3SAlex Crichton 7983298283Sgnzlbg<div class="platform_docs"></div> 8097a158b3SAlex Crichton 8183298283Sgnzlbg## License 8297a158b3SAlex Crichton 8383298283SgnzlbgThis project is licensed under either of 8413418a50SAlex Crichton 85284184d1SAlex Touchet* [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) 8607f7c833SJosh Triplett ([LICENSE-APACHE](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-APACHE)) 8778f5acadSAlex Crichton 88284184d1SAlex Touchet* [MIT License](https://opensource.org/licenses/MIT) 8907f7c833SJosh Triplett ([LICENSE-MIT](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-MIT)) 9078f5acadSAlex Crichton 9183298283Sgnzlbgat your option. 9213418a50SAlex Crichton 9383298283Sgnzlbg## Contributing 9483298283Sgnzlbg 956a4da8f2STrevor GrossWe welcome all people who want to contribute. Please see the 966a4da8f2STrevor Gross[contributing instructions] for more information. 9783298283Sgnzlbg 9807f7c833SJosh Triplett[contributing instructions]: https://github.com/rust-lang/libc/blob/HEAD/CONTRIBUTING.md 9983298283Sgnzlbg 1006a4da8f2STrevor GrossContributions in any form (issues, pull requests, etc.) to this project must 1016a4da8f2STrevor Grossadhere to Rust's [Code of Conduct]. 10283298283Sgnzlbg 103284184d1SAlex Touchet[Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct 10483298283Sgnzlbg 10583298283SgnzlbgUnless you explicitly state otherwise, any contribution intentionally submitted 10683298283Sgnzlbgfor inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be 10783298283Sgnzlbgdual licensed as above, without any additional terms or conditions. 10883298283Sgnzlbg 1095b2bdd11SYuki Okushi[GitHub Actions]: https://github.com/rust-lang/libc/actions 1105b2bdd11SYuki Okushi[GHA Status]: https://github.com/rust-lang/libc/workflows/CI/badge.svg 111284184d1SAlex Touchet[Cirrus CI]: https://cirrus-ci.com/github/rust-lang/libc 112284184d1SAlex Touchet[Cirrus CI Status]: https://api.cirrus-ci.com/github/rust-lang/libc.svg 11383298283Sgnzlbg[crates.io]: https://crates.io/crates/libc 11483298283Sgnzlbg[Latest Version]: https://img.shields.io/crates/v/libc.svg 11583298283Sgnzlbg[Documentation]: https://docs.rs/libc/badge.svg 11683298283Sgnzlbg[docs.rs]: https://docs.rs/libc 11783298283Sgnzlbg[License]: https://img.shields.io/crates/l/libc.svg 118