-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from getditto/libc-improvements
`libc` improvements
- Loading branch information
Showing
10 changed files
with
110 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ path = "src/_lib.rs" | |
|
||
[package] | ||
name = "safer-ffi" | ||
version = "0.1.1" # Keep in sync | ||
version = "0.1.2" # Keep in sync | ||
authors = [ | ||
"Daniel Henry-Mantilla <[email protected]>", | ||
] | ||
|
@@ -126,6 +126,9 @@ inventory-0-3-1.optional = true | |
inventory-0-3-1.package = "inventory" | ||
inventory-0-3-1.version = "0.3.1" | ||
|
||
libc.version = "0.2.66" | ||
libc.default-features = false | ||
|
||
log.optional = true | ||
log.version = "0.4.8" | ||
|
||
|
@@ -161,11 +164,7 @@ version = "0.0.3" | |
|
||
[dependencies.safer_ffi-proc_macros] | ||
path = "src/proc_macro" | ||
version = "=0.1.1" # Keep in sync | ||
|
||
[target.'cfg(not(target = "wasm32-unknown-unknown"))'.dependencies] | ||
libc.version = "0.2.66" | ||
libc.default-features = false | ||
version = "=0.1.2" # Keep in sync | ||
|
||
[workspace] | ||
members = [ | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,73 @@ | ||
#![cfg_attr(rustfmt, rustfmt::skip)] | ||
//! On certain platforms, `::libc` has no definitions for pervasive types such as `size_t`. | ||
//! | ||
//! We polyfill them here, and reëxport them for downstream users to use at leisure | ||
//! (_e.g._, so that they don't have to do that themselves too!). | ||
//! | ||
//! ```rust | ||
//! # #[cfg(any())] macro_rules! ignore { | ||
#![doc = stringified_module_code!()] | ||
//! # } | ||
#![allow(warnings, clippy::all)] | ||
|
||
use_libc_or_else! { | ||
pub use ::libc::{ | ||
/// Note: your should probably be using [`crate::c_char`] instead. | ||
c_char else u8, | ||
/// Note: your should probably be using [`crate::c_int`] instead. | ||
c_int else ::core::ffi::c_int, | ||
/// | ||
size_t else usize, | ||
/// | ||
uintptr_t else usize, | ||
}; | ||
} | ||
|
||
macro_rules! use_libc_or_else_ {( | ||
pub use ::libc::{ | ||
$( | ||
$(#$doc:tt)* | ||
$c_type:ident else $FallbackTy:ty | ||
),* $(,)? | ||
}; | ||
) => ( | ||
|
||
$( | ||
#[doc = concat!("A _`type` alias_ to [`::libc::", stringify!($c_type), "`].")] | ||
/// | ||
$(#$doc)* | ||
pub type $c_type = helper::$c_type; | ||
)* | ||
|
||
mod helper { | ||
mod real_libc { | ||
pub use ::libc::*; | ||
$( | ||
pub const $c_type: () = (); | ||
)* | ||
} | ||
|
||
pub use real_libc::{ | ||
$( | ||
$c_type, | ||
)* | ||
}; | ||
|
||
pub use fallback::*; | ||
mod fallback { | ||
$( | ||
pub type $c_type = $FallbackTy; | ||
)* | ||
} | ||
} | ||
)} use use_libc_or_else_; | ||
|
||
macro_rules! use_libc_or_else {( | ||
$($input:tt)* | ||
) => ( | ||
macro_rules! stringified_module_code {() => ( | ||
stringify!($($input)*) | ||
)} | ||
|
||
use_libc_or_else_!($($input)*); | ||
)} use use_libc_or_else; |
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ proc-macro = true | |
|
||
[package] | ||
name = "safer_ffi-proc_macros" | ||
version = "0.1.1" # Keep in sync | ||
version = "0.1.2" # Keep in sync | ||
authors = ["Daniel Henry-Mantilla <[email protected]>"] | ||
edition = "2021" | ||
|
||
|
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