Skip to content

Commit

Permalink
Fix the name of c_ispeed/c_ospeed on powerpc musl targets. (#1158)
Browse files Browse the repository at this point in the history
Fixes #1157.
  • Loading branch information
sunfishcode authored Sep 11, 2024
1 parent ba0947f commit 23369bb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ jobs:
- run: cargo check -Zbuild-std=core,alloc --target=powerpc64-ibm-aix --features=all-apis --no-default-features
- run: cargo check -Z build-std --target=mipsel-unknown-linux-gnu --features=all-apis
- run: cargo check -Z build-std --target=mips64el-unknown-linux-gnuabi64 --features=all-apis
- run: cargo check -Z build-std --target=powerpc64le-unknown-linux-musl --features=all-apis


test:
Expand Down
43 changes: 43 additions & 0 deletions src/backend/libc/termios/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,29 @@ pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> {
local_modes: LocalModes::from_bits_retain(termios2.c_lflag),
line_discipline: termios2.c_line,
special_codes: SpecialCodes(Default::default()),

// On PowerPC musl targets, `c_ispeed`/`c_ospeed` are named
// `__c_ispeed`/`__c_ospeed`.
#[cfg(not(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
)))]
input_speed: termios2.c_ispeed,
#[cfg(not(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
)))]
output_speed: termios2.c_ospeed,
#[cfg(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
))]
input_speed: termios2.__c_ispeed,
#[cfg(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
))]
output_speed: termios2.__c_ospeed,
};

// Copy in the control codes, since libc's `c_cc` array may have a
Expand Down Expand Up @@ -179,15 +200,37 @@ pub(crate) fn tcsetattr(

let output_speed = termios.output_speed();
let input_speed = termios.input_speed();

let mut termios2 = c::termios2 {
c_iflag: termios.input_modes.bits(),
c_oflag: termios.output_modes.bits(),
c_cflag: termios.control_modes.bits(),
c_lflag: termios.local_modes.bits(),
c_line: termios.line_discipline,
c_cc: Default::default(),

// On PowerPC musl targets, `c_ispeed`/`c_ospeed` are named
// `__c_ispeed`/`__c_ospeed`.
#[cfg(not(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
)))]
c_ispeed: input_speed,
#[cfg(not(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
)))]
c_ospeed: output_speed,
#[cfg(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
))]
__c_ispeed: input_speed,
#[cfg(all(
target_env = "musl",
any(target_arch = "powerpc", target_arch = "powerpc64")
))]
__c_ospeed: output_speed,
};

// Ensure that our input and output speeds are set, as `libc`
Expand Down

0 comments on commit 23369bb

Please sign in to comment.