summaryrefslogtreecommitdiff
path: root/src/sys/ioctl/platform/bsd.rs
blob: a36808d785e49dd8cec7a66b3e2675e05bf189f8 (plain)
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
45
46
47
48
49
50
51
/// The datatype used for the ioctl number
#[doc(hidden)]
pub type ioctl_num_type = ::libc::c_ulong;

mod consts {
    use ::sys::ioctl::platform::ioctl_num_type;
    #[doc(hidden)]
    pub const VOID: ioctl_num_type = 0x2000_0000;
    #[doc(hidden)]
    pub const OUT: ioctl_num_type = 0x4000_0000;
    #[doc(hidden)]
    pub const IN: ioctl_num_type = 0x8000_0000;
    #[doc(hidden)]
    pub const INOUT: ioctl_num_type = (IN|OUT);
    #[doc(hidden)]
    pub const IOCPARM_MASK: ioctl_num_type = 0x1fff;
}

pub use self::consts::*;

#[macro_export]
#[doc(hidden)]
macro_rules! ioc {
    ($inout:expr, $group:expr, $num:expr, $len:expr) => (
        $inout | (($len as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::IOCPARM_MASK) << 16) | (($group as $crate::sys::ioctl::ioctl_num_type) << 8) | ($num as $crate::sys::ioctl::ioctl_num_type)
    )
}

#[macro_export]
#[doc(hidden)]
macro_rules! io {
    ($g:expr, $n:expr) => (ioc!($crate::sys::ioctl::VOID, $g, $n, 0))
}

#[macro_export]
#[doc(hidden)]
macro_rules! ior {
    ($g:expr, $n:expr, $len:expr) => (ioc!($crate::sys::ioctl::OUT, $g, $n, $len))
}

#[macro_export]
#[doc(hidden)]
macro_rules! iow {
    ($g:expr, $n:expr, $len:expr) => (ioc!($crate::sys::ioctl::IN, $g, $n, $len))
}

#[macro_export]
#[doc(hidden)]
macro_rules! iorw {
    ($g:expr, $n:expr, $len:expr) => (ioc!($crate::sys::ioctl::INOUT, $g, $n, $len))
}