| 1 |
# libc - Raw FFI bindings to platforms' system libraries |
| 2 |
|
| 3 |
[![GHA Status]][GitHub Actions] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License] |
| 4 |
|
| 5 |
`libc` provides all of the definitions necessary to easily interoperate with C |
| 6 |
code (or "C-like" code) on each of the platforms that Rust supports. This |
| 7 |
includes type definitions (e.g. `c_int`), constants (e.g. `EINVAL`) as well as |
| 8 |
function headers (e.g. `malloc`). |
| 9 |
|
| 10 |
This crate exports all underlying platform types, functions, and constants under |
| 11 |
the crate root, so all items are accessible as `libc::foo`. The types and values |
| 12 |
of all the exported APIs match the platform that libc is compiled for. |
| 13 |
|
| 14 |
Windows API bindings are not included in this crate. If you are looking for |
| 15 |
WinAPI bindings, consider using crates like [windows-sys]. |
| 16 |
|
| 17 |
More detailed information about the design of this library can be found in its |
| 18 |
[associated RFC][rfc]. |
| 19 |
|
| 20 |
[rfc]: https://github.com/rust-lang/rfcs/blob/HEAD/text/1291-promote-libc.md |
| 21 |
[windows-sys]: https://docs.rs/windows-sys |
| 22 |
|
| 23 |
## v1.0 Roadmap |
| 24 |
|
| 25 |
Currently, `libc` has two active branches: `main` for the upcoming v1.0 release, |
| 26 |
and `libc-0.2` for the currently published version. By default all pull requests |
| 27 |
should target `main`; once reviewed, they can be cherry picked to the `libc-0.2` |
| 28 |
branch if needed. |
| 29 |
|
| 30 |
We will stop making new v0.2 releases once v1.0 is released. |
| 31 |
|
| 32 |
See the section in [CONTRIBUTING.md](CONTRIBUTING.md#v10-roadmap) for more |
| 33 |
details. |
| 34 |
|
| 35 |
## Usage |
| 36 |
|
| 37 |
Add the following to your `Cargo.toml`: |
| 38 |
|
| 39 |
```toml |
| 40 |
[dependencies] |
| 41 |
libc = "0.2" |
| 42 |
``` |
| 43 |
|
| 44 |
## Rust version support |
| 45 |
|
| 46 |
The minimum supported Rust toolchain version is currently **Rust 1.65**. |
| 47 |
|
| 48 |
Increases to the MSRV are allowed to change without a major (i.e. semver- |
| 49 |
breaking) release in order to avoid a ripple effect in the ecosystem. A policy |
| 50 |
for when this may change is a work in progress. |
| 51 |
|
| 52 |
`libc` may continue to compile with Rust versions older than the current MSRV |
| 53 |
but this is not guaranteed. |
| 54 |
|
| 55 |
## Platform support |
| 56 |
|
| 57 |
You can see the platform(target)-specific docs on [docs.rs], select a platform |
| 58 |
you want to see. |
| 59 |
|
| 60 |
See [`ci/verify-build.py`](https://github.com/rust-lang/libc/blob/HEAD/ci/verify-build.py) for |
| 61 |
the platforms on which `libc` is guaranteed to build for each Rust toolchain. |
| 62 |
The test matrices at [GitHub Actions] show the platforms in which `libc` tests |
| 63 |
are run. |
| 64 |
|
| 65 |
<div class="platform_docs"></div> |
| 66 |
|
| 67 |
## License |
| 68 |
|
| 69 |
This project is licensed under either of |
| 70 |
|
| 71 |
* [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
| 72 |
([LICENSE-APACHE](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-APACHE)) |
| 73 |
|
| 74 |
* [MIT License](https://opensource.org/licenses/MIT) |
| 75 |
([LICENSE-MIT](https://github.com/rust-lang/libc/blob/HEAD/LICENSE-MIT)) |
| 76 |
|
| 77 |
at your option. |
| 78 |
|
| 79 |
## Contributing |
| 80 |
|
| 81 |
We welcome all people who want to contribute. Please see the |
| 82 |
[contributing instructions] for more information. |
| 83 |
|
| 84 |
[contributing instructions]: https://github.com/rust-lang/libc/blob/HEAD/CONTRIBUTING.md |
| 85 |
|
| 86 |
Contributions in any form (issues, pull requests, etc.) to this project must |
| 87 |
adhere to Rust's [Code of Conduct]. |
| 88 |
|
| 89 |
[Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct |
| 90 |
|
| 91 |
Unless you explicitly state otherwise, any contribution intentionally submitted |
| 92 |
for inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be |
| 93 |
dual licensed as above, without any additional terms or conditions. |
| 94 |
|
| 95 |
[GitHub Actions]: https://github.com/rust-lang/libc/actions |
| 96 |
[GHA Status]: https://github.com/rust-lang/libc/workflows/CI/badge.svg |
| 97 |
[crates.io]: https://crates.io/crates/libc |
| 98 |
[Latest Version]: https://img.shields.io/crates/v/libc.svg |
| 99 |
[Documentation]: https://docs.rs/libc/badge.svg |
| 100 |
[docs.rs]: https://docs.rs/libc |
| 101 |
[License]: https://img.shields.io/crates/l/libc.svg |