Skip to content

Commit 23369bb

Browse files
authored
Fix the name of c_ispeed/c_ospeed on powerpc musl targets. (#1158)
Fixes #1157.
1 parent ba0947f commit 23369bb

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ jobs:
225225
- run: cargo check -Zbuild-std=core,alloc --target=powerpc64-ibm-aix --features=all-apis --no-default-features
226226
- run: cargo check -Z build-std --target=mipsel-unknown-linux-gnu --features=all-apis
227227
- run: cargo check -Z build-std --target=mips64el-unknown-linux-gnuabi64 --features=all-apis
228+
- run: cargo check -Z build-std --target=powerpc64le-unknown-linux-musl --features=all-apis
228229

229230

230231
test:

src/backend/libc/termios/syscalls.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,29 @@ pub(crate) fn tcgetattr(fd: BorrowedFd<'_>) -> io::Result<Termios> {
6767
local_modes: LocalModes::from_bits_retain(termios2.c_lflag),
6868
line_discipline: termios2.c_line,
6969
special_codes: SpecialCodes(Default::default()),
70+
71+
// On PowerPC musl targets, `c_ispeed`/`c_ospeed` are named
72+
// `__c_ispeed`/`__c_ospeed`.
73+
#[cfg(not(all(
74+
target_env = "musl",
75+
any(target_arch = "powerpc", target_arch = "powerpc64")
76+
)))]
7077
input_speed: termios2.c_ispeed,
78+
#[cfg(not(all(
79+
target_env = "musl",
80+
any(target_arch = "powerpc", target_arch = "powerpc64")
81+
)))]
7182
output_speed: termios2.c_ospeed,
83+
#[cfg(all(
84+
target_env = "musl",
85+
any(target_arch = "powerpc", target_arch = "powerpc64")
86+
))]
87+
input_speed: termios2.__c_ispeed,
88+
#[cfg(all(
89+
target_env = "musl",
90+
any(target_arch = "powerpc", target_arch = "powerpc64")
91+
))]
92+
output_speed: termios2.__c_ospeed,
7293
};
7394

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

180201
let output_speed = termios.output_speed();
181202
let input_speed = termios.input_speed();
203+
182204
let mut termios2 = c::termios2 {
183205
c_iflag: termios.input_modes.bits(),
184206
c_oflag: termios.output_modes.bits(),
185207
c_cflag: termios.control_modes.bits(),
186208
c_lflag: termios.local_modes.bits(),
187209
c_line: termios.line_discipline,
188210
c_cc: Default::default(),
211+
212+
// On PowerPC musl targets, `c_ispeed`/`c_ospeed` are named
213+
// `__c_ispeed`/`__c_ospeed`.
214+
#[cfg(not(all(
215+
target_env = "musl",
216+
any(target_arch = "powerpc", target_arch = "powerpc64")
217+
)))]
189218
c_ispeed: input_speed,
219+
#[cfg(not(all(
220+
target_env = "musl",
221+
any(target_arch = "powerpc", target_arch = "powerpc64")
222+
)))]
190223
c_ospeed: output_speed,
224+
#[cfg(all(
225+
target_env = "musl",
226+
any(target_arch = "powerpc", target_arch = "powerpc64")
227+
))]
228+
__c_ispeed: input_speed,
229+
#[cfg(all(
230+
target_env = "musl",
231+
any(target_arch = "powerpc", target_arch = "powerpc64")
232+
))]
233+
__c_ospeed: output_speed,
191234
};
192235

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

0 commit comments

Comments
 (0)