forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#94503 - joshtriplett:core-ffi-c, r=Amanieu
Provide C FFI types via core::ffi, not just in std Tracking issue: rust-lang#94501 The ability to interoperate with C code via FFI is not limited to crates using std; this allows using these types without std. The existing types in `std::os::raw` become type aliases for the ones in `core::ffi`. This uses type aliases rather than re-exports, to allow the std types to remain stable while the core types are unstable. This also moves the currently unstable `NonZero_` variants and `c_size_t`/`c_ssize_t`/`c_ptrdiff_t` types to `core::ffi`, while leaving them unstable. Historically, we didn't do this because these types are target-dependent. However, `core` itself is also target-dependent. `core` should not call any OS services, but it knows the target and the target's ABI.
- Loading branch information
Showing
23 changed files
with
283 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Equivalent to C's `void` type when used as a [pointer]. | ||
|
||
In essence, `*const c_void` is equivalent to C's `const void*` | ||
and `*mut c_void` is equivalent to C's `void*`. That said, this is | ||
*not* the same as C's `void` return type, which is Rust's `()` type. | ||
|
||
To model pointers to opaque types in FFI, until `extern type` is | ||
stabilized, it is recommended to use a newtype wrapper around an empty | ||
byte array. See the [Nomicon] for details. | ||
|
||
One could use `std::os::raw::c_void` if they want to support old Rust | ||
compiler down to 1.1.0. After Rust 1.30.0, it was re-exported by | ||
this definition. For more information, please read [RFC 2521]. | ||
|
||
[Nomicon]: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs | ||
[RFC 2521]: https://github.com/rust-lang/rfcs/blob/master/text/2521-c_void-reunification.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.