1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +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:
Florian Weimer
2025-07-11 16:04:07 +02:00
parent 02e7ac5ee3
commit 3d3572f590
18 changed files with 116 additions and 260 deletions

View File

@@ -30,7 +30,18 @@
#include <sysdep.h>
#include <shlib-compat.h>
#include <termios_arch.h>
#include <termios-kernel-consts.h>
/* Alpha got termios2 late, but TCGETS has exactly the same structure
format and function as TCGETS2. On all other platforms, the termios2
interface exists as far back as this version of glibc supports.
For TCSETS* it is more complicated; this is handled in tcsetattr.c. */
#ifdef __ASSUME_TERMIOS2
# define ARCH_TCGETS KERNEL_TCGETS2
#else
# define ARCH_TCGETS KERNEL_TCGETS
#endif
/* ---- Kernel interface definitions ---- */
@@ -44,7 +55,7 @@ struct termios2
tcflag_t c_oflag; /* output mode flags */
tcflag_t c_cflag; /* control mode flags */
tcflag_t c_lflag; /* local mode flags */
#if _HAVE_TERMIOS2_C_CC_BEFORE_C_LINE
#if KERNEL_TERMIOS2_CC_OFFSET < KERNEL_TERMIOS2_LINE_OFFSET
cc_t c_cc[_TERMIOS2_NCCS]; /* control characters */
cc_t c_line; /* line discipline */
#else
@@ -55,26 +66,6 @@ struct termios2
speed_t c_ospeed; /* output speed */
};
/* Alpha got termios2 late, but TCGETS has exactly the same structure
format and function as TCGETS2. On all other platforms, the termios2
interface exists as far back as this version of glibc supports.
For TCSETS* it is more complicated; this is handled in tcsetattr.c.
Some other architectures only have the equivalent of the termios2
interface, in which case the old ioctl names are the only ones
presented, but are equivalent to the new ones. */
#ifndef TCGETS2
# define TCGETS2 TCGETS
# define TCSETS2 TCSETS
# define TCSETSW2 TCSETSW
# define TCSETSF2 TCSETSF
#elif !__ASSUME_TERMIOS2
/* Hack for Alpha */
# undef TCGETS2
# define TCGETS2 TCGETS
#endif
/* ---- Application interface definitions ---- */
/*
@@ -91,12 +82,7 @@ struct termios2
* This only applies to SPARC and MIPS; for other architectures the
* new and old speed_t interfaces both use the same struct termios.
*/
#if _HAVE_STRUCT_OLD_TERMIOS
typedef struct old_termios old_termios_t;
#else
# define OLD_NCCS NCCS
typedef struct termios old_termios_t;
#endif
#include <old_termios.h>
/* ---- Internal function definitions ---- */