Skip to content

Commit 97d6b43

Browse files
Merge #1805
1805: Add `line` field to `Termios` struct r=rtzoeller a=tertsdiepraam Fixes #1802 I have to admit I'm not really sure how to test this properly, so if that's necessary I require some help :) Co-authored-by: Terts Diepraam <terts.diepraam@gmail.com>
2 parents 9cbb7eb + 810f74a commit 97d6b43

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
66
## [Unreleased] - ReleaseDate
77
### Added
88

9+
- Added `line_discipline` field to `Termios` on Linux, Android and Haiku
10+
([#1805](https://github.com/nix-rust/nix/pull/1805))
11+
912
### Changed
1013

1114
- The MSRV is now 1.56.1

src/sys/termios.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ pub struct Termios {
181181
pub local_flags: LocalFlags,
182182
/// Control characters (see `termios.c_cc` documentation)
183183
pub control_chars: [libc::cc_t; NCCS],
184+
/// Line discipline (see `termios.c_line` documentation)
185+
#[cfg(any(
186+
target_os = "linux",
187+
target_os = "android",
188+
))]
189+
pub line_discipline: libc::cc_t,
190+
/// Line discipline (see `termios.c_line` documentation)
191+
#[cfg(target_os = "haiku")]
192+
pub line_discipline: libc::c_char,
184193
}
185194

186195
impl Termios {
@@ -196,6 +205,14 @@ impl Termios {
196205
termios.c_cflag = self.control_flags.bits();
197206
termios.c_lflag = self.local_flags.bits();
198207
termios.c_cc = self.control_chars;
208+
#[cfg(any(
209+
target_os = "linux",
210+
target_os = "android",
211+
target_os = "haiku",
212+
))]
213+
{
214+
termios.c_line = self.line_discipline;
215+
}
199216
}
200217
self.inner.borrow()
201218
}
@@ -214,6 +231,14 @@ impl Termios {
214231
termios.c_cflag = self.control_flags.bits();
215232
termios.c_lflag = self.local_flags.bits();
216233
termios.c_cc = self.control_chars;
234+
#[cfg(any(
235+
target_os = "linux",
236+
target_os = "android",
237+
target_os = "haiku",
238+
))]
239+
{
240+
termios.c_line = self.line_discipline;
241+
}
217242
}
218243
self.inner.as_ptr()
219244
}
@@ -226,6 +251,14 @@ impl Termios {
226251
self.control_flags = ControlFlags::from_bits_truncate(termios.c_cflag);
227252
self.local_flags = LocalFlags::from_bits_truncate(termios.c_lflag);
228253
self.control_chars = termios.c_cc;
254+
#[cfg(any(
255+
target_os = "linux",
256+
target_os = "android",
257+
target_os = "haiku",
258+
))]
259+
{
260+
self.line_discipline = termios.c_line;
261+
}
229262
}
230263
}
231264

@@ -238,6 +271,12 @@ impl From<libc::termios> for Termios {
238271
control_flags: ControlFlags::from_bits_truncate(termios.c_cflag),
239272
local_flags: LocalFlags::from_bits_truncate(termios.c_lflag),
240273
control_chars: termios.c_cc,
274+
#[cfg(any(
275+
target_os = "linux",
276+
target_os = "android",
277+
target_os = "haiku",
278+
))]
279+
line_discipline: termios.c_line,
241280
}
242281
}
243282
}

0 commit comments

Comments
 (0)