1[![Azure Status]][Azure] [![Cirrus CI Status]][Cirrus CI] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License] 2 3libc - Raw FFI bindings to platforms' system libraries 4==== 5 6`libc` provides all of the definitions necessary to easily interoperate with C 7code (or "C-like" code) on each of the platforms that Rust supports. This 8includes type definitions (e.g. `c_int`), constants (e.g. `EINVAL`) as well as 9function headers (e.g. `malloc`). 10 11This crate exports all underlying platform types, functions, and constants under 12the crate root, so all items are accessible as `libc::foo`. The types and values 13of all the exported APIs match the platform that libc is compiled for. 14 15More detailed information about the design of this library can be found in its 16[associated RFC][rfc]. 17 18[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1291-promote-libc.md 19 20## Usage 21 22Add the following to your `Cargo.toml`: 23 24```toml 25[dependencies] 26libc = "0.2" 27``` 28 29## Features 30 31* `std`: by default `libc` links to the standard library. Disable this 32 feature remove this dependency and be able to use `libc` in `#![no_std]` 33 crates. 34 35* `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`. 36 This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`. 37 38* `const-extern-fn`: Changes some `extern fn`s into `const extern fn`s. 39 This features requires a nightly rustc 40 41* **deprecated**: `use_std` is deprecated, and is equivalent to `std`. 42 43## Rust version support 44 45The minimum supported Rust toolchain version is **Rust 1.13.0** . APIs requiring 46newer Rust features are only available on newer Rust toolchains: 47 48| Feature | Version | 49|----------------------|---------| 50| `union` | 1.19.0 | 51| `const mem::size_of` | 1.24.0 | 52| `repr(align)` | 1.25.0 | 53| `extra_traits` | 1.25.0 | 54| `core::ffi::c_void` | 1.30.0 | 55| `repr(packed(N))` | 1.33.0 | 56 57## Platform support 58 59[Platform-specific documentation (master branch)][docs.master]. 60 61See 62[`ci/build.sh`](https://github.com/rust-lang/libc/blob/master/ci/build.sh) 63for the platforms on which `libc` is guaranteed to build for each Rust 64toolchain. The test-matrix at [Azure] and [Cirrus CI] show the 65platforms in which `libc` tests are run. 66 67<div class="platform_docs"></div> 68 69## License 70 71This project is licensed under either of 72 73* [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) 74 ([LICENSE-APACHE](LICENSE-APACHE)) 75 76* [MIT License](https://opensource.org/licenses/MIT) 77 ([LICENSE-MIT](LICENSE-MIT)) 78 79at your option. 80 81## Contributing 82 83We welcome all people who want to contribute. Please see the [contributing 84instructions] for more information. 85 86[contributing instructions]: CONTRIBUTING.md 87 88Contributions in any form (issues, pull requests, etc.) to this project 89must adhere to Rust's [Code of Conduct]. 90 91[Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct 92 93Unless you explicitly state otherwise, any contribution intentionally submitted 94for inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be 95dual licensed as above, without any additional terms or conditions. 96 97[Azure Status]: https://dev.azure.com/rust-lang2/libc/_apis/build/status/rust-lang.libc?branchName=master 98[Azure]: https://dev.azure.com/rust-lang2/libc/_build/latest?definitionId=1&branchName=master 99[Cirrus CI]: https://cirrus-ci.com/github/rust-lang/libc 100[Cirrus CI Status]: https://api.cirrus-ci.com/github/rust-lang/libc.svg 101[crates.io]: https://crates.io/crates/libc 102[Latest Version]: https://img.shields.io/crates/v/libc.svg 103[Documentation]: https://docs.rs/libc/badge.svg 104[docs.rs]: https://docs.rs/libc 105[License]: https://img.shields.io/crates/l/libc.svg 106[docs.master]: https://rust-lang.github.io/libc/#platform-specific-documentation 107