Skip to content

Commit e95e79e

Browse files
committed
Add termios 2 on all platforms
1 parent 15df477 commit e95e79e

File tree

9 files changed

+108
-2
lines changed

9 files changed

+108
-2
lines changed

Diff for: libc-test/build.rs

+20-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fn main() {
99
let aarch64 = target.contains("aarch64");
1010
let i686 = target.contains("i686");
1111
let x86_64 = target.contains("x86_64");
12+
let powerpc = target.contains("powerpc");
1213
let windows = target.contains("windows");
1314
let mingw = target.contains("windows-gnu");
1415
let linux = target.contains("unknown-linux");
@@ -377,6 +378,10 @@ fn main() {
377378
// FIXME: unskip it for next major release
378379
"stat" | "stat64" if android => true,
379380

381+
// These are tested as part of the linux_fcntl tests since there are
382+
// header conflicts when including them with all the other structs.
383+
"termios2" => true,
384+
380385
_ => false
381386
}
382387
});
@@ -671,8 +676,7 @@ fn main() {
671676
// fails on a lot of platforms.
672677
let mut cfg = ctest::TestGenerator::new();
673678
cfg.skip_type(|_| true)
674-
.skip_struct(|_| true)
675-
.skip_fn(|_| true);
679+
.skip_fn(|_| true);
676680
if android || linux {
677681
// musl defines these directly in `fcntl.h`
678682
if musl {
@@ -695,8 +699,22 @@ fn main() {
695699
_ => true,
696700
}
697701
});
702+
cfg.skip_struct(|s| {
703+
s != "termios2"
704+
});
705+
cfg.type_name(move |ty, is_struct| {
706+
match ty {
707+
// The termios2 struct is the same as `termios` on powerpc, so it's actually
708+
// undeclared in the headers. We'll still expose it there to still provide
709+
// some type safety, but we can't check it directly.
710+
"termios2" if powerpc => "struct termios".to_string(),
711+
t if is_struct => format!("struct {}", t),
712+
t => t.to_string(),
713+
}
714+
});
698715
} else {
699716
cfg.skip_const(|_| true);
717+
cfg.skip_struct(|_| true);
700718
}
701719
cfg.generate("../src/lib.rs", "linux_fcntl.rs");
702720
}

Diff for: src/unix/notbsd/android/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ s! {
8484
pub c_cc: [::cc_t; ::NCCS],
8585
}
8686

87+
pub struct termios2 {
88+
pub c_iflag: ::tcflag_t,
89+
pub c_oflag: ::tcflag_t,
90+
pub c_cflag: ::tcflag_t,
91+
pub c_lflag: ::tcflag_t,
92+
pub c_line: ::cc_t,
93+
pub c_cc: [::cc_t; 19],
94+
pub c_ispeed: ::speed_t,
95+
pub c_ospeed: ::speed_t,
96+
}
97+
8798
pub struct flock {
8899
pub l_type: ::c_short,
89100
pub l_whence: ::c_short,

Diff for: src/unix/notbsd/linux/mips/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ s! {
2525
__size: [::c_char; 32],
2626
__align: [::c_long; 0],
2727
}
28+
29+
pub struct termios2 {
30+
pub c_iflag: ::tcflag_t,
31+
pub c_oflag: ::tcflag_t,
32+
pub c_cflag: ::tcflag_t,
33+
pub c_lflag: ::tcflag_t,
34+
pub c_line: ::cc_t,
35+
pub c_cc: [::cc_t; 23],
36+
pub c_ispeed: ::speed_t,
37+
pub c_ospeed: ::speed_t,
38+
}
2839
}
2940

3041
pub const SFD_CLOEXEC: ::c_int = 0x080000;

Diff for: src/unix/notbsd/linux/musl/b32/arm.rs

+11
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,17 @@ s! {
138138
pub f_namemax: ::c_ulong,
139139
__f_spare: [::c_int; 6],
140140
}
141+
142+
pub struct termios2 {
143+
pub c_iflag: ::tcflag_t,
144+
pub c_oflag: ::tcflag_t,
145+
pub c_cflag: ::tcflag_t,
146+
pub c_lflag: ::tcflag_t,
147+
pub c_line: ::cc_t,
148+
pub c_cc: [::cc_t; 19],
149+
pub c_ispeed: ::speed_t,
150+
pub c_ospeed: ::speed_t,
151+
}
141152
}
142153

143154
pub const O_DIRECT: ::c_int = 0x10000;

Diff for: src/unix/notbsd/linux/musl/b32/mips.rs

+11
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ s! {
149149
pub f_namemax: ::c_ulong,
150150
__f_spare: [::c_int; 6],
151151
}
152+
153+
pub struct termios2 {
154+
pub c_iflag: ::tcflag_t,
155+
pub c_oflag: ::tcflag_t,
156+
pub c_cflag: ::tcflag_t,
157+
pub c_lflag: ::tcflag_t,
158+
pub c_line: ::cc_t,
159+
pub c_cc: [::cc_t; 23],
160+
pub c_ispeed: ::speed_t,
161+
pub c_ospeed: ::speed_t,
162+
}
152163
}
153164

154165
pub const O_DIRECT: ::c_int = 0o100000;

Diff for: src/unix/notbsd/linux/musl/b32/x86.rs

+11
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@ s! {
151151
pub f_namemax: ::c_ulong,
152152
__f_spare: [::c_int; 6],
153153
}
154+
155+
pub struct termios2 {
156+
pub c_iflag: ::tcflag_t,
157+
pub c_oflag: ::tcflag_t,
158+
pub c_cflag: ::tcflag_t,
159+
pub c_lflag: ::tcflag_t,
160+
pub c_line: ::cc_t,
161+
pub c_cc: [::cc_t; 19],
162+
pub c_ispeed: ::speed_t,
163+
pub c_ospeed: ::speed_t,
164+
}
154165
}
155166

156167
pub const O_DIRECT: ::c_int = 0x4000;

Diff for: src/unix/notbsd/linux/musl/b64/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ s! {
118118
pub _pad: [::c_int; 29],
119119
_align: [usize; 0],
120120
}
121+
122+
pub struct termios2 {
123+
pub c_iflag: ::tcflag_t,
124+
pub c_oflag: ::tcflag_t,
125+
pub c_cflag: ::tcflag_t,
126+
pub c_lflag: ::tcflag_t,
127+
pub c_line: ::cc_t,
128+
pub c_cc: [::cc_t; 19],
129+
pub c_ispeed: ::speed_t,
130+
pub c_ospeed: ::speed_t,
131+
}
121132
}
122133

123134
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;

Diff for: src/unix/notbsd/linux/other/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,17 @@ s! {
151151
pub c_ospeed: ::speed_t,
152152
}
153153

154+
pub struct termios2 {
155+
pub c_iflag: ::tcflag_t,
156+
pub c_oflag: ::tcflag_t,
157+
pub c_cflag: ::tcflag_t,
158+
pub c_lflag: ::tcflag_t,
159+
pub c_line: ::cc_t,
160+
pub c_cc: [::cc_t; 19],
161+
pub c_ispeed: ::speed_t,
162+
pub c_ospeed: ::speed_t,
163+
}
164+
154165
pub struct flock {
155166
pub l_type: ::c_short,
156167
pub l_whence: ::c_short,

Diff for: src/unix/notbsd/linux/s390x.rs

+11
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ s! {
177177
pub c_ospeed: ::speed_t,
178178
}
179179

180+
pub struct termios2 {
181+
pub c_iflag: ::tcflag_t,
182+
pub c_oflag: ::tcflag_t,
183+
pub c_cflag: ::tcflag_t,
184+
pub c_lflag: ::tcflag_t,
185+
pub c_line: ::cc_t,
186+
pub c_cc: [::cc_t; 19],
187+
pub c_ispeed: ::speed_t,
188+
pub c_ospeed: ::speed_t,
189+
}
190+
180191
pub struct sysinfo {
181192
pub uptime: ::c_long,
182193
pub loads: [::c_ulong; 3],

0 commit comments

Comments
 (0)