// SPDX-License-Identifier: GPL-2.012//! Foreign function interface (FFI) types.3//!4//! This crate provides mapping from C primitive types to Rust ones.5//!6//! The Rust [`core`] crate provides [`core::ffi`], which maps integer types to the platform default7//! C ABI. The kernel does not use [`core::ffi`], so it can customise the mapping that deviates from8//! the platform default.910#![no_std]1112macro_rules! alias {13($($name:ident = $ty:ty;)*) => {$(14#[allow(non_camel_case_types, missing_docs)]15pub type $name = $ty;1617// Check size compatibility with `core`.18const _: () = assert!(19::core::mem::size_of::<$name>() == ::core::mem::size_of::<::core::ffi::$name>()20);21)*}22}2324alias! {25// `core::ffi::c_char` is either `i8` or `u8` depending on architecture. In the kernel, we use26// `-funsigned-char` so it's always mapped to `u8`.27c_char = u8;2829c_schar = i8;30c_uchar = u8;3132c_short = i16;33c_ushort = u16;3435c_int = i32;36c_uint = u32;3738// In the kernel, `intptr_t` is defined to be `long` in all platforms, so we can map the type to39// `isize`.40c_long = isize;41c_ulong = usize;4243c_longlong = i64;44c_ulonglong = u64;45}4647pub use core::ffi::c_void;484950