summaryrefslogtreecommitdiff
path: root/src/sys/ioctl/linux.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys/ioctl/linux.rs')
-rw-r--r--src/sys/ioctl/linux.rs64
1 files changed, 47 insertions, 17 deletions
diff --git a/src/sys/ioctl/linux.rs b/src/sys/ioctl/linux.rs
index 08cd0c33..0c0a2090 100644
--- a/src/sys/ioctl/linux.rs
+++ b/src/sys/ioctl/linux.rs
@@ -14,7 +14,13 @@ pub const NRBITS: ioctl_num_type = 8;
#[doc(hidden)]
pub const TYPEBITS: ioctl_num_type = 8;
-#[cfg(any(target_arch = "mips", target_arch = "mips64", target_arch = "powerpc", target_arch = "powerpc64", target_arch = "sparc64"))]
+#[cfg(any(
+ target_arch = "mips",
+ target_arch = "mips64",
+ target_arch = "powerpc",
+ target_arch = "powerpc64",
+ target_arch = "sparc64"
+))]
mod consts {
#[doc(hidden)]
pub const NONE: u8 = 1;
@@ -29,13 +35,15 @@ mod consts {
}
// "Generic" ioctl protocol
-#[cfg(any(target_arch = "x86",
- target_arch = "arm",
- target_arch = "s390x",
- target_arch = "x86_64",
- target_arch = "aarch64",
- target_arch = "riscv32",
- target_arch = "riscv64"))]
+#[cfg(any(
+ target_arch = "x86",
+ target_arch = "arm",
+ target_arch = "s390x",
+ target_arch = "x86_64",
+ target_arch = "aarch64",
+ target_arch = "riscv32",
+ target_arch = "riscv64"
+))]
mod consts {
#[doc(hidden)]
pub const NONE: u8 = 0;
@@ -73,11 +81,20 @@ pub const DIRMASK: ioctl_num_type = (1 << DIRBITS) - 1;
#[macro_export]
#[doc(hidden)]
macro_rules! ioc {
- ($dir:expr, $ty:expr, $nr:expr, $sz:expr) => (
- (($dir as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::DIRMASK) << $crate::sys::ioctl::DIRSHIFT) |
- (($ty as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::TYPEMASK) << $crate::sys::ioctl::TYPESHIFT) |
- (($nr as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::NRMASK) << $crate::sys::ioctl::NRSHIFT) |
- (($sz as $crate::sys::ioctl::ioctl_num_type & $crate::sys::ioctl::SIZEMASK) << $crate::sys::ioctl::SIZESHIFT))
+ ($dir:expr, $ty:expr, $nr:expr, $sz:expr) => {
+ (($dir as $crate::sys::ioctl::ioctl_num_type
+ & $crate::sys::ioctl::DIRMASK)
+ << $crate::sys::ioctl::DIRSHIFT)
+ | (($ty as $crate::sys::ioctl::ioctl_num_type
+ & $crate::sys::ioctl::TYPEMASK)
+ << $crate::sys::ioctl::TYPESHIFT)
+ | (($nr as $crate::sys::ioctl::ioctl_num_type
+ & $crate::sys::ioctl::NRMASK)
+ << $crate::sys::ioctl::NRSHIFT)
+ | (($sz as $crate::sys::ioctl::ioctl_num_type
+ & $crate::sys::ioctl::SIZEMASK)
+ << $crate::sys::ioctl::SIZESHIFT)
+ };
}
/// Generate an ioctl request code for a command that passes no data.
@@ -97,7 +114,9 @@ macro_rules! ioc {
/// ```
#[macro_export(local_inner_macros)]
macro_rules! request_code_none {
- ($ty:expr, $nr:expr) => (ioc!($crate::sys::ioctl::NONE, $ty, $nr, 0))
+ ($ty:expr, $nr:expr) => {
+ ioc!($crate::sys::ioctl::NONE, $ty, $nr, 0)
+ };
}
/// Generate an ioctl request code for a command that reads.
@@ -112,7 +131,9 @@ macro_rules! request_code_none {
/// writing.
#[macro_export(local_inner_macros)]
macro_rules! request_code_read {
- ($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::READ, $ty, $nr, $sz))
+ ($ty:expr, $nr:expr, $sz:expr) => {
+ ioc!($crate::sys::ioctl::READ, $ty, $nr, $sz)
+ };
}
/// Generate an ioctl request code for a command that writes.
@@ -127,7 +148,9 @@ macro_rules! request_code_read {
/// reading.
#[macro_export(local_inner_macros)]
macro_rules! request_code_write {
- ($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::WRITE, $ty, $nr, $sz))
+ ($ty:expr, $nr:expr, $sz:expr) => {
+ ioc!($crate::sys::ioctl::WRITE, $ty, $nr, $sz)
+ };
}
/// Generate an ioctl request code for a command that reads and writes.
@@ -138,5 +161,12 @@ macro_rules! request_code_write {
/// with is "bad" and you cannot use `ioctl_readwrite!()` directly.
#[macro_export(local_inner_macros)]
macro_rules! request_code_readwrite {
- ($ty:expr, $nr:expr, $sz:expr) => (ioc!($crate::sys::ioctl::READ | $crate::sys::ioctl::WRITE, $ty, $nr, $sz))
+ ($ty:expr, $nr:expr, $sz:expr) => {
+ ioc!(
+ $crate::sys::ioctl::READ | $crate::sys::ioctl::WRITE,
+ $ty,
+ $nr,
+ $sz
+ )
+ };
}