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
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)
    })
}