]>
Commit | Line | Data |
---|---|---|
3dfed10e | 1 | # libc - Raw FFI bindings to platforms' system libraries |
532ac7d7 | 2 | |
3dfed10e | 3 | [![Azure Status]][Azure] [![Cirrus CI Status]][Cirrus CI] [![Latest Version]][crates.io] [![Documentation]][docs.rs] ![License] |
476ff2be | 4 | |
532ac7d7 XL |
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. | |
476ff2be | 13 | |
532ac7d7 XL |
14 | More detailed information about the design of this library can be found in its |
15 | [associated RFC][rfc]. | |
16 | ||
17 | [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1291-promote-libc.md | |
476ff2be | 18 | |
476ff2be SL |
19 | ## Usage |
20 | ||
532ac7d7 | 21 | Add the following to your `Cargo.toml`: |
476ff2be SL |
22 | |
23 | ```toml | |
24 | [dependencies] | |
25 | libc = "0.2" | |
26 | ``` | |
27 | ||
532ac7d7 | 28 | ## Features |
476ff2be | 29 | |
416331ca | 30 | * `std`: by default `libc` links to the standard library. Disable this |
29967ef6 | 31 | feature to remove this dependency and be able to use `libc` in `#![no_std]` |
532ac7d7 | 32 | crates. |
476ff2be | 33 | |
532ac7d7 XL |
34 | * `extra_traits`: all `struct`s implemented in `libc` are `Copy` and `Clone`. |
35 | This feature derives `Debug`, `Eq`, `Hash`, and `PartialEq`. | |
476ff2be | 36 | |
dfeec247 | 37 | * `const-extern-fn`: Changes some `extern fn`s into `const extern fn`s. |
29967ef6 | 38 | This feature requires a nightly rustc. |
dfeec247 | 39 | |
416331ca XL |
40 | * **deprecated**: `use_std` is deprecated, and is equivalent to `std`. |
41 | ||
532ac7d7 | 42 | ## Rust version support |
476ff2be | 43 | |
532ac7d7 XL |
44 | The minimum supported Rust toolchain version is **Rust 1.13.0** . APIs requiring |
45 | newer Rust features are only available on newer Rust toolchains: | |
b7449926 | 46 | |
532ac7d7 XL |
47 | | Feature | Version | |
48 | |----------------------|---------| | |
49 | | `union` | 1.19.0 | | |
50 | | `const mem::size_of` | 1.24.0 | | |
51 | | `repr(align)` | 1.25.0 | | |
dfeec247 | 52 | | `extra_traits` | 1.25.0 | |
532ac7d7 | 53 | | `core::ffi::c_void` | 1.30.0 | |
dfeec247 | 54 | | `repr(packed(N))` | 1.33.0 | |
3dfed10e | 55 | | `cfg(target_vendor)` | 1.33.0 | |
b7449926 | 56 | |
532ac7d7 | 57 | ## Platform support |
476ff2be | 58 | |
532ac7d7 | 59 | [Platform-specific documentation (master branch)][docs.master]. |
476ff2be | 60 | |
532ac7d7 | 61 | See |
416331ca | 62 | [`ci/build.sh`](https://github.com/rust-lang/libc/blob/master/ci/build.sh) |
532ac7d7 | 63 | for the platforms on which `libc` is guaranteed to build for each Rust |
dfeec247 | 64 | toolchain. The test-matrix at [Azure] and [Cirrus CI] show the |
532ac7d7 | 65 | platforms in which `libc` tests are run. |
476ff2be | 66 | |
532ac7d7 | 67 | <div class="platform_docs"></div> |
476ff2be | 68 | |
532ac7d7 | 69 | ## License |
476ff2be | 70 | |
532ac7d7 | 71 | This project is licensed under either of |
476ff2be | 72 | |
dfeec247 | 73 | * [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
3dfed10e | 74 | ([LICENSE-APACHE](https://github.com/rust-lang/libc/blob/master/LICENSE-APACHE)) |
532ac7d7 | 75 | |
dfeec247 | 76 | * [MIT License](https://opensource.org/licenses/MIT) |
3dfed10e | 77 | ([LICENSE-MIT](https://github.com/rust-lang/libc/blob/master/LICENSE-MIT)) |
532ac7d7 XL |
78 | |
79 | at your option. | |
80 | ||
81 | ## Contributing | |
82 | ||
83 | We welcome all people who want to contribute. Please see the [contributing | |
84 | instructions] for more information. | |
85 | ||
3dfed10e | 86 | [contributing instructions]: https://github.com/rust-lang/libc/blob/master/CONTRIBUTING.md |
532ac7d7 XL |
87 | |
88 | Contributions in any form (issues, pull requests, etc.) to this project | |
89 | must adhere to Rust's [Code of Conduct]. | |
90 | ||
dfeec247 | 91 | [Code of Conduct]: https://www.rust-lang.org/policies/code-of-conduct |
532ac7d7 XL |
92 | |
93 | Unless you explicitly state otherwise, any contribution intentionally submitted | |
94 | for inclusion in `libc` by you, as defined in the Apache-2.0 license, shall be | |
95 | dual licensed as above, without any additional terms or conditions. | |
476ff2be | 96 | |
ba9703b0 | 97 | [Azure Status]: https://dev.azure.com/rust-lang2/libc/_apis/build/status/rust-lang.libc%20(1)?branchName=master |
e1599b0c | 98 | [Azure]: https://dev.azure.com/rust-lang2/libc/_build/latest?definitionId=1&branchName=master |
dfeec247 XL |
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 | |
532ac7d7 XL |
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 |