mirror of
https://sourceware.org/git/glibc.git
synced 2025-12-24 17:51:17 +03:00
Linux: Keep termios ioctl constants strictly internal
Undefine TCGETS, TCGETS2, and related ioctl constants in the installed headers. Extract the correct constants (using the kernel type definitions) automatically from the UAPI headers. The kernel constants are available under KERNEL_* names during the glibc build, computed using assembler constant extraction mechanism. Alpha may have to use TCGETS instead of TCGETS2 because TCTGETS2 became available in Linux 4.20 only. Introduce ARCH_TCGETS to make this choice explict. To support emulation on powerpc, glibc versions of the termios constants are added to the emulation code in internal-ioctl.h. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
@@ -19,6 +19,12 @@
|
||||
|
||||
#define static_assert_equal(x,y) _Static_assert ((x) == (y), #x " != " #y)
|
||||
|
||||
static_assert_equal (sizeof (struct termios2), KERNEL_TERMIOS2_SIZE);
|
||||
static_assert_equal (offsetof (struct termios2, c_cc),
|
||||
KERNEL_TERMIOS2_CC_OFFSET);
|
||||
static_assert_equal (offsetof (struct termios2, c_line),
|
||||
KERNEL_TERMIOS2_LINE_OFFSET);
|
||||
|
||||
/* Set the state of FD to *TERMIOS_P. */
|
||||
int
|
||||
__tcsetattr (int fd, int optional_actions, const struct termios *termios_p)
|
||||
@@ -53,10 +59,10 @@ __tcsetattr (int fd, int optional_actions, const struct termios *termios_p)
|
||||
*/
|
||||
static_assert_equal(TCSADRAIN, TCSANOW + 1);
|
||||
static_assert_equal(TCSAFLUSH, TCSANOW + 2);
|
||||
static_assert_equal(TCSETSW2, TCSETS2 + 1);
|
||||
static_assert_equal(TCSETSF2, TCSETS2 + 2);
|
||||
static_assert_equal(TCSETSW, TCSETS + 1);
|
||||
static_assert_equal(TCSETSF, TCSETS + 2);
|
||||
static_assert_equal(KERNEL_TCSETSW2, KERNEL_TCSETS2 + 1);
|
||||
static_assert_equal(KERNEL_TCSETSF2, KERNEL_TCSETS2 + 2);
|
||||
static_assert_equal(KERNEL_TCSETSW, KERNEL_TCSETS + 1);
|
||||
static_assert_equal(KERNEL_TCSETSF, KERNEL_TCSETS + 2);
|
||||
|
||||
cmd = (long)optional_actions - TCSANOW;
|
||||
if (cmd > 2)
|
||||
@@ -66,11 +72,11 @@ __tcsetattr (int fd, int optional_actions, const struct termios *termios_p)
|
||||
k_termios.c_ospeed != k_termios.c_ispeed ||
|
||||
cbaud (k_termios.c_cflag) == __BOTHER)
|
||||
{
|
||||
cmd += TCSETS2;
|
||||
cmd += KERNEL_TCSETS2;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd += TCSETS;
|
||||
cmd += KERNEL_TCSETS;
|
||||
k_termios.c_cflag &= ~CIBAUD;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user