Skip to content

Commit d87d24e

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

File tree

15 files changed

+174
-2
lines changed

15 files changed

+174
-2
lines changed

libc-test/build.rs

Lines changed: 20 additions & 2 deletions
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
}

src/unix/notbsd/android/mod.rs

Lines changed: 11 additions & 0 deletions
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,

src/unix/notbsd/linux/mips/mod.rs

Lines changed: 11 additions & 0 deletions
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;

src/unix/notbsd/linux/musl/b32/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ s! {
4444
__unused1: ::c_long,
4545
__unused2: ::c_long
4646
}
47+
48+
pub struct termios2 {
49+
pub c_iflag: ::tcflag_t,
50+
pub c_oflag: ::tcflag_t,
51+
pub c_cflag: ::tcflag_t,
52+
pub c_lflag: ::tcflag_t,
53+
pub c_line: ::cc_t,
54+
pub c_cc: [::cc_t; ::NCCS],
55+
pub c_ispeed: ::speed_t,
56+
pub c_ospeed: ::speed_t,
57+
}
4758
}
4859

4960
pub const SIGSTKSZ: ::size_t = 8192;

src/unix/notbsd/linux/musl/b64/aarch64.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ s! {
6060
__unused1: ::c_ulong,
6161
__unused2: ::c_ulong,
6262
}
63+
64+
pub struct termios2 {
65+
pub c_iflag: ::tcflag_t,
66+
pub c_oflag: ::tcflag_t,
67+
pub c_cflag: ::tcflag_t,
68+
pub c_lflag: ::tcflag_t,
69+
pub c_line: ::cc_t,
70+
pub c_cc: [::cc_t; ::NCCS],
71+
pub c_ispeed: ::speed_t,
72+
pub c_ospeed: ::speed_t,
73+
}
6374
}
6475

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

src/unix/notbsd/linux/musl/b64/powerpc64.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ s! {
5858
__unused1: ::c_long,
5959
__unused2: ::c_long
6060
}
61+
62+
pub struct termios2 {
63+
pub c_iflag: ::tcflag_t,
64+
pub c_oflag: ::tcflag_t,
65+
pub c_cflag: ::tcflag_t,
66+
pub c_lflag: ::tcflag_t,
67+
pub c_line: ::cc_t,
68+
pub c_cc: [::cc_t; 19],
69+
pub c_ispeed: ::speed_t,
70+
pub c_ospeed: ::speed_t,
71+
}
6172
}
6273

6374
pub const SYS_pivot_root: ::c_long = 203;

src/unix/notbsd/linux/musl/b64/x86_64.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ s! {
7171
__unused1: ::c_long,
7272
__unused2: ::c_long
7373
}
74+
75+
pub struct termios2 {
76+
pub c_iflag: ::tcflag_t,
77+
pub c_oflag: ::tcflag_t,
78+
pub c_cflag: ::tcflag_t,
79+
pub c_lflag: ::tcflag_t,
80+
pub c_line: ::cc_t,
81+
pub c_cc: [::cc_t; ::NCCS],
82+
pub c_ispeed: ::speed_t,
83+
pub c_ospeed: ::speed_t,
84+
}
7485
}
7586

7687
// Syscall table

src/unix/notbsd/linux/other/b32/arm.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ s! {
101101
__glibc_reserved4: ::c_ulong,
102102
__glibc_reserved5: ::c_ulong,
103103
}
104+
105+
pub struct termios2 {
106+
pub c_iflag: ::tcflag_t,
107+
pub c_oflag: ::tcflag_t,
108+
pub c_cflag: ::tcflag_t,
109+
pub c_lflag: ::tcflag_t,
110+
pub c_line: ::cc_t,
111+
pub c_cc: [::cc_t; 19],
112+
pub c_ispeed: ::speed_t,
113+
pub c_ospeed: ::speed_t,
114+
}
104115
}
105116

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

src/unix/notbsd/linux/other/b32/powerpc.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ s! {
101101
__glibc_reserved4: ::c_ulong,
102102
__glibc_reserved5: ::c_ulong,
103103
}
104+
105+
pub struct termios2 {
106+
pub c_iflag: ::tcflag_t,
107+
pub c_oflag: ::tcflag_t,
108+
pub c_cflag: ::tcflag_t,
109+
pub c_lflag: ::tcflag_t,
110+
pub c_line: ::cc_t,
111+
pub c_cc: [::cc_t; ::NCCS],
112+
pub c_ispeed: ::speed_t,
113+
pub c_ospeed: ::speed_t,
114+
}
104115
}
105116

106117
pub const O_DIRECT: ::c_int = 0x20000;

src/unix/notbsd/linux/other/b32/x86.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,17 @@ s! {
200200
__glibc_reserved4: ::c_ulong,
201201
__glibc_reserved5: ::c_ulong,
202202
}
203+
204+
pub struct termios2 {
205+
pub c_iflag: ::tcflag_t,
206+
pub c_oflag: ::tcflag_t,
207+
pub c_cflag: ::tcflag_t,
208+
pub c_lflag: ::tcflag_t,
209+
pub c_line: ::cc_t,
210+
pub c_cc: [::cc_t; 19],
211+
pub c_ispeed: ::speed_t,
212+
pub c_ospeed: ::speed_t,
213+
}
203214
}
204215

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

0 commit comments

Comments
 (0)