ioctl_macros/
lib.rs

1use std::os::raw::c_int;
2
3extern {
4    #[inline]
5    pub fn _c_io(ty: c_int, nr: c_int) -> c_int;
6
7    #[inline]
8    pub fn _c_ior(ty: c_int, nr: c_int, size: c_int) -> c_int;
9
10    #[inline]
11    pub fn _c_iow(ty: c_int, nr: c_int, size: c_int) -> c_int;
12
13    #[inline]
14    pub fn _c_iowr(ty: c_int, nr: c_int, size: c_int) -> c_int;
15}
16
17#[macro_export]
18macro_rules! io {
19    ($ty:expr, $nr:expr) => (unsafe {
20        $crate::_c_io(($ty) as i32, ($nr) as i32)
21    })
22}
23
24#[macro_export]
25macro_rules! ior {
26    ($ty:expr, $nr:expr, $sz:ty) => (unsafe {
27        $crate::_c_ior(($ty) as i32, ($nr) as i32, ::std::mem::size_of::<$sz>() as i32)
28    })
29}
30
31#[macro_export]
32macro_rules! iow {
33    ($ty:expr, $nr:expr, $sz:ty) => (unsafe {
34        $crate::_c_iow(($ty) as i32, ($nr) as i32, ::std::mem::size_of::<$sz>() as i32)
35    })
36}
37
38#[macro_export]
39macro_rules! iowr {
40    ($ty:expr, $nr:expr, $sz:ty) => (unsafe {
41        $crate::_c_iowr(($ty) as i32, ($nr) as i32, ::std::mem::size_of::<$sz>() as i32)
42    })
43}
44