Codebase list rust-bzip2 / 3eb7964
fix compilation errors serial-unix/ioctl-rs Henry-Nicolas Tourneur 2 years ago
7 changed file(s) with 163 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
11
22 * Package ioctl-rs 0.2.0 from crates.io using debcargo 2.4.4
33
4 -- Henry-Nicolas Tourneur <debian@nilux.be> Fri, 23 Apr 2021 19:32:54 +0000
4 -- Henry-Nicolas Tourneur <debian@nilux.be> Fri, 07 May 2021 12:30:54 +0000
0 Author: Dorota Czaplejewicz
1 Forwarded: https://github.com/dcuddeback/ioctl-rs/pull/6
2 Description: Use a dedicated type for TIOCM requests
3 ---
4 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
5 --- a/src/lib.rs
6 +++ b/src/lib.rs
7 @@ -41,8 +41,8 @@ pub fn tiocnxcl(fd: RawFd) -> io::Result
8 }
9
10 /// Get the status of modem bits.
11 -pub fn tiocmget(fd: RawFd) -> io::Result<c_int> {
12 - let mut bits: c_int = unsafe { mem::uninitialized() };
13 +pub fn tiocmget(fd: RawFd) -> io::Result<BitsInt> {
14 + let mut bits: BitsInt = unsafe { mem::uninitialized() };
15
16 match unsafe { ioctl(fd, TIOCMGET, &mut bits) } {
17 0 => Ok(bits),
18 @@ -51,7 +51,7 @@ pub fn tiocmget(fd: RawFd) -> io::Result
19 }
20
21 /// Set the status of modem bits.
22 -pub fn tiocmset(fd: RawFd, bits: c_int) -> io::Result<()> {
23 +pub fn tiocmset(fd: RawFd, bits: BitsInt) -> io::Result<()> {
24 match unsafe { ioctl(fd, TIOCMSET, &bits) } {
25 0 => Ok(()),
26 _ => Err(io::Error::last_os_error())
27 @@ -59,7 +59,7 @@ pub fn tiocmset(fd: RawFd, bits: c_int)
28 }
29
30 /// Set the indicated modem bits.
31 -pub fn tiocmbis(fd: RawFd, bits: c_int) -> io::Result<()> {
32 +pub fn tiocmbis(fd: RawFd, bits: BitsInt) -> io::Result<()> {
33 match unsafe { ioctl(fd, TIOCMBIS, &bits) } {
34 0 => Ok(()),
35 _ => Err(io::Error::last_os_error())
36 @@ -67,9 +67,26 @@ pub fn tiocmbis(fd: RawFd, bits: c_int)
37 }
38
39 /// Clear the indicated modem bits.
40 -pub fn tiocmbic(fd: RawFd, bits: c_int) -> io::Result<()> {
41 +pub fn tiocmbic(fd: RawFd, bits: BitsInt) -> io::Result<()> {
42 match unsafe { ioctl(fd, TIOCMBIC, &bits) } {
43 0 => Ok(()),
44 _ => Err(io::Error::last_os_error())
45 }
46 }
47 +
48 +#[cfg(test)]
49 +mod tests {
50 + use super::*;
51 + ///
52 + /// Will fail to compile if types don't match.
53 + #[allow(dead_code)]
54 + fn compile_bits() {
55 + tiocmbic(0, TIOCM_RTS).unwrap();
56 + }
57 +
58 + #[allow(dead_code)]
59 + fn compile_get_bits() {
60 + let bits = tiocmget(0).unwrap();
61 + tiocmset(0, bits).unwrap();
62 + }
63 +}
64 --- a/src/os/dragonfly.rs
65 +++ b/src/os/dragonfly.rs
66 @@ -67,6 +67,8 @@ pub const TIOCM_RNG: c_int = 0x00000080;
67 pub const TIOCM_RI: c_int = 0x00000080;
68 pub const TIOCM_DSR: c_int = 0x00000100;
69
70 +pub type BitsInt = c_int;
71 +
72 extern "C" {
73 pub fn ioctl(fildes: c_int, request: c_ulong, ...) -> c_int;
74 }
75 --- a/src/os/freebsd.rs
76 +++ b/src/os/freebsd.rs
77 @@ -67,6 +67,8 @@ pub const TIOCM_RNG: c_int = 0x00000080;
78 pub const TIOCM_RI: c_int = 0x00000080;
79 pub const TIOCM_DSR: c_int = 0x00000100;
80
81 +pub type BitsInt = c_int;
82 +
83 extern "C" {
84 pub fn ioctl(fildes: c_int, request: c_ulong, ...) -> c_int;
85 }
86 --- a/src/os/linux.rs
87 +++ b/src/os/linux.rs
88 @@ -115,6 +115,8 @@ pub const TIOCM_RNG: c_uint = 0x00000080
89 pub const TIOCM_RI: c_uint = 0x00000080;
90 pub const TIOCM_DSR: c_uint = 0x00000100;
91
92 +pub type BitsInt = c_uint;
93 +
94 extern "C" {
95 pub fn ioctl(fd: c_int, request: c_uint, ...) -> c_int;
96 }
97 --- a/src/os/macos.rs
98 +++ b/src/os/macos.rs
99 @@ -76,6 +76,8 @@ pub const TIOCM_RNG: c_int = 0x00000080;
100 pub const TIOCM_RI: c_int = 0x00000080;
101 pub const TIOCM_DSR: c_int = 0x00000100;
102
103 +pub type BitsInt = c_int;
104 +
105 extern "C" {
106 pub fn ioctl(fildes: c_int, request: c_ulong, ...) -> c_int;
107 }
108 --- a/src/os/openbsd.rs
109 +++ b/src/os/openbsd.rs
110 @@ -67,6 +67,8 @@ pub const TIOCM_RNG: c_int = 0x00000080;
111 pub const TIOCM_RI: c_int = 0x00000080;
112 pub const TIOCM_DSR: c_int = 0x00000100;
113
114 +pub type BitsInt = c_int;
115 +
116 extern "C" {
117 pub fn ioctl(fildes: c_int, request: c_ulong, ...) -> c_int;
118 }
0 deps tree:
1 serial (NEW)
2 - serial-core (NEW)
3 - serial-unix (NEW)
4 - termios (update, no rdeps)
5 - ioctl-rs (NEW)
11
22 * Package serial-unix 0.4.0 from crates.io using debcargo 2.4.4
33
4 -- Henry-Nicolas Tourneur <debian@nilux.be> Fri, 23 Apr 2021 19:45:54 +0000
4 -- Henry-Nicolas Tourneur <debian@nilux.be> Fri, 07 May 2021 12:47:38 +0000
0 Author: Henry-Nicolas Tourneur <debian@nilux.be>
1 Forwarded: not-needed
2 Description: Fix compilation errors with c_int / c_uint type incompatibilities
3 ---
4 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
5 --- a/src/tty.rs
6 +++ b/src/tty.rs
7 @@ -10,7 +10,7 @@ use std::time::Duration;
8
9 use std::os::unix::prelude::*;
10
11 -use libc::{c_int, c_void, size_t};
12 +use libc::{c_int, c_uint, c_void, size_t};
13
14 use core::{SerialDevice, SerialPortSettings};
15
16 @@ -85,7 +85,7 @@ impl TTYPort {
17 Ok(port)
18 }
19
20 - fn set_pin(&mut self, pin: c_int, level: bool) -> core::Result<()> {
21 + fn set_pin(&mut self, pin: c_uint, level: bool) -> core::Result<()> {
22 let retval = if level {
23 ioctl::tiocmbis(self.fd, pin)
24 }
25 @@ -99,7 +99,7 @@ impl TTYPort {
26 }
27 }
28
29 - fn read_pin(&mut self, pin: c_int) -> core::Result<bool> {
30 + fn read_pin(&mut self, pin: c_uint) -> core::Result<bool> {
31 match ioctl::tiocmget(self.fd) {
32 Ok(pins) => Ok(pins & pin != 0),
33 Err(err) => Err(super::error::from_io_error(err)),
0 fix_compile-errors.patch
01 relax-deps.patch