From 96a50281ddd9edbf8332ff7e5bd437b340cf9d23 Mon Sep 17 00:00:00 2001 From: sm-Fifteen <516999+sm-Fifteen@users.noreply.github.com> Date: Fri, 14 Feb 2020 21:31:39 -0500 Subject: [PATCH 1/4] Added ioctl generation macros from MUSL as functions --- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 27 +++++++++++++++++ .../linux_like/linux/musl/b32/mips/mod.rs | 27 +++++++++++++++++ src/unix/linux_like/linux/musl/b32/powerpc.rs | 27 +++++++++++++++++ src/unix/linux_like/linux/musl/b32/x86/mod.rs | 27 +++++++++++++++++ .../linux_like/linux/musl/b64/aarch64/mod.rs | 27 +++++++++++++++++ src/unix/linux_like/linux/musl/b64/mips64.rs | 27 +++++++++++++++++ .../linux_like/linux/musl/b64/powerpc64.rs | 27 +++++++++++++++++ .../linux_like/linux/musl/b64/x86_64/mod.rs | 29 +++++++++++++++++++ 8 files changed, 218 insertions(+) diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index ff23688734721..e0f32a46df049 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -152,6 +152,33 @@ s! { } } +pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { + ( (a<<30) | (b<<8) | c | (d<<16) ) +} + +pub const _IOC_NONE: ::c_int = 0; +pub const _IOC_WRITE: ::c_int = 1; +pub const _IOC_READ: ::c_int = 2; + +pub fn _IO(a:u8,b:u8) -> ::c_int { + _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) +} + +pub fn _IOW (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOWR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index be11341683f15..1fc233ff4c395 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -163,6 +163,33 @@ s! { } } +pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { + ( (a<<29) | (b<<8) | c | (d<<16) ) +} + +pub const _IOC_NONE: ::c_int = 1; +pub const _IOC_READ: ::c_int = 2; +pub const _IOC_WRITE: ::c_int = 4; + +pub fn _IO(a:u8,b:u8) -> ::c_int { + _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) +} + +pub fn _IOW (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOWR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 6181b1cdc137e..5a45ce5e8d571 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -155,6 +155,33 @@ s! { } } +pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { + ( (a<<29) | (b<<8) | c | (d<<16) ) +} + +pub const _IOC_NONE: ::c_int = 1; +pub const _IOC_WRITE: ::c_int = 4; +pub const _IOC_READ: ::c_int = 2; + +pub fn _IO(a:u8,b:u8) -> ::c_int { + _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) +} + +pub fn _IOW (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOWR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const SIGSTKSZ: ::size_t = 10240; pub const MINSIGSTKSZ: ::size_t = 4096; diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index fcd8ae4117b0b..53194e205151b 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -212,6 +212,33 @@ cfg_if! { } } +pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { + ( (a<<30) | (b<<8) | c | (d<<16) ) +} + +pub const _IOC_NONE: ::c_int = 0; +pub const _IOC_WRITE: ::c_int = 1; +pub const _IOC_READ: ::c_int = 2; + +pub fn _IO(a:u8,b:u8) -> ::c_int { + _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) +} + +pub fn _IOW (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOWR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index 876ff3c8d746f..1245f0253bfaa 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -62,6 +62,33 @@ s! { } } +pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { + ( (a<<30) | (b<<8) | c | (d<<16) ) +} + +pub const _IOC_NONE: ::c_int = 0; +pub const _IOC_WRITE: ::c_int = 1; +pub const _IOC_READ: ::c_int = 2; + +pub fn _IO(a:u8,b:u8) -> ::c_int { + _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) +} + +pub fn _IOW (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOWR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + pub const O_APPEND: ::c_int = 1024; pub const O_DIRECT: ::c_int = 0x10000; pub const O_DIRECTORY: ::c_int = 0x4000; diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 2c410509fa76e..8b8ebe432c0a9 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -97,6 +97,33 @@ s! { } } +pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { + ( (a<<29) | (b<<8) | c | (d<<16) ) +} + +pub const _IOC_NONE: ::c_int = 1; +pub const _IOC_READ: ::c_int = 2; +pub const _IOC_WRITE: ::c_int = 4; + +pub fn _IO(a:u8,b:u8) -> ::c_int { + _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) +} + +pub fn _IOW (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOWR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + pub const SIGSTKSZ: ::size_t = 8192; pub const MINSIGSTKSZ: ::size_t = 2048; diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index d27d703ad9c4c..3e87071594719 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -60,6 +60,33 @@ s! { } } +pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { + ( (a<<29) | (b<<8) | c | (d<<16) ) +} + +pub const _IOC_NONE: ::c_int = 1; +pub const _IOC_WRITE: ::c_int = 4; +pub const _IOC_READ: ::c_int = 2; + +pub fn _IO(a:u8,b:u8) -> ::c_int { + _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) +} + +pub fn _IOW (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOWR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + pub const MADV_SOFT_OFFLINE: ::c_int = 101; pub const MAP_32BIT: ::c_int = 0x0040; pub const O_APPEND: ::c_int = 1024; diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index ff9300c85f393..09099d03d00fc 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -245,6 +245,35 @@ cfg_if! { } } +// ioctl macros from bits/ioctl.h (generic) + +pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { + ( (a<<30) | (b<<8) | c | (d<<16) ) +} + +pub const _IOC_NONE: ::c_int = 0; +pub const _IOC_WRITE: ::c_int = 1; +pub const _IOC_READ: ::c_int = 2; + +pub fn _IO(a:u8,b:u8) -> ::c_int { + _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) +} + +pub fn _IOW (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) +} + +pub fn _IOWR (a:u8,b:u8) -> ::c_int { + let size = ::core::mem::size_of::() as ::c_int; + _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) +} + // Syscall table pub const SYS_read: ::c_long = 0; From a78ab9ee120e5941629c193bd44c9d43ac685fb2 Mon Sep 17 00:00:00 2001 From: sm-Fifteen <516999+sm-Fifteen@users.noreply.github.com> Date: Fri, 14 Feb 2020 23:58:33 -0500 Subject: [PATCH 2/4] Added ioctl generation macros from glibc as functions --- src/unix/linux_like/linux/gnu/b32/arm/mod.rs | 10 ++++++ src/unix/linux_like/linux/gnu/b32/mips/mod.rs | 11 +++++++ src/unix/linux_like/linux/gnu/b32/powerpc.rs | 11 +++++++ .../linux_like/linux/gnu/b32/sparc/mod.rs | 11 +++++++ src/unix/linux_like/linux/gnu/b32/x86/mod.rs | 10 ++++++ .../linux_like/linux/gnu/b64/aarch64/mod.rs | 10 ++++++ .../linux_like/linux/gnu/b64/mips64/mod.rs | 11 +++++++ .../linux_like/linux/gnu/b64/powerpc64/mod.rs | 11 +++++++ .../linux_like/linux/gnu/b64/riscv64/mod.rs | 10 ++++++ src/unix/linux_like/linux/gnu/b64/s390x.rs | 10 ++++++ .../linux_like/linux/gnu/b64/sparc64/mod.rs | 11 +++++++ .../linux_like/linux/gnu/b64/x86_64/mod.rs | 10 ++++++ src/unix/linux_like/linux/gnu/mod.rs | 32 +++++++++++++++++++ 13 files changed, 158 insertions(+) diff --git a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs index 0a5fc8567b570..0f9dd142b779c 100644 --- a/src/unix/linux_like/linux/gnu/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/arm/mod.rs @@ -868,6 +868,16 @@ pub const SYS_pkey_alloc: ::c_long = 395; pub const SYS_pkey_free: ::c_long = 396; pub const SYS_statx: ::c_long = 397; +// from uapi/asm-generic +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +pub const _IOC_SIZEBITS: u32 = 14; +pub const _IOC_DIRBITS: u32 = 2; + +pub const _IOC_NONE: ::c_ulong = 0; +pub const _IOC_READ: ::c_ulong = 1; +pub const _IOC_WRITE: ::c_ulong = 2; + cfg_if! { if #[cfg(libc_align)] { mod align; diff --git a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs index 4a3b600aaf6b4..e75821072fb96 100644 --- a/src/unix/linux_like/linux/gnu/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/mips/mod.rs @@ -893,6 +893,17 @@ pub const TIOCM_DSR: ::c_int = 0x400; pub const EHWPOISON: ::c_int = 168; +// from uapi/asm-generic +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +// from arch/mips/include/uapi/asm +pub const _IOC_SIZEBITS: u32 = 13; +pub const _IOC_DIRBITS: u32 = 3; + +pub const _IOC_NONE: ::c_ulong = 1; +pub const _IOC_READ: ::c_ulong = 2; +pub const _IOC_WRITE: ::c_ulong = 4; + cfg_if! { if #[cfg(libc_align)] { mod align; diff --git a/src/unix/linux_like/linux/gnu/b32/powerpc.rs b/src/unix/linux_like/linux/gnu/b32/powerpc.rs index 7644428014f1a..b413cf0a99681 100644 --- a/src/unix/linux_like/linux/gnu/b32/powerpc.rs +++ b/src/unix/linux_like/linux/gnu/b32/powerpc.rs @@ -871,3 +871,14 @@ pub const SYS_preadv2: ::c_long = 380; pub const SYS_pwritev2: ::c_long = 381; pub const SYS_kexec_file_load: ::c_long = 382; pub const SYS_statx: ::c_long = 383; + +// from uapi/asm-generic +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +// from arch/powerpc/include/uapi/asm +pub const _IOC_SIZEBITS: u32 = 13; +pub const _IOC_DIRBITS: u32 = 3; + +pub const _IOC_NONE: ::c_ulong = 1; +pub const _IOC_READ: ::c_ulong = 2; +pub const _IOC_WRITE: ::c_ulong = 4; diff --git a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs index f670b3422bff7..0b6729c1ae148 100644 --- a/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs @@ -958,6 +958,17 @@ pub const SYS_preadv2: ::c_long = 358; pub const SYS_pwritev2: ::c_long = 359; pub const SYS_statx: ::c_long = 360; +// from uapi/asm-generic +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +// from arch/sparc/include/uapi/asm +pub const _IOC_SIZEBITS: u32 = 13; +pub const _IOC_DIRBITS: u32 = 3; + +pub const _IOC_NONE: ::c_ulong = 1; +pub const _IOC_READ: ::c_ulong = 2; +pub const _IOC_WRITE: ::c_ulong = 4; + #[link(name = "util")] extern "C" { pub fn sysctl( diff --git a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs index f5f7cac4c5ac4..f749914399a82 100644 --- a/src/unix/linux_like/linux/gnu/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/gnu/b32/x86/mod.rs @@ -1101,6 +1101,16 @@ pub const SYS_pkey_alloc: ::c_long = 381; pub const SYS_pkey_free: ::c_long = 382; pub const SYS_statx: ::c_long = 383; +// from uapi/asm-generic +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +pub const _IOC_SIZEBITS: u32 = 14; +pub const _IOC_DIRBITS: u32 = 2; + +pub const _IOC_NONE: ::c_ulong = 0; +pub const _IOC_READ: ::c_ulong = 1; +pub const _IOC_WRITE: ::c_ulong = 2; + // offsets in user_regs_structs, from sys/reg.h pub const EBX: ::c_int = 0; pub const ECX: ::c_int = 1; diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index 93f0f2bc1b0ae..4814ed8c8a167 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -946,6 +946,16 @@ extern "C" { ) -> ::c_int; } +// from uapi/asm-generic +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +pub const _IOC_SIZEBITS: u32 = 14; +pub const _IOC_DIRBITS: u32 = 2; + +pub const _IOC_NONE: ::c_ulong = 0; +pub const _IOC_READ: ::c_ulong = 1; +pub const _IOC_WRITE: ::c_ulong = 2; + cfg_if! { if #[cfg(libc_align)] { mod align; diff --git a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs index a59554b844ff0..3b8a11b78b9e1 100644 --- a/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs @@ -997,6 +997,17 @@ pub const TIOCM_DSR: ::c_int = 0x400; pub const EHWPOISON: ::c_int = 168; +// from uapi/asm-generic +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +// from arch/mips/include/uapi/asm +pub const _IOC_SIZEBITS: u32 = 13; +pub const _IOC_DIRBITS: u32 = 3; + +pub const _IOC_NONE: ::c_ulong = 1; +pub const _IOC_READ: ::c_ulong = 2; +pub const _IOC_WRITE: ::c_ulong = 4; + #[link(name = "util")] extern "C" { pub fn sysctl( diff --git a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs index 22507d72f3267..a727207b3f55c 100644 --- a/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs @@ -1032,6 +1032,17 @@ pub const SYS_pwritev2: ::c_long = 381; pub const SYS_kexec_file_load: ::c_long = 382; pub const SYS_statx: ::c_long = 383; +// from uapi/asm-generic +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +// from arch/powerpc/include/uapi/asm +pub const _IOC_SIZEBITS: u32 = 13; +pub const _IOC_DIRBITS: u32 = 3; + +pub const _IOC_NONE: ::c_ulong = 1; +pub const _IOC_READ: ::c_ulong = 2; +pub const _IOC_WRITE: ::c_ulong = 4; + #[link(name = "util")] extern "C" { pub fn sysctl( diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index c45c5b230bed7..a95877a3a4f12 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -859,3 +859,13 @@ pub const SYS_pkey_mprotect: ::c_long = 288; pub const SYS_pkey_alloc: ::c_long = 289; pub const SYS_pkey_free: ::c_long = 290; pub const SYS_statx: ::c_long = 291; + +// from uapi/asm-generic +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +pub const _IOC_SIZEBITS: u32 = 14; +pub const _IOC_DIRBITS: u32 = 2; + +pub const _IOC_NONE: ::c_ulong = 0; +pub const _IOC_READ: ::c_ulong = 1; +pub const _IOC_WRITE: ::c_ulong = 2; diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index cf0612a8ff784..ed0c148c3d69b 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -1003,6 +1003,16 @@ pub const SYS_setfsgid: ::c_long = 216; pub const SYS_newfstatat: ::c_long = 293; pub const SYS_statx: ::c_long = 379; +// from uapi/asm-generic +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +pub const _IOC_SIZEBITS: u32 = 14; +pub const _IOC_DIRBITS: u32 = 2; + +pub const _IOC_NONE: ::c_ulong = 0; +pub const _IOC_READ: ::c_ulong = 1; +pub const _IOC_WRITE: ::c_ulong = 2; + #[link(name = "util")] extern "C" { diff --git a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs index 651ada376eecc..c303d44f3da2c 100644 --- a/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs @@ -968,6 +968,17 @@ pub const SYS_preadv2: ::c_long = 358; pub const SYS_pwritev2: ::c_long = 359; pub const SYS_statx: ::c_long = 360; +// from uapi/asm-generic +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +// from arch/sparc/include/uapi/asm +pub const _IOC_SIZEBITS: u32 = 13; +pub const _IOC_DIRBITS: u32 = 3; + +pub const _IOC_NONE: ::c_ulong = 1; +pub const _IOC_READ: ::c_ulong = 2; +pub const _IOC_WRITE: ::c_ulong = 4; + #[link(name = "util")] extern "C" { pub fn sysctl( diff --git a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs index 34e4da8bcb3bd..4bafdbba6b0ab 100644 --- a/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs @@ -890,6 +890,16 @@ pub const REG_TRAPNO: ::c_int = 20; pub const REG_OLDMASK: ::c_int = 21; pub const REG_CR2: ::c_int = 22; +// from uapi/asm-generic +pub const _IOC_NRBITS: u32 = 8; +pub const _IOC_TYPEBITS: u32 = 8; +pub const _IOC_SIZEBITS: u32 = 14; +pub const _IOC_DIRBITS: u32 = 2; + +pub const _IOC_NONE: ::c_ulong = 0; +pub const _IOC_READ: ::c_ulong = 1; +pub const _IOC_WRITE: ::c_ulong = 2; + extern "C" { pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int; pub fn setcontext(ucp: *const ucontext_t) -> ::c_int; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index ea041aa6dae18..1fbf4fca96950 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -961,6 +961,38 @@ extern "C" { ) -> ::ssize_t; } +// glibc uses the definitions from the kernel header files. +pub fn _IOC(dir: ::c_ulong, typ: ::c_ulong, nr: ::c_ulong, size: ::c_ulong) -> ::c_ulong { + const _IOC_NRSHIFT: u32 = 0; + const _IOC_TYPESHIFT: u32 = _IOC_NRSHIFT+_IOC_NRBITS; + const _IOC_SIZESHIFT: u32 = _IOC_TYPESHIFT+_IOC_TYPEBITS; + const _IOC_DIRSHIFT: u32 = _IOC_SIZESHIFT+_IOC_SIZEBITS; + + (((dir) << _IOC_DIRSHIFT) | + ((typ) << _IOC_TYPESHIFT) | + ((nr) << _IOC_NRSHIFT) | + ((size) << _IOC_SIZESHIFT)) +} + +pub fn _IO(a:u8,b:u8) -> ::c_ulong { + _IOC(_IOC_NONE,(a as ::c_ulong),(b as ::c_ulong),0) +} + +pub fn _IOW (a:u8,b:u8) -> ::c_ulong { + let size = ::core::mem::size_of::() as ::c_ulong; + _IOC(_IOC_WRITE,(a as ::c_ulong),(b as ::c_ulong),size) +} + +pub fn _IOR (a:u8,b:u8) -> ::c_ulong { + let size = ::core::mem::size_of::() as ::c_ulong; + _IOC(_IOC_READ,(a as ::c_ulong),(b as ::c_ulong),size) +} + +pub fn _IOWR (a:u8,b:u8) -> ::c_ulong { + let size = ::core::mem::size_of::() as ::c_ulong; + _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_ulong),(b as ::c_ulong),size) +} + #[link(name = "util")] extern "C" { pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; From c84cd8d2adf4dc17c4f32caa8bc68dc27a33bdc2 Mon Sep 17 00:00:00 2001 From: sm-Fifteen <516999+sm-Fifteen@users.noreply.github.com> Date: Sun, 16 Feb 2020 13:58:19 -0500 Subject: [PATCH 3/4] Fixed signature of _IOC to match the type-checked ioctl macros --- src/unix/linux_like/linux/gnu/mod.rs | 18 +++++++++--------- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 18 +++++++++--------- src/unix/linux_like/linux/musl/b32/mips/mod.rs | 18 +++++++++--------- src/unix/linux_like/linux/musl/b32/powerpc.rs | 18 +++++++++--------- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 18 +++++++++--------- .../linux_like/linux/musl/b64/aarch64/mod.rs | 18 +++++++++--------- src/unix/linux_like/linux/musl/b64/mips64.rs | 18 +++++++++--------- .../linux_like/linux/musl/b64/powerpc64.rs | 18 +++++++++--------- .../linux_like/linux/musl/b64/x86_64/mod.rs | 18 +++++++++--------- 9 files changed, 81 insertions(+), 81 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 1fbf4fca96950..66db1201a5ad7 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -962,35 +962,35 @@ extern "C" { } // glibc uses the definitions from the kernel header files. -pub fn _IOC(dir: ::c_ulong, typ: ::c_ulong, nr: ::c_ulong, size: ::c_ulong) -> ::c_ulong { +pub fn _IOC(dir: ::c_ulong, typ: u8, nr: u8, size: ::c_ulong) -> ::c_ulong { const _IOC_NRSHIFT: u32 = 0; const _IOC_TYPESHIFT: u32 = _IOC_NRSHIFT+_IOC_NRBITS; const _IOC_SIZESHIFT: u32 = _IOC_TYPESHIFT+_IOC_TYPEBITS; const _IOC_DIRSHIFT: u32 = _IOC_SIZESHIFT+_IOC_SIZEBITS; - (((dir) << _IOC_DIRSHIFT) | - ((typ) << _IOC_TYPESHIFT) | - ((nr) << _IOC_NRSHIFT) | - ((size) << _IOC_SIZESHIFT)) + (((dir) << _IOC_DIRSHIFT) | + ((typ as ::c_ulong) << _IOC_TYPESHIFT) | + ((nr as ::c_ulong) << _IOC_NRSHIFT) | + ((size) << _IOC_SIZESHIFT)) } pub fn _IO(a:u8,b:u8) -> ::c_ulong { - _IOC(_IOC_NONE,(a as ::c_ulong),(b as ::c_ulong),0) + _IOC(_IOC_NONE,a,b,0) } pub fn _IOW (a:u8,b:u8) -> ::c_ulong { let size = ::core::mem::size_of::() as ::c_ulong; - _IOC(_IOC_WRITE,(a as ::c_ulong),(b as ::c_ulong),size) + _IOC(_IOC_WRITE,a,b,size) } pub fn _IOR (a:u8,b:u8) -> ::c_ulong { let size = ::core::mem::size_of::() as ::c_ulong; - _IOC(_IOC_READ,(a as ::c_ulong),(b as ::c_ulong),size) + _IOC(_IOC_READ,a,b,size) } pub fn _IOWR (a:u8,b:u8) -> ::c_ulong { let size = ::core::mem::size_of::() as ::c_ulong; - _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_ulong),(b as ::c_ulong),size) + _IOC(_IOC_READ|_IOC_WRITE,a,b,size) } #[link(name = "util")] diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index e0f32a46df049..70a74eaef9aa3 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -152,31 +152,31 @@ s! { } } -pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { - ( (a<<30) | (b<<8) | c | (d<<16) ) +pub fn _IOC(a: ::c_uint, b: u8, c: u8, d: ::c_int) -> ::c_int { + (a<<30) as ::c_int | (b as ::c_int)<<8 | c as ::c_int | d<<16 } -pub const _IOC_NONE: ::c_int = 0; -pub const _IOC_WRITE: ::c_int = 1; -pub const _IOC_READ: ::c_int = 2; +pub const _IOC_NONE: ::c_uint = 0; +pub const _IOC_WRITE: ::c_uint = 1; +pub const _IOC_READ: ::c_uint = 2; pub fn _IO(a:u8,b:u8) -> ::c_int { - _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) + _IOC(_IOC_NONE,a,b,0) } pub fn _IOW (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_WRITE,a,b,size) } pub fn _IOR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ,a,b,size) } pub fn _IOWR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ|_IOC_WRITE,a,b,size) } pub const SIGSTKSZ: ::size_t = 8192; diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index 1fc233ff4c395..10a6e892e7dab 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -163,31 +163,31 @@ s! { } } -pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { - ( (a<<29) | (b<<8) | c | (d<<16) ) +pub fn _IOC(a: ::c_uint, b: u8, c: u8, d: ::c_int) -> ::c_int { + (a<<29) as ::c_int | (b as ::c_int)<<8 | c as ::c_int | d<<16 } -pub const _IOC_NONE: ::c_int = 1; -pub const _IOC_READ: ::c_int = 2; -pub const _IOC_WRITE: ::c_int = 4; +pub const _IOC_NONE: ::c_uint = 1; +pub const _IOC_READ: ::c_uint = 2; +pub const _IOC_WRITE: ::c_uint = 4; pub fn _IO(a:u8,b:u8) -> ::c_int { - _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) + _IOC(_IOC_NONE,a,b,0) } pub fn _IOW (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_WRITE,a,b,size) } pub fn _IOR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ,a,b,size) } pub fn _IOWR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ|_IOC_WRITE,a,b,size) } pub const SIGSTKSZ: ::size_t = 8192; diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 5a45ce5e8d571..c668f3710c32b 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -155,31 +155,31 @@ s! { } } -pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { - ( (a<<29) | (b<<8) | c | (d<<16) ) +pub fn _IOC(a: ::c_uint, b: u8, c: u8, d: ::c_int) -> ::c_int { + (a<<29) as ::c_int | (b as as ::c_int)<<8 | c as as ::c_int | d<<16 } -pub const _IOC_NONE: ::c_int = 1; -pub const _IOC_WRITE: ::c_int = 4; -pub const _IOC_READ: ::c_int = 2; +pub const _IOC_NONE: ::c_uint = 1; +pub const _IOC_WRITE: ::c_uint = 4; +pub const _IOC_READ: ::c_uint = 2; pub fn _IO(a:u8,b:u8) -> ::c_int { - _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) + _IOC(_IOC_NONE,a,b,0) } pub fn _IOW (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_WRITE,a,b,size) } pub fn _IOR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ,a,b,size) } pub fn _IOWR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ|_IOC_WRITE,a,b,size) } pub const MADV_SOFT_OFFLINE: ::c_int = 101; diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 53194e205151b..187fe4dded7d5 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -212,31 +212,31 @@ cfg_if! { } } -pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { - ( (a<<30) | (b<<8) | c | (d<<16) ) +pub fn _IOC(a: ::c_uint, b: u8, c: u8, d: ::c_int) -> ::c_int { + ( (a<<30) as ::c_int | (b as ::c_int)<<8 | c as ::c_int | (d<<16) ) } -pub const _IOC_NONE: ::c_int = 0; -pub const _IOC_WRITE: ::c_int = 1; -pub const _IOC_READ: ::c_int = 2; +pub const _IOC_NONE: ::c_uint = 0; +pub const _IOC_WRITE: ::c_uint = 1; +pub const _IOC_READ: ::c_uint = 2; pub fn _IO(a:u8,b:u8) -> ::c_int { - _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) + _IOC(_IOC_NONE,a,b,0) } pub fn _IOW (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_WRITE,a,b,size) } pub fn _IOR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ,a,b,size) } pub fn _IOWR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ|_IOC_WRITE,a,b,size) } pub const SIGSTKSZ: ::size_t = 8192; diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index 1245f0253bfaa..c90a887fc222e 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -62,31 +62,31 @@ s! { } } -pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { - ( (a<<30) | (b<<8) | c | (d<<16) ) +pub fn _IOC(a: ::c_uint, b: u8, c: u8, d: ::c_int) -> ::c_int { + (a<<30) as ::c_int | (b as ::c_int)<<8 | c | (d<<16) } -pub const _IOC_NONE: ::c_int = 0; -pub const _IOC_WRITE: ::c_int = 1; -pub const _IOC_READ: ::c_int = 2; +pub const _IOC_NONE: ::c_uint = 0; +pub const _IOC_WRITE: ::c_uint = 1; +pub const _IOC_READ: ::c_uint = 2; pub fn _IO(a:u8,b:u8) -> ::c_int { - _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) + _IOC(_IOC_NONE,a,b,0) } pub fn _IOW (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_WRITE,a,b,size) } pub fn _IOR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ,a,b,size) } pub fn _IOWR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ|_IOC_WRITE,a,b,size) } pub const O_APPEND: ::c_int = 1024; diff --git a/src/unix/linux_like/linux/musl/b64/mips64.rs b/src/unix/linux_like/linux/musl/b64/mips64.rs index 8b8ebe432c0a9..d698aed6eb498 100644 --- a/src/unix/linux_like/linux/musl/b64/mips64.rs +++ b/src/unix/linux_like/linux/musl/b64/mips64.rs @@ -97,31 +97,31 @@ s! { } } -pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { - ( (a<<29) | (b<<8) | c | (d<<16) ) +pub fn _IOC(a: ::c_uint, b: u8, c: u8, d: ::c_int) -> ::c_int { + (a<<29) as ::c_int | (b as ::c_int)<<8 | c as ::c_int | (d<<16) } -pub const _IOC_NONE: ::c_int = 1; -pub const _IOC_READ: ::c_int = 2; -pub const _IOC_WRITE: ::c_int = 4; +pub const _IOC_NONE: ::c_uint = 1; +pub const _IOC_READ: ::c_uint = 2; +pub const _IOC_WRITE: ::c_uint = 4; pub fn _IO(a:u8,b:u8) -> ::c_int { - _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) + _IOC(_IOC_NONE,a,b,0) } pub fn _IOW (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_WRITE,a,b,size) } pub fn _IOR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ,a,b,size) } pub fn _IOWR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ|_IOC_WRITE,a,b,size) } pub const SIGSTKSZ: ::size_t = 8192; diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index 3e87071594719..b6cf24488eb7e 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -60,31 +60,31 @@ s! { } } -pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { - ( (a<<29) | (b<<8) | c | (d<<16) ) +pub fn _IOC(a: ::c_uint, b: u8, c: u8, d: ::c_int) -> ::c_int { + (a<<29) as ::c_int | (b as ::c_int)<<8 | c as ::c_int | (d<<16) ) } -pub const _IOC_NONE: ::c_int = 1; -pub const _IOC_WRITE: ::c_int = 4; -pub const _IOC_READ: ::c_int = 2; +pub const _IOC_NONE: ::c_uint = 1; +pub const _IOC_WRITE: ::c_uint = 4; +pub const _IOC_READ: ::c_uint = 2; pub fn _IO(a:u8,b:u8) -> ::c_int { - _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) + _IOC(_IOC_NONE,a,b,0) } pub fn _IOW (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_WRITE,a,b,size) } pub fn _IOR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ,a,b,size) } pub fn _IOWR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ|_IOC_WRITE,a,b,size) } pub const MADV_SOFT_OFFLINE: ::c_int = 101; diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index 09099d03d00fc..bedd0ae0b6529 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -247,31 +247,31 @@ cfg_if! { // ioctl macros from bits/ioctl.h (generic) -pub fn _IOC(a: ::c_int, b: ::c_int,c: ::c_int, d: ::c_int) -> ::c_int { - ( (a<<30) | (b<<8) | c | (d<<16) ) +pub fn _IOC(a: ::c_uint, b: u8, c: u8, d: ::c_int) -> ::c_int { + (a<<30) as ::c_int | (b as ::c_int)<<8 | c as ::c_int | d<<16 } -pub const _IOC_NONE: ::c_int = 0; -pub const _IOC_WRITE: ::c_int = 1; -pub const _IOC_READ: ::c_int = 2; +pub const _IOC_NONE: ::c_uint = 0; +pub const _IOC_WRITE: ::c_uint = 1; +pub const _IOC_READ: ::c_uint = 2; pub fn _IO(a:u8,b:u8) -> ::c_int { - _IOC(_IOC_NONE,(a as ::c_int),(b as ::c_int),0) + _IOC(_IOC_NONE,a,b,0) } pub fn _IOW (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_WRITE,a,b,size) } pub fn _IOR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ,a,b,size) } pub fn _IOWR (a:u8,b:u8) -> ::c_int { let size = ::core::mem::size_of::() as ::c_int; - _IOC(_IOC_READ|_IOC_WRITE,(a as ::c_int),(b as ::c_int),size) + _IOC(_IOC_READ|_IOC_WRITE,a,b,size) } // Syscall table From a32979d7f967f4b1ae7becf84af425b6a4c72fe4 Mon Sep 17 00:00:00 2001 From: sm-Fifteen <516999+sm-Fifteen@users.noreply.github.com> Date: Sun, 16 Feb 2020 16:37:12 -0500 Subject: [PATCH 4/4] Fix linter and syntax errors for ioctl macros --- src/unix/linux_like/linux/gnu/mod.rs | 8 ++++---- src/unix/linux_like/linux/musl/b32/powerpc.rs | 2 +- src/unix/linux_like/linux/musl/b32/x86/mod.rs | 2 +- src/unix/linux_like/linux/musl/b64/powerpc64.rs | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 66db1201a5ad7..0fd9ed61ac530 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -968,10 +968,10 @@ pub fn _IOC(dir: ::c_ulong, typ: u8, nr: u8, size: ::c_ulong) -> ::c_ulong { const _IOC_SIZESHIFT: u32 = _IOC_TYPESHIFT+_IOC_TYPEBITS; const _IOC_DIRSHIFT: u32 = _IOC_SIZESHIFT+_IOC_SIZEBITS; - (((dir) << _IOC_DIRSHIFT) | - ((typ as ::c_ulong) << _IOC_TYPESHIFT) | - ((nr as ::c_ulong) << _IOC_NRSHIFT) | - ((size) << _IOC_SIZESHIFT)) + ((dir) << _IOC_DIRSHIFT) | + ((typ as ::c_ulong) << _IOC_TYPESHIFT) | + ((nr as ::c_ulong) << _IOC_NRSHIFT) | + ((size) << _IOC_SIZESHIFT) } pub fn _IO(a:u8,b:u8) -> ::c_ulong { diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index c668f3710c32b..df1a0a0690d2b 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -156,7 +156,7 @@ s! { } pub fn _IOC(a: ::c_uint, b: u8, c: u8, d: ::c_int) -> ::c_int { - (a<<29) as ::c_int | (b as as ::c_int)<<8 | c as as ::c_int | d<<16 + (a<<29) as ::c_int | (b as ::c_int)<<8 | c as ::c_int | d<<16 } pub const _IOC_NONE: ::c_uint = 1; diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 187fe4dded7d5..2c2b38c51fa74 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -213,7 +213,7 @@ cfg_if! { } pub fn _IOC(a: ::c_uint, b: u8, c: u8, d: ::c_int) -> ::c_int { - ( (a<<30) as ::c_int | (b as ::c_int)<<8 | c as ::c_int | (d<<16) ) + (a<<30) as ::c_int | (b as ::c_int)<<8 | c as ::c_int | (d<<16) } pub const _IOC_NONE: ::c_uint = 0; diff --git a/src/unix/linux_like/linux/musl/b64/powerpc64.rs b/src/unix/linux_like/linux/musl/b64/powerpc64.rs index b6cf24488eb7e..eb02911e624ad 100644 --- a/src/unix/linux_like/linux/musl/b64/powerpc64.rs +++ b/src/unix/linux_like/linux/musl/b64/powerpc64.rs @@ -61,7 +61,7 @@ s! { } pub fn _IOC(a: ::c_uint, b: u8, c: u8, d: ::c_int) -> ::c_int { - (a<<29) as ::c_int | (b as ::c_int)<<8 | c as ::c_int | (d<<16) ) + (a<<29) as ::c_int | (b as ::c_int)<<8 | c as ::c_int | (d<<16) } pub const _IOC_NONE: ::c_uint = 1;