12add0d91Sopenharmony_ci# libc - Raw FFI bindings to platforms' system libraries
22add0d91Sopenharmony_ci
32add0d91Sopenharmony_ci[![GHA Status]][GitHub Actions] [![Cirrus CI Status]][Cirrus CI] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License]
42add0d91Sopenharmony_ci
52add0d91Sopenharmony_ci`libc` provides all of the definitions necessary to easily interoperate with C
62add0d91Sopenharmony_cicode (or "C-like" code) on each of the platforms that Rust supports. This
72add0d91Sopenharmony_ciincludes type definitions (e.g. `c_int`), constants (e.g. `EINVAL`) as well as
82add0d91Sopenharmony_cifunction headers (e.g. `malloc`).
92add0d91Sopenharmony_ci
102add0d91Sopenharmony_ciThis crate exports all underlying platform types, functions, and constants under
112add0d91Sopenharmony_cithe crate root, so all items are accessible as `libc::foo`. The types and values
122add0d91Sopenharmony_ciof all the exported APIs match the platform that libc is compiled for.
132add0d91Sopenharmony_ci
142add0d91Sopenharmony_ciMore detailed information about the design of this library can be found in its
152add0d91Sopenharmony_ci[associated RFC][rfc].
162add0d91Sopenharmony_ci
172add0d91Sopenharmony_ci[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1291-promote-libc.md
182add0d91Sopenharmony_ci
192add0d91Sopenharmony_ci## Usage
202add0d91Sopenharmony_ci
212add0d91Sopenharmony_ciAdd the following to your `Cargo.toml`:
222add0d91Sopenharmony_ci
232add0d91Sopenharmony_ci```toml
242add0d91Sopenharmony_ci[dependencies]
252add0d91Sopenharmony_cilibc = "0.2"
262add0d91Sopenharmony_ci```
272add0d91Sopenharmony_ci
282add0d91Sopenharmony_ci## Features
292add0d91Sopenharmony_ci
302add0d91Sopenharmony_ci* `std`: by default `libc` links to the standard library. Disable this
312add0d91Sopenharmony_ci  feature to remove this dependency and be able to use `libc` in `#![no_std]`
322add0d91Sopenharmony_ci  crates.
332add0d91Sopenharmony_ci
342add0d91Sopenharmony_ci* `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`.
352add0d91Sopenharmony_ci  This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`.
362add0d91Sopenharmony_ci
372add0d91Sopenharmony_ci* `const-extern-fn`: Changes some `extern fn`s into `const extern fn`s.
382add0d91Sopenharmony_ci  If you use Rust >= 1.62, this feature is implicitly enabled.
392add0d91Sopenharmony_ci  Otherwise it requires a nightly rustc.
402add0d91Sopenharmony_ci
412add0d91Sopenharmony_ci* **deprecated**: `use_std` is deprecated, and is equivalent to `std`.
422add0d91Sopenharmony_ci
432add0d91Sopenharmony_ci## Rust version support
442add0d91Sopenharmony_ci
452add0d91Sopenharmony_ciThe minimum supported Rust toolchain version is currently **Rust 1.13.0**.
462add0d91Sopenharmony_ci(libc does not currently have any policy regarding changes to the minimum
472add0d91Sopenharmony_cisupported Rust version; such policy is a work in progress.) APIs requiring
482add0d91Sopenharmony_cinewer Rust features are only available on newer Rust toolchains:
492add0d91Sopenharmony_ci
502add0d91Sopenharmony_ci| Feature              | Version |
512add0d91Sopenharmony_ci|----------------------|---------|
522add0d91Sopenharmony_ci| `union`              |  1.19.0 |
532add0d91Sopenharmony_ci| `const mem::size_of` |  1.24.0 |
542add0d91Sopenharmony_ci| `repr(align)`        |  1.25.0 |
552add0d91Sopenharmony_ci| `extra_traits`       |  1.25.0 |
562add0d91Sopenharmony_ci| `core::ffi::c_void`  |  1.30.0 |
572add0d91Sopenharmony_ci| `repr(packed(N))`    |  1.33.0 |
582add0d91Sopenharmony_ci| `cfg(target_vendor)` |  1.33.0 |
592add0d91Sopenharmony_ci| `const-extern-fn`    |  1.62.0 |
602add0d91Sopenharmony_ci
612add0d91Sopenharmony_ci## Platform support
622add0d91Sopenharmony_ci
632add0d91Sopenharmony_ci[Platform-specific documentation (master branch)][docs.master].
642add0d91Sopenharmony_ci
652add0d91Sopenharmony_ciSee
662add0d91Sopenharmony_ci[`ci/build.sh`](https://github.com/rust-lang/libc/blob/master/ci/build.sh)
672add0d91Sopenharmony_cifor the platforms on which `libc` is guaranteed to build for each Rust
682add0d91Sopenharmony_citoolchain. The test-matrix at [GitHub Actions] and [Cirrus CI] show the
692add0d91Sopenharmony_ciplatforms in which `libc` tests are run.
702add0d91Sopenharmony_ci
712add0d91Sopenharmony_ci<div class="platform_docs"></div>
722add0d91Sopenharmony_ci
732add0d91Sopenharmony_ci## License
742add0d91Sopenharmony_ci
752add0d91Sopenharmony_ciThis project is licensed under either of
762add0d91Sopenharmony_ci
772add0d91Sopenharmony_ci* [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)
782add0d91Sopenharmony_ci  ([LICENSE-APACHE](https://github.com/rust-lang/libc/blob/master/LICENSE-APACHE))
792add0d91Sopenharmony_ci
802add0d91Sopenharmony_ci* [MIT License](https://opensource.org/licenses/MIT)
812add0d91Sopenharmony_ci  ([LICENSE-MIT](https://github.com/rust-lang/libc/blob/master/LICENSE-MIT))
822add0d91Sopenharmony_ci
832add0d91Sopenharmony_ciat your option.
842add0d91Sopenharmony_ci
852add0d91Sopenharmony_ci## Contributing
862add0d91Sopenharmony_ci
872add0d91Sopenharmony_ciWe welcome all people who want to contribute. Please see the [contributing
882add0d91Sopenharmony_ciinstructions] for more information.
892add0d91Sopenharmony_ci
902add0d91Sopenharmony_ci[contributing instructions]: https://github.com/rust-lang/libc/blob/master/CONTRIBUTING.md
912add0d91Sopenharmony_ci
922add0d91Sopenharmony_ciContributions in any form (issues, pull requests, etc.) to this project
932add0d91Sopenharmony_cimust adhere to Rust's [Code of Conduct].
942add0d91Sopenharmony_ci
952add0d91Sopenharmony_ci[Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct
962add0d91Sopenharmony_ci
972add0d91Sopenharmony_ciUnless you explicitly state otherwise, any contribution intentionally submitted
982add0d91Sopenharmony_cifor inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be
992add0d91Sopenharmony_cidual licensed as above, without any additional terms or conditions.
1002add0d91Sopenharmony_ci
1012add0d91Sopenharmony_ci[GitHub Actions]: https://github.com/rust-lang/libc/actions
1022add0d91Sopenharmony_ci[GHA Status]: https://github.com/rust-lang/libc/workflows/CI/badge.svg
1032add0d91Sopenharmony_ci[Cirrus CI]: https://cirrus-ci.com/github/rust-lang/libc
1042add0d91Sopenharmony_ci[Cirrus CI Status]: https://api.cirrus-ci.com/github/rust-lang/libc.svg
1052add0d91Sopenharmony_ci[crates.io]: https://crates.io/crates/libc
1062add0d91Sopenharmony_ci[Latest Version]: https://img.shields.io/crates/v/libc.svg
1072add0d91Sopenharmony_ci[Documentation]: https://docs.rs/libc/badge.svg
1082add0d91Sopenharmony_ci[docs.rs]: https://docs.rs/libc
1092add0d91Sopenharmony_ci[License]: https://img.shields.io/crates/l/libc.svg
1102add0d91Sopenharmony_ci[docs.master]: https://rust-lang.github.io/libc/#platform-specific-documentation
111