ioctl-macros 0.1.0

Rust macros that can be used to generate ioctl numbers on unix systems
Documentation
use std::os::raw::c_int;

extern {
    #[inline]
    pub fn _c_io(ty: c_int, nr: c_int) -> c_int;

    #[inline]
    pub fn _c_ior(ty: c_int, nr: c_int, size: c_int) -> c_int;

    #[inline]
    pub fn _c_iow(ty: c_int, nr: c_int, size: c_int) -> c_int;

    #[inline]
    pub fn _c_iowr(ty: c_int, nr: c_int, size: c_int) -> c_int;
}

#[macro_export]
macro_rules! io {
    ($ty:expr, $nr:expr) => (unsafe {
        $crate::_c_io(($ty) as i32, ($nr) as i32)
    })
}

#[macro_export]
macro_rules! ior {
    ($ty:expr, $nr:expr, $sz:ty) => (unsafe {
        $crate::_c_ior(($ty) as i32, ($nr) as i32, ::std::mem::size_of::<$sz>() as i32)
    })
}

#[macro_export]
macro_rules! iow {
    ($ty:expr, $nr:expr, $sz:ty) => (unsafe {
        $crate::_c_iow(($ty) as i32, ($nr) as i32, ::std::mem::size_of::<$sz>() as i32)
    })
}

#[macro_export]
macro_rules! iowr {
    ($ty:expr, $nr:expr, $sz:ty) => (unsafe {
        $crate::_c_iowr(($ty) as i32, ($nr) as i32, ::std::mem::size_of::<$sz>() as i32)
    })
}