Skip to content

Commit 13f6dfb

Browse files
committed
Change the cfmakeraw() wrapper to handle the difference in its return type on AIX.
1 parent 224daf0 commit 13f6dfb

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/backend/libc/termios/syscalls.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,20 @@ pub(crate) fn set_input_speed(termios: &mut Termios, arbitrary_speed: u32) -> io
493493
#[cfg(not(any(target_os = "espidf", target_os = "nto", target_os = "wasi")))]
494494
#[inline]
495495
pub(crate) fn cfmakeraw(termios: &mut Termios) {
496-
unsafe { c::cfmakeraw(as_mut_ptr(termios).cast()) }
496+
unsafe {
497+
// On AIX, cfmakeraw() has a return type of 'int' instead of 'void'.
498+
// If the argument 'termios' is NULL, it returns -1; otherwise, it returns 0.
499+
// We believe it is safe to ignore the return value.
500+
#[cfg(target_os = "aix")]
501+
{
502+
let _ = c::cfmakeraw(as_mut_ptr(termios).cast());
503+
}
504+
505+
#[cfg(not(target_os = "aix"))]
506+
{
507+
c::cfmakeraw(as_mut_ptr(termios).cast());
508+
}
509+
}
497510
}
498511

499512
pub(crate) fn isatty(fd: BorrowedFd<'_>) -> bool {

0 commit comments

Comments
 (0)