Skip to content

Commit 25ea72c

Browse files
committed
Auto merge of #2518 - de-vri-es:move-termios2-to-arch, r=Amanieu
Move termios2 struct and ioctl constants to linux::arch::*. When trying to use the newly added ioctls from #2508 I noticed that the `termios2` struct was not defined for musl or uclibc, except interestingly for the hexagon+musl target However, the `termios2` struct and ioctls are part of the Linux headers, not part of the libc headers. So the libc flavour doesn't matter for these definitions. This PR moves the definitions to the `linux::arch::*` modules, to make them available for all libc flavours and reduce code duplication as a bonus.
2 parents 16c69c0 + 3a529d0 commit 25ea72c

File tree

15 files changed

+54
-150
lines changed

15 files changed

+54
-150
lines changed

src/unix/linux_like/linux/arch/generic/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
s! {
2+
pub struct termios2 {
3+
pub c_iflag: ::tcflag_t,
4+
pub c_oflag: ::tcflag_t,
5+
pub c_cflag: ::tcflag_t,
6+
pub c_lflag: ::tcflag_t,
7+
pub c_line: ::cc_t,
8+
pub c_cc: [::cc_t; 19],
9+
pub c_ispeed: ::speed_t,
10+
pub c_ospeed: ::speed_t,
11+
}
12+
}
13+
114
// include/uapi/asm-generic/socket.h
215
// arch/alpha/include/uapi/asm/socket.h
316
// tools/include/uapi/asm-generic/socket.h
@@ -98,3 +111,8 @@ cfg_if! {
98111
// pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
99112
pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS;
100113
pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING;
114+
115+
pub const TCGETS2: ::c_ulong = 0x802c542a;
116+
pub const TCSETS2: ::c_ulong = 0x402c542b;
117+
pub const TCSETSW2: ::c_ulong = 0x402c542c;
118+
pub const TCSETSF2: ::c_ulong = 0x402c542d;

src/unix/linux_like/linux/arch/mips/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
s! {
2+
pub struct termios2 {
3+
pub c_iflag: ::tcflag_t,
4+
pub c_oflag: ::tcflag_t,
5+
pub c_cflag: ::tcflag_t,
6+
pub c_lflag: ::tcflag_t,
7+
pub c_line: ::cc_t,
8+
pub c_cc: [::cc_t; 23],
9+
pub c_ispeed: ::speed_t,
10+
pub c_ospeed: ::speed_t,
11+
}
12+
}
13+
114
// arch/mips/include/uapi/asm/socket.h
215
pub const SOL_SOCKET: ::c_int = 0xffff;
316

@@ -94,3 +107,8 @@ pub const SO_TIMESTAMPING: ::c_int = 37;
94107
// pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
95108
pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS;
96109
pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING;
110+
111+
pub const TCGETS2: ::c_ulong = 0x4030542a;
112+
pub const TCSETS2: ::c_ulong = 0x8030542b;
113+
pub const TCSETSW2: ::c_ulong = 0x8030542c;
114+
pub const TCSETSF2: ::c_ulong = 0x8030542d;

src/unix/linux_like/linux/arch/sparc/mod.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
s! {
2+
pub struct termios2 {
3+
pub c_iflag: ::tcflag_t,
4+
pub c_oflag: ::tcflag_t,
5+
pub c_cflag: ::tcflag_t,
6+
pub c_lflag: ::tcflag_t,
7+
pub c_line: ::cc_t,
8+
pub c_cc: [::cc_t; 19],
9+
pub c_ispeed: ::speed_t,
10+
pub c_ospeed: ::speed_t,
11+
}
12+
}
13+
114
// arch/sparc/include/uapi/asm/socket.h
215
pub const SOL_SOCKET: ::c_int = 0xffff;
316

@@ -86,3 +99,8 @@ pub const SO_TIMESTAMPING: ::c_int = 0x0023;
8699
// pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
87100
pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS;
88101
pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING;
102+
103+
pub const TCGETS2: ::c_ulong = 0x402c540c;
104+
pub const TCSETS2: ::c_ulong = 0x802c540d;
105+
pub const TCSETSW2: ::c_ulong = 0x802c540e;
106+
pub const TCSETSF2: ::c_ulong = 0x802c540f;

src/unix/linux_like/linux/gnu/b32/arm/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,6 @@ s! {
141141
__glibc_reserved5: ::c_ulong,
142142
}
143143

144-
pub struct termios2 {
145-
pub c_iflag: ::tcflag_t,
146-
pub c_oflag: ::tcflag_t,
147-
pub c_cflag: ::tcflag_t,
148-
pub c_lflag: ::tcflag_t,
149-
pub c_line: ::cc_t,
150-
pub c_cc: [::cc_t; 19],
151-
pub c_ispeed: ::speed_t,
152-
pub c_ospeed: ::speed_t,
153-
}
154-
155144
pub struct siginfo_t {
156145
pub si_signo: ::c_int,
157146
pub si_errno: ::c_int,
@@ -447,10 +436,6 @@ pub const TCGETS: ::c_ulong = 0x5401;
447436
pub const TCSETS: ::c_ulong = 0x5402;
448437
pub const TCSETSW: ::c_ulong = 0x5403;
449438
pub const TCSETSF: ::c_ulong = 0x5404;
450-
pub const TCGETS2: ::c_ulong = 0x802c542a;
451-
pub const TCSETS2: ::c_ulong = 0x402c542b;
452-
pub const TCSETSW2: ::c_ulong = 0x402c542c;
453-
pub const TCSETSF2: ::c_ulong = 0x402c542d;
454439
pub const TCGETA: ::c_ulong = 0x5405;
455440
pub const TCSETA: ::c_ulong = 0x5406;
456441
pub const TCSETAW: ::c_ulong = 0x5407;

src/unix/linux_like/linux/gnu/b32/mips/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,6 @@ s! {
153153
pub l_pid: ::pid_t,
154154
pad: [::c_long; 4],
155155
}
156-
157-
pub struct termios2 {
158-
pub c_iflag: ::tcflag_t,
159-
pub c_oflag: ::tcflag_t,
160-
pub c_cflag: ::tcflag_t,
161-
pub c_lflag: ::tcflag_t,
162-
pub c_line: ::cc_t,
163-
pub c_cc: [::cc_t; 23],
164-
pub c_ispeed: ::speed_t,
165-
pub c_ospeed: ::speed_t,
166-
}
167156
}
168157

169158
pub const O_LARGEFILE: ::c_int = 0x2000;
@@ -730,10 +719,6 @@ pub const TCGETS: ::c_ulong = 0x540d;
730719
pub const TCSETS: ::c_ulong = 0x540e;
731720
pub const TCSETSW: ::c_ulong = 0x540f;
732721
pub const TCSETSF: ::c_ulong = 0x5410;
733-
pub const TCGETS2: ::c_ulong = 0x4030542a;
734-
pub const TCSETS2: ::c_ulong = 0x8030542b;
735-
pub const TCSETSW2: ::c_ulong = 0x8030542c;
736-
pub const TCSETSF2: ::c_ulong = 0x8030542d;
737722
pub const TCGETA: ::c_ulong = 0x5401;
738723
pub const TCSETA: ::c_ulong = 0x5402;
739724
pub const TCSETAW: ::c_ulong = 0x5403;

src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,6 @@ pub const TCGETS: ::c_ulong = 21505;
483483
pub const TCSETS: ::c_ulong = 21506;
484484
pub const TCSETSW: ::c_ulong = 21507;
485485
pub const TCSETSF: ::c_ulong = 21508;
486-
pub const TCGETS2: ::c_ulong = 0x802c542a;
487-
pub const TCSETS2: ::c_ulong = 0x402c542b;
488-
pub const TCSETSW2: ::c_ulong = 0x402c542c;
489-
pub const TCSETSF2: ::c_ulong = 0x402c542d;
490486
pub const TCGETA: ::c_ulong = 21509;
491487
pub const TCSETA: ::c_ulong = 21510;
492488
pub const TCSETAW: ::c_ulong = 21511;

src/unix/linux_like/linux/gnu/b32/sparc/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -191,17 +191,6 @@ s! {
191191
__glibc_reserved1: ::c_ulong,
192192
__glibc_reserved2: ::c_ulong,
193193
}
194-
195-
pub struct termios2 {
196-
pub c_iflag: ::tcflag_t,
197-
pub c_oflag: ::tcflag_t,
198-
pub c_cflag: ::tcflag_t,
199-
pub c_lflag: ::tcflag_t,
200-
pub c_line: ::cc_t,
201-
pub c_cc: [::cc_t; 19],
202-
pub c_ispeed: ::speed_t,
203-
pub c_ospeed: ::speed_t,
204-
}
205194
}
206195

207196
pub const RLIM_INFINITY: ::rlim_t = !0;
@@ -508,10 +497,6 @@ pub const TCGETS: ::c_ulong = 0x40245408;
508497
pub const TCSETS: ::c_ulong = 0x80245409;
509498
pub const TCSETSW: ::c_ulong = 0x8024540a;
510499
pub const TCSETSF: ::c_ulong = 0x8024540b;
511-
pub const TCGETS2: ::c_ulong = 0x402c540c;
512-
pub const TCSETS2: ::c_ulong = 0x802c540d;
513-
pub const TCSETSW2: ::c_ulong = 0x802c540e;
514-
pub const TCSETSF2: ::c_ulong = 0x802c540f;
515500
pub const TCGETA: ::c_ulong = 0x40125401;
516501
pub const TCSETA: ::c_ulong = 0x80125402;
517502
pub const TCSETAW: ::c_ulong = 0x80125403;

src/unix/linux_like/linux/gnu/b32/x86/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,6 @@ s! {
215215
__glibc_reserved5: ::c_ulong,
216216
}
217217

218-
pub struct termios2 {
219-
pub c_iflag: ::tcflag_t,
220-
pub c_oflag: ::tcflag_t,
221-
pub c_cflag: ::tcflag_t,
222-
pub c_lflag: ::tcflag_t,
223-
pub c_line: ::cc_t,
224-
pub c_cc: [::cc_t; 19],
225-
pub c_ispeed: ::speed_t,
226-
pub c_ospeed: ::speed_t,
227-
}
228-
229218
pub struct siginfo_t {
230219
pub si_signo: ::c_int,
231220
pub si_errno: ::c_int,
@@ -666,10 +655,6 @@ pub const TCGETS: ::c_ulong = 0x5401;
666655
pub const TCSETS: ::c_ulong = 0x5402;
667656
pub const TCSETSW: ::c_ulong = 0x5403;
668657
pub const TCSETSF: ::c_ulong = 0x5404;
669-
pub const TCGETS2: ::c_ulong = 0x802c542a;
670-
pub const TCSETS2: ::c_ulong = 0x402c542b;
671-
pub const TCSETSW2: ::c_ulong = 0x402c542c;
672-
pub const TCSETSF2: ::c_ulong = 0x402c542d;
673658
pub const TCGETA: ::c_ulong = 0x5405;
674659
pub const TCSETA: ::c_ulong = 0x5406;
675660
pub const TCSETAW: ::c_ulong = 0x5407;

src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,6 @@ s! {
168168
__unused5: ::c_ulong
169169
}
170170

171-
pub struct termios2 {
172-
pub c_iflag: ::tcflag_t,
173-
pub c_oflag: ::tcflag_t,
174-
pub c_cflag: ::tcflag_t,
175-
pub c_lflag: ::tcflag_t,
176-
pub c_line: ::cc_t,
177-
pub c_cc: [::cc_t; 19],
178-
pub c_ispeed: ::speed_t,
179-
pub c_ospeed: ::speed_t,
180-
}
181-
182171
pub struct siginfo_t {
183172
pub si_signo: ::c_int,
184173
pub si_errno: ::c_int,
@@ -560,10 +549,6 @@ pub const TCGETS: ::c_ulong = 0x5401;
560549
pub const TCSETS: ::c_ulong = 0x5402;
561550
pub const TCSETSW: ::c_ulong = 0x5403;
562551
pub const TCSETSF: ::c_ulong = 0x5404;
563-
pub const TCGETS2: ::c_ulong = 0x802c542a;
564-
pub const TCSETS2: ::c_ulong = 0x402c542b;
565-
pub const TCSETSW2: ::c_ulong = 0x402c542c;
566-
pub const TCSETSF2: ::c_ulong = 0x402c542d;
567552
pub const TCGETA: ::c_ulong = 0x5405;
568553
pub const TCSETA: ::c_ulong = 0x5406;
569554
pub const TCSETAW: ::c_ulong = 0x5407;

src/unix/linux_like/linux/gnu/b64/mips64/mod.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -183,17 +183,6 @@ s! {
183183
__unused4: ::c_ulong,
184184
__unused5: ::c_ulong
185185
}
186-
187-
pub struct termios2 {
188-
pub c_iflag: ::tcflag_t,
189-
pub c_oflag: ::tcflag_t,
190-
pub c_cflag: ::tcflag_t,
191-
pub c_lflag: ::tcflag_t,
192-
pub c_line: ::cc_t,
193-
pub c_cc: [::cc_t; 23],
194-
pub c_ispeed: ::speed_t,
195-
pub c_ospeed: ::speed_t,
196-
}
197186
}
198187

199188
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
@@ -830,10 +819,6 @@ pub const TCGETS: ::c_ulong = 0x540d;
830819
pub const TCSETS: ::c_ulong = 0x540e;
831820
pub const TCSETSW: ::c_ulong = 0x540f;
832821
pub const TCSETSF: ::c_ulong = 0x5410;
833-
pub const TCGETS2: ::c_ulong = 0x4030542a;
834-
pub const TCSETS2: ::c_ulong = 0x8030542b;
835-
pub const TCSETSW2: ::c_ulong = 0x8030542c;
836-
pub const TCSETSF2: ::c_ulong = 0x8030542d;
837822
pub const TCGETA: ::c_ulong = 0x5401;
838823
pub const TCSETA: ::c_ulong = 0x5402;
839824
pub const TCSETAW: ::c_ulong = 0x5403;

0 commit comments

Comments
 (0)