Skip to content

Commit

Permalink
Auto merge of #2518 - de-vri-es:move-termios2-to-arch, r=Amanieu
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Nov 6, 2021
2 parents 16c69c0 + 3a529d0 commit 25ea72c
Show file tree
Hide file tree
Showing 15 changed files with 54 additions and 150 deletions.
18 changes: 18 additions & 0 deletions src/unix/linux_like/linux/arch/generic/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
s! {
pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 19],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}
}

// include/uapi/asm-generic/socket.h
// arch/alpha/include/uapi/asm/socket.h
// tools/include/uapi/asm-generic/socket.h
Expand Down Expand Up @@ -98,3 +111,8 @@ cfg_if! {
// pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS;
pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING;

pub const TCGETS2: ::c_ulong = 0x802c542a;
pub const TCSETS2: ::c_ulong = 0x402c542b;
pub const TCSETSW2: ::c_ulong = 0x402c542c;
pub const TCSETSF2: ::c_ulong = 0x402c542d;
18 changes: 18 additions & 0 deletions src/unix/linux_like/linux/arch/mips/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
s! {
pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 23],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}
}

// arch/mips/include/uapi/asm/socket.h
pub const SOL_SOCKET: ::c_int = 0xffff;

Expand Down Expand Up @@ -94,3 +107,8 @@ pub const SO_TIMESTAMPING: ::c_int = 37;
// pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS;
pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING;

pub const TCGETS2: ::c_ulong = 0x4030542a;
pub const TCSETS2: ::c_ulong = 0x8030542b;
pub const TCSETSW2: ::c_ulong = 0x8030542c;
pub const TCSETSF2: ::c_ulong = 0x8030542d;
18 changes: 18 additions & 0 deletions src/unix/linux_like/linux/arch/sparc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
s! {
pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 19],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}
}

// arch/sparc/include/uapi/asm/socket.h
pub const SOL_SOCKET: ::c_int = 0xffff;

Expand Down Expand Up @@ -86,3 +99,8 @@ pub const SO_TIMESTAMPING: ::c_int = 0x0023;
// pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS;
pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING;

pub const TCGETS2: ::c_ulong = 0x402c540c;
pub const TCSETS2: ::c_ulong = 0x802c540d;
pub const TCSETSW2: ::c_ulong = 0x802c540e;
pub const TCSETSF2: ::c_ulong = 0x802c540f;
15 changes: 0 additions & 15 deletions src/unix/linux_like/linux/gnu/b32/arm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,6 @@ s! {
__glibc_reserved5: ::c_ulong,
}

pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 19],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}

pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
Expand Down Expand Up @@ -447,10 +436,6 @@ pub const TCGETS: ::c_ulong = 0x5401;
pub const TCSETS: ::c_ulong = 0x5402;
pub const TCSETSW: ::c_ulong = 0x5403;
pub const TCSETSF: ::c_ulong = 0x5404;
pub const TCGETS2: ::c_ulong = 0x802c542a;
pub const TCSETS2: ::c_ulong = 0x402c542b;
pub const TCSETSW2: ::c_ulong = 0x402c542c;
pub const TCSETSF2: ::c_ulong = 0x402c542d;
pub const TCGETA: ::c_ulong = 0x5405;
pub const TCSETA: ::c_ulong = 0x5406;
pub const TCSETAW: ::c_ulong = 0x5407;
Expand Down
15 changes: 0 additions & 15 deletions src/unix/linux_like/linux/gnu/b32/mips/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,6 @@ s! {
pub l_pid: ::pid_t,
pad: [::c_long; 4],
}

pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 23],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}
}

pub const O_LARGEFILE: ::c_int = 0x2000;
Expand Down Expand Up @@ -730,10 +719,6 @@ pub const TCGETS: ::c_ulong = 0x540d;
pub const TCSETS: ::c_ulong = 0x540e;
pub const TCSETSW: ::c_ulong = 0x540f;
pub const TCSETSF: ::c_ulong = 0x5410;
pub const TCGETS2: ::c_ulong = 0x4030542a;
pub const TCSETS2: ::c_ulong = 0x8030542b;
pub const TCSETSW2: ::c_ulong = 0x8030542c;
pub const TCSETSF2: ::c_ulong = 0x8030542d;
pub const TCGETA: ::c_ulong = 0x5401;
pub const TCSETA: ::c_ulong = 0x5402;
pub const TCSETAW: ::c_ulong = 0x5403;
Expand Down
4 changes: 0 additions & 4 deletions src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,6 @@ pub const TCGETS: ::c_ulong = 21505;
pub const TCSETS: ::c_ulong = 21506;
pub const TCSETSW: ::c_ulong = 21507;
pub const TCSETSF: ::c_ulong = 21508;
pub const TCGETS2: ::c_ulong = 0x802c542a;
pub const TCSETS2: ::c_ulong = 0x402c542b;
pub const TCSETSW2: ::c_ulong = 0x402c542c;
pub const TCSETSF2: ::c_ulong = 0x402c542d;
pub const TCGETA: ::c_ulong = 21509;
pub const TCSETA: ::c_ulong = 21510;
pub const TCSETAW: ::c_ulong = 21511;
Expand Down
15 changes: 0 additions & 15 deletions src/unix/linux_like/linux/gnu/b32/sparc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,6 @@ s! {
__glibc_reserved1: ::c_ulong,
__glibc_reserved2: ::c_ulong,
}

pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 19],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}
}

pub const RLIM_INFINITY: ::rlim_t = !0;
Expand Down Expand Up @@ -508,10 +497,6 @@ pub const TCGETS: ::c_ulong = 0x40245408;
pub const TCSETS: ::c_ulong = 0x80245409;
pub const TCSETSW: ::c_ulong = 0x8024540a;
pub const TCSETSF: ::c_ulong = 0x8024540b;
pub const TCGETS2: ::c_ulong = 0x402c540c;
pub const TCSETS2: ::c_ulong = 0x802c540d;
pub const TCSETSW2: ::c_ulong = 0x802c540e;
pub const TCSETSF2: ::c_ulong = 0x802c540f;
pub const TCGETA: ::c_ulong = 0x40125401;
pub const TCSETA: ::c_ulong = 0x80125402;
pub const TCSETAW: ::c_ulong = 0x80125403;
Expand Down
15 changes: 0 additions & 15 deletions src/unix/linux_like/linux/gnu/b32/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,6 @@ s! {
__glibc_reserved5: ::c_ulong,
}

pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 19],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}

pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
Expand Down Expand Up @@ -666,10 +655,6 @@ pub const TCGETS: ::c_ulong = 0x5401;
pub const TCSETS: ::c_ulong = 0x5402;
pub const TCSETSW: ::c_ulong = 0x5403;
pub const TCSETSF: ::c_ulong = 0x5404;
pub const TCGETS2: ::c_ulong = 0x802c542a;
pub const TCSETS2: ::c_ulong = 0x402c542b;
pub const TCSETSW2: ::c_ulong = 0x402c542c;
pub const TCSETSF2: ::c_ulong = 0x402c542d;
pub const TCGETA: ::c_ulong = 0x5405;
pub const TCSETA: ::c_ulong = 0x5406;
pub const TCSETAW: ::c_ulong = 0x5407;
Expand Down
15 changes: 0 additions & 15 deletions src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,6 @@ s! {
__unused5: ::c_ulong
}

pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 19],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}

pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_errno: ::c_int,
Expand Down Expand Up @@ -560,10 +549,6 @@ pub const TCGETS: ::c_ulong = 0x5401;
pub const TCSETS: ::c_ulong = 0x5402;
pub const TCSETSW: ::c_ulong = 0x5403;
pub const TCSETSF: ::c_ulong = 0x5404;
pub const TCGETS2: ::c_ulong = 0x802c542a;
pub const TCSETS2: ::c_ulong = 0x402c542b;
pub const TCSETSW2: ::c_ulong = 0x402c542c;
pub const TCSETSF2: ::c_ulong = 0x402c542d;
pub const TCGETA: ::c_ulong = 0x5405;
pub const TCSETA: ::c_ulong = 0x5406;
pub const TCSETAW: ::c_ulong = 0x5407;
Expand Down
15 changes: 0 additions & 15 deletions src/unix/linux_like/linux/gnu/b64/mips64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,6 @@ s! {
__unused4: ::c_ulong,
__unused5: ::c_ulong
}

pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 23],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}
}

pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
Expand Down Expand Up @@ -830,10 +819,6 @@ pub const TCGETS: ::c_ulong = 0x540d;
pub const TCSETS: ::c_ulong = 0x540e;
pub const TCSETSW: ::c_ulong = 0x540f;
pub const TCSETSF: ::c_ulong = 0x5410;
pub const TCGETS2: ::c_ulong = 0x4030542a;
pub const TCSETS2: ::c_ulong = 0x8030542b;
pub const TCSETSW2: ::c_ulong = 0x8030542c;
pub const TCSETSF2: ::c_ulong = 0x8030542d;
pub const TCGETA: ::c_ulong = 0x5401;
pub const TCSETA: ::c_ulong = 0x5402;
pub const TCSETAW: ::c_ulong = 0x5403;
Expand Down
4 changes: 0 additions & 4 deletions src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,6 @@ pub const TCGETS: ::c_ulong = 21505;
pub const TCSETS: ::c_ulong = 21506;
pub const TCSETSW: ::c_ulong = 21507;
pub const TCSETSF: ::c_ulong = 21508;
pub const TCGETS2: ::c_ulong = 0x802c542a;
pub const TCSETS2: ::c_ulong = 0x402c542b;
pub const TCSETSW2: ::c_ulong = 0x402c542c;
pub const TCSETSF2: ::c_ulong = 0x402c542d;
pub const TCGETA: ::c_ulong = 21509;
pub const TCSETA: ::c_ulong = 21510;
pub const TCSETAW: ::c_ulong = 21511;
Expand Down
11 changes: 0 additions & 11 deletions src/unix/linux_like/linux/gnu/b64/s390x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,17 +153,6 @@ s! {
__f_spare: [::c_int; 6],
}

pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 19],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}

pub struct __psw_t {
pub mask: u64,
pub addr: u64,
Expand Down
15 changes: 0 additions & 15 deletions src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,17 +193,6 @@ s! {
__reserved1: ::c_ulong,
__reserved2: ::c_ulong
}

pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 19],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}
}

pub const POSIX_FADV_DONTNEED: ::c_int = 4;
Expand Down Expand Up @@ -587,10 +576,6 @@ pub const TCGETS: ::c_ulong = 0x40245408;
pub const TCSETS: ::c_ulong = 0x80245409;
pub const TCSETSW: ::c_ulong = 0x8024540a;
pub const TCSETSF: ::c_ulong = 0x8024540b;
pub const TCGETS2: ::c_ulong = 0x402c540c;
pub const TCSETS2: ::c_ulong = 0x802c540d;
pub const TCSETSW2: ::c_ulong = 0x802c540e;
pub const TCSETSF2: ::c_ulong = 0x802c540f;
pub const TCGETA: ::c_ulong = 0x40125401;
pub const TCSETA: ::c_ulong = 0x80125402;
pub const TCSETAW: ::c_ulong = 0x80125403;
Expand Down
15 changes: 0 additions & 15 deletions src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,6 @@ s! {
__unused5: u64
}

pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 19],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}

pub struct ip_mreqn {
pub imr_multiaddr: ::in_addr,
pub imr_address: ::in_addr,
Expand Down Expand Up @@ -772,10 +761,6 @@ pub const TCGETS: ::c_ulong = 0x5401;
pub const TCSETS: ::c_ulong = 0x5402;
pub const TCSETSW: ::c_ulong = 0x5403;
pub const TCSETSF: ::c_ulong = 0x5404;
pub const TCGETS2: ::c_ulong = 0x802c542a;
pub const TCSETS2: ::c_ulong = 0x402c542b;
pub const TCSETSW2: ::c_ulong = 0x402c542c;
pub const TCSETSF2: ::c_ulong = 0x402c542d;
pub const TCGETA: ::c_ulong = 0x5405;
pub const TCSETA: ::c_ulong = 0x5406;
pub const TCSETAW: ::c_ulong = 0x5407;
Expand Down
11 changes: 0 additions & 11 deletions src/unix/linux_like/linux/musl/b32/hexagon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,6 @@ s! {
pub f_namemax: ::c_ulong,
__f_spare: [::c_int; 6],
}

pub struct termios2 {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_line: ::cc_t,
pub c_cc: [::cc_t; 19],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}
}

pub const AF_FILE: ::c_int = 1;
Expand Down

0 comments on commit 25ea72c

Please sign in to comment.