1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 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: you should probably be using [`crate::c_char`] instead.
c_char else u8,
/// Note: you 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 stringified_module_code;
use_libc_or_else_!($($input)*);
)} use use_libc_or_else;