71 lines
1.9 KiB
Rust
71 lines
1.9 KiB
Rust
|
//! This defines the primitive types that may be seen
|
||
|
//! when creating 'C' bindings.
|
||
|
//!
|
||
|
//! There are several places where the target architecture and the OS
|
||
|
//! require special consideration. These are handled
|
||
|
//! with configuration statements.
|
||
|
|
||
|
// Character types.
|
||
|
#[cfg(any(target_os="android", target_os="emscripten",
|
||
|
all(target_os="linux",
|
||
|
any(target_arch="aarch64", target_arch="arm",
|
||
|
target_arch="powerpc", target_arch="powerpc64"))))]
|
||
|
pub type CChar = u8;
|
||
|
|
||
|
#[cfg(not(any(target_os="android", target_os="emscripten",
|
||
|
all(target_os="linux",
|
||
|
any(target_arch="aarch64", target_arch="arm",
|
||
|
target_arch="powerpc", target_arch="powerpc64")))))]
|
||
|
pub type CChar = i8;
|
||
|
|
||
|
|
||
|
pub type CIChar = i8;
|
||
|
pub type CUChar = u8;
|
||
|
|
||
|
|
||
|
|
||
|
// Integer types.
|
||
|
#[cfg(any(target_pointer_width="32", target_os="windows"))]
|
||
|
pub type CLong = i32;
|
||
|
|
||
|
#[cfg(any(target_pointer_width="32", target_os="windows"))]
|
||
|
pub type CULong = u32;
|
||
|
|
||
|
|
||
|
#[cfg(all(target_pointer_width="64", not(target_os="windows")))]
|
||
|
pub type CLong = i32;
|
||
|
|
||
|
#[cfg(all(target_pointer_width="64", not(target_os="windows")))]
|
||
|
pub type CULong = u32;
|
||
|
|
||
|
|
||
|
pub type CShort = i16;
|
||
|
pub type CUShort = u16;
|
||
|
pub type CInt = i32;
|
||
|
pub type CUInt = u32;
|
||
|
pub type CLongLong = u64;
|
||
|
pub type CULongLong = u64;
|
||
|
pub type CFloat = f32;
|
||
|
pub type CDouble = f64;
|
||
|
|
||
|
|
||
|
|
||
|
// Void types.
|
||
|
/// To return void from a 'C' function it should return an empty tuple ().
|
||
|
/// This type is just a descriptive version of that. **DO NOT** use this
|
||
|
/// as an argument to a function. Use the c_void type for that.
|
||
|
pub type CReturnVoid = ();
|
||
|
|
||
|
/// This acts as a 'C' void pointer to pass to functions. **DO NOT**
|
||
|
/// use this as a return type from a 'C' function. If a 'C' function
|
||
|
/// returns void, then use the c_return_void type for that.
|
||
|
#[repr(u8)]
|
||
|
pub enum CVoid
|
||
|
{
|
||
|
#[doc(hidden)]
|
||
|
_Variant,
|
||
|
|
||
|
#[doc(hidden)]
|
||
|
_Variant2
|
||
|
}
|