summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/sys/ioctl/mod.rs1
-rw-r--r--src/sys/ioctl/platform/bsd.rs10
-rw-r--r--src/sys/ioctl/platform/linux.rs33
3 files changed, 44 insertions, 0 deletions
diff --git a/src/sys/ioctl/mod.rs b/src/sys/ioctl/mod.rs
index ac8ff149..6a799876 100644
--- a/src/sys/ioctl/mod.rs
+++ b/src/sys/ioctl/mod.rs
@@ -120,6 +120,7 @@ pub use ::libc as libc;
/// Convert raw ioctl return value to a Nix result
#[macro_export]
+#[doc(hidden)]
macro_rules! convert_ioctl_res {
($w:expr) => (
{
diff --git a/src/sys/ioctl/platform/bsd.rs b/src/sys/ioctl/platform/bsd.rs
index 57b4d637..df3716b9 100644
--- a/src/sys/ioctl/platform/bsd.rs
+++ b/src/sys/ioctl/platform/bsd.rs
@@ -1,14 +1,20 @@
mod consts {
+ #[doc(hidden)]
pub const VOID: u32 = 0x20000000;
+ #[doc(hidden)]
pub const OUT: u32 = 0x40000000;
+ #[doc(hidden)]
pub const IN: u32 = 0x80000000;
+ #[doc(hidden)]
pub const INOUT: u32 = (IN|OUT);
+ #[doc(hidden)]
pub const IOCPARM_MASK: u32 = 0x1fff;
}
pub use self::consts::*;
#[macro_export]
+#[doc(hidden)]
macro_rules! ioc {
($inout:expr, $group:expr, $num:expr, $len:expr) => (
$inout | (($len as u32 & $crate::sys::ioctl::IOCPARM_MASK) << 16) | (($group as u32) << 8) | ($num as u32)
@@ -16,21 +22,25 @@ macro_rules! ioc {
}
#[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))
}
diff --git a/src/sys/ioctl/platform/linux.rs b/src/sys/ioctl/platform/linux.rs
index cdf5b20a..00a25e88 100644
--- a/src/sys/ioctl/platform/linux.rs
+++ b/src/sys/ioctl/platform/linux.rs
@@ -1,12 +1,19 @@
+#[doc(hidden)]
pub const NRBITS: u32 = 8;
+#[doc(hidden)]
pub const TYPEBITS: u32 = 8;
#[cfg(any(target_arch = "mips", target_arch = "mips64", target_arch = "powerpc", target_arch = "powerpc64"))]
mod consts {
+ #[doc(hidden)]
pub const NONE: u8 = 1;
+ #[doc(hidden)]
pub const READ: u8 = 2;
+ #[doc(hidden)]
pub const WRITE: u8 = 4;
+ #[doc(hidden)]
pub const SIZEBITS: u8 = 13;
+ #[doc(hidden)]
pub const DIRBITS: u8 = 3;
}
@@ -28,27 +35,41 @@ use this_arch_not_supported;
target_arch = "x86_64",
target_arch = "aarch64"))]
mod consts {
+ #[doc(hidden)]
pub const NONE: u8 = 0;
+ #[doc(hidden)]
pub const READ: u8 = 2;
+ #[doc(hidden)]
pub const WRITE: u8 = 1;
+ #[doc(hidden)]
pub const SIZEBITS: u8 = 14;
+ #[doc(hidden)]
pub const DIRBITS: u8 = 2;
}
pub use self::consts::*;
+#[doc(hidden)]
pub const NRSHIFT: u32 = 0;
+#[doc(hidden)]
pub const TYPESHIFT: u32 = NRSHIFT + NRBITS as u32;
+#[doc(hidden)]
pub const SIZESHIFT: u32 = TYPESHIFT + TYPEBITS as u32;
+#[doc(hidden)]
pub const DIRSHIFT: u32 = SIZESHIFT + SIZEBITS as u32;
+#[doc(hidden)]
pub const NRMASK: u32 = (1 << NRBITS) - 1;
+#[doc(hidden)]
pub const TYPEMASK: u32 = (1 << TYPEBITS) - 1;
+#[doc(hidden)]
pub const SIZEMASK: u32 = (1 << SIZEBITS) - 1;
+#[doc(hidden)]
pub const DIRMASK: u32 = (1 << DIRBITS) - 1;
/// Encode an ioctl command.
#[macro_export]
+#[doc(hidden)]
macro_rules! ioc {
($dir:expr, $ty:expr, $nr:expr, $sz:expr) => (
(($dir as u32) << $crate::sys::ioctl::DIRSHIFT) |
@@ -59,53 +80,65 @@ macro_rules! ioc {
/// Encode an ioctl command that has no associated data.
#[macro_export]
+#[doc(hidden)]
macro_rules! io {
($ty:expr, $nr:expr) => (ioc!($crate::sys::ioctl::NONE, $ty, $nr, 0))
}
/// Encode an ioctl command that reads.
#[macro_export]
+#[doc(hidden)]
macro_rules! ior {
($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::READ, $ty, $nr, $sz))
}
/// Encode an ioctl command that writes.
#[macro_export]
+#[doc(hidden)]
macro_rules! iow {
($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::WRITE, $ty, $nr, $sz))
}
/// Encode an ioctl command that both reads and writes.
#[macro_export]
+#[doc(hidden)]
macro_rules! iorw {
($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::READ | $crate::sys::ioctl::WRITE, $ty, $nr, $sz))
}
/// Extracts the "direction" (read/write/none) from an encoded ioctl command.
#[inline(always)]
+#[doc(hidden)]
pub fn ioc_dir(nr: u32) -> u8 {
((nr >> DIRSHIFT) & DIRMASK) as u8
}
/// Extracts the type from an encoded ioctl command.
#[inline(always)]
+#[doc(hidden)]
pub fn ioc_type(nr: u32) -> u32 {
(nr >> TYPESHIFT) & TYPEMASK
}
/// Extracts the ioctl number from an encoded ioctl command.
#[inline(always)]
+#[doc(hidden)]
pub fn ioc_nr(nr: u32) -> u32 {
(nr >> NRSHIFT) & NRMASK
}
/// Extracts the size from an encoded ioctl command.
#[inline(always)]
+#[doc(hidden)]
pub fn ioc_size(nr: u32) -> u32 {
((nr >> SIZESHIFT) as u32) & SIZEMASK
}
+#[doc(hidden)]
pub const IN: u32 = (WRITE as u32) << DIRSHIFT;
+#[doc(hidden)]
pub const OUT: u32 = (READ as u32) << DIRSHIFT;
+#[doc(hidden)]
pub const INOUT: u32 = ((READ|WRITE) as u32) << DIRSHIFT;
+#[doc(hidden)]
pub const SIZE_MASK: u32 = SIZEMASK << SIZESHIFT;