]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
linux: implement arbitrary and split speeds in termios
authorH. Peter Anvin (Intel) <hpa@zytor.com>
Thu, 12 Jun 2025 01:35:36 +0000 (18:35 -0700)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 17 Jun 2025 12:11:38 +0000 (09:11 -0300)
Linux has supported arbitrary speeds and split speeds in the kernel
since 2008 on all platforms except Alpha (fixed in 2020), but glibc
was never updated to match. This is further complicated by POSIX uses
of macros for the cf[gs]et[io]speed interfaces, rather than plain
numbers, as it really ought to have.

On most platforms, the glibc ABI includes the c_[io]speed fields in
struct termios, but they are incorrectly used. On MIPS and SPARC, they
are entirely missing.

For backwards compatibility, the kernel will still use the legacy
speed fields unless they are set to BOTHER, and will use the legacy
output speed as the input speed if the latter is 0 (== B0). However,
the specific encoding used is visible to user space applications,
including ones other than the one running.

- SPARC and MIPS get a new struct termios, and tc[gs]etattr() is
  versioned accordingly. However, the new struct termios is set to be
  a strict extension of the old one, which means that cf* interfaces
  other than the speed-related ones do not need versioning.
- The Bxxx constants are redefined as equivalent to their integer
  values and the legacy Bxxx constants are renamed __Bxxx.
- cf[gs]et[io]speed() and cfsetspeed() are versioned accordingly.
- tcgetattr() and cfset[io]speed() are adjusted to always keep the
  c_[io]speed fields correct (unlike earlier versions), but to
  canonicalize the representation to ALSO configure the legacy fields
  if a valid legacy representation exists.
- tcsetattr(), too, canonicalizes the representation in this way
  before passing it to the kernel, to maximize compatibility with
  older applications/tools.
- The old IBAUD0 hack is removed; it is no longer necessary since
  even the legacy c_cflag baud rate fields have had separate input
  values for a long time.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
62 files changed:
NEWS
sysdeps/unix/sysv/linux/Versions
sysdeps/unix/sysv/linux/aarch64/libc.abilist
sysdeps/unix/sysv/linux/alpha/bits/termios-c_cflag.h
sysdeps/unix/sysv/linux/alpha/bits/termios-cbaud.h [moved from sysdeps/unix/sysv/linux/alpha/bits/termios-baud.h with 58% similarity]
sysdeps/unix/sysv/linux/alpha/kernel-features.h
sysdeps/unix/sysv/linux/alpha/kernel_termios.h [deleted file]
sysdeps/unix/sysv/linux/alpha/libc.abilist
sysdeps/unix/sysv/linux/alpha/termios_arch.h [moved from sysdeps/unix/sysv/linux/mips/bits/termios-struct.h with 51% similarity]
sysdeps/unix/sysv/linux/arc/libc.abilist
sysdeps/unix/sysv/linux/arm/be/libc.abilist
sysdeps/unix/sysv/linux/arm/le/libc.abilist
sysdeps/unix/sysv/linux/bits/termios-baud.h
sysdeps/unix/sysv/linux/bits/termios-c_cflag.h
sysdeps/unix/sysv/linux/bits/termios-cbaud.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/bits/termios.h
sysdeps/unix/sysv/linux/cfsetspeed.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/csky/libc.abilist
sysdeps/unix/sysv/linux/hppa/libc.abilist
sysdeps/unix/sysv/linux/i386/libc.abilist
sysdeps/unix/sysv/linux/isatty.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/isatty_nostatus.c
sysdeps/unix/sysv/linux/kernel-features.h
sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist
sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
sysdeps/unix/sysv/linux/mips/Versions
sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
sysdeps/unix/sysv/linux/mips/termios_arch.h [moved from sysdeps/unix/sysv/linux/kernel_termios.h with 54% similarity]
sysdeps/unix/sysv/linux/old_termios.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/or1k/libc.abilist
sysdeps/unix/sysv/linux/powerpc/bits/termios-c_cflag.h
sysdeps/unix/sysv/linux/powerpc/bits/termios-cbaud.h [moved from sysdeps/unix/sysv/linux/powerpc/bits/termios-baud.h with 58% similarity]
sysdeps/unix/sysv/linux/powerpc/kernel_termios.h [deleted file]
sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
sysdeps/unix/sysv/linux/powerpc/termios_arch.h [moved from sysdeps/unix/sysv/linux/sparc/bits/termios-struct.h with 51% similarity]
sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
sysdeps/unix/sysv/linux/sh/be/libc.abilist
sysdeps/unix/sysv/linux/sh/le/libc.abilist
sysdeps/unix/sysv/linux/sparc/Versions
sysdeps/unix/sysv/linux/sparc/bits/termios-cbaud.h [moved from sysdeps/unix/sysv/linux/sparc/bits/termios-baud.h with 57% similarity]
sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
sysdeps/unix/sysv/linux/sparc/termios_arch.h [moved from sysdeps/unix/sysv/linux/sparc/kernel_termios.h with 51% similarity]
sysdeps/unix/sysv/linux/speed.c
sysdeps/unix/sysv/linux/tcgetattr.c
sysdeps/unix/sysv/linux/tcsetattr.c
sysdeps/unix/sysv/linux/termios_arch.h [moved from sysdeps/unix/sysv/linux/mips/kernel_termios.h with 50% similarity]
sysdeps/unix/sysv/linux/termios_internals.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist

diff --git a/NEWS b/NEWS
index afe8076dfc9da2ee35d01b3f44e31ef0224f5e97..cc668344c12255220881c8c8752eef3c744123b4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,10 @@ Major new features:
 * The ISO C2Y family of unsigned abs functions, i.e.
   uabs, ulabs, ullabs and uimaxabs, are now supported.
 
+* On Linux, the <termios.h> interface now supports arbitrary baud rates;
+  speed_t is redefined to simply be the baud rate specified as an
+  unsigned int, which matches the kernel interface.
+
 Deprecated and removed features, and other changes affecting compatibility:
 
 * The glibc.rtld.execstack now supports a compatibility mode to allow
index 55d565545ab3b601d30c330bc63be324fd5d681e..b721331bf71d8b09bc545006ae0796938cb49152 100644 (file)
@@ -332,6 +332,13 @@ libc {
     sched_getattr;
     sched_setattr;
   }
+  GLIBC_2.42 {
+    cfgetospeed;
+    cfgetispeed;
+    cfsetospeed;
+    cfsetispeed;
+    cfsetspeed;
+  }
   GLIBC_PRIVATE {
     # functions used in other libraries
     __syscall_rt_sigqueueinfo;
index aa6bf483dd702667ac5c26da1ddba8a7dc6adc36..fdccf84d8f8833063fda7acf42019818f1d7a3c6 100644 (file)
@@ -2752,6 +2752,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 1f9f7f2680d10d4896011e58513b5a235512ce9b..d8308848c624d41b70eb7caf18bcbd01ebf062fd 100644 (file)
@@ -36,4 +36,6 @@
 
 #ifdef __USE_MISC
 # define ADDRB 04000000000
+# define CMSPAR  010000000000 /* Mark or space (stick) parity.  */
+# define CRTSCTS 020000000000 /* Flow control.  */
 #endif
similarity index 58%
rename from sysdeps/unix/sysv/linux/alpha/bits/termios-baud.h
rename to sysdeps/unix/sysv/linux/alpha/bits/termios-cbaud.h
index 324d5d8776d3280346eadc852cce2577afcc284b..69421f6797108ea3c49d558a339e7aa200fcb491 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #ifndef _TERMIOS_H
-# error "Never include <bits/termios-baud.h> directly; use <termios.h> instead."
+# error "Never include <bits/termios-cbaud.h> directly; use <termios.h> instead."
 #endif
 
 #ifdef __USE_MISC
-# define CBAUD 0000037
-# define CBAUDEX 0000000
-# define CMSPAR          010000000000          /* mark or space (stick) parity */
-# define CRTSCTS  020000000000         /* flow control */
+# define CBAUD     000000037
+# define CBAUDEX    000000000
+# define CIBAUD     007600000
+# define IBSHIFT    16
 #endif
 
-#define  B57600   00020
-#define  B115200  00021
-#define  B230400  00022
-#define  B460800  00023
-#define  B500000  00024
-#define  B576000  00025
-#define  B921600  00026
-#define  B1000000 00027
-#define  B1152000 00030
-#define  B1500000 00031
-#define  B2000000 00032
-#define  B2500000 00033
-#define  B3000000 00034
-#define  B3500000 00035
-#define  B4000000 00036
-
-#define __MAX_BAUD B4000000
+#define  __B57600   00020
+#define  __B115200  00021
+#define  __B230400  00022
+#define  __B460800  00023
+#define  __B500000  00024
+#define  __B576000  00025
+#define  __B921600  00026
+#define  __B1000000 00027
+#define  __B1152000 00030
+#define  __B1500000 00031
+#define  __B2000000 00032
+#define  __B2500000 00033
+#define  __B3000000 00034
+#define  __B3500000 00035
+#define  __B4000000 00036
+#define  __BOTHER   00037
index 6eae48f13e74def6cccf7bf1bcfaafbcea10bfcd..83fdf91222a732aad63426431cfa3f9dbf9a6aa1 100644 (file)
 #undef __ASSUME_CLONE3
 #define __ASSUME_CLONE3 0
 
+/* Alpha did not provide BOTHER, CIBAUD or the termios2 ioctls until
+   kernel 4.20.  Even though struct __kernel_termios and struct
+   termios2 are the same on Alpha, Calling the legacy TCSETS* ioctls
+   with BOTHER set triggers a bug in these old kernels, so only use
+   the legacy TCSETS* ioctl numbers if neither BOTHER nor split speed is
+   needed; that way the code will fail gracefully. */
+#if __LINUX_KERNEL_VERSION < 0x041400
+# undef  __ASSUME_TERMIOS2
+# define __ASSUME_TERMIOS2 0
+#endif
+
 #endif /* _KERNEL_FEATURES_H */
diff --git a/sysdeps/unix/sysv/linux/alpha/kernel_termios.h b/sysdeps/unix/sysv/linux/alpha/kernel_termios.h
deleted file mode 100644 (file)
index 6a777dd..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright (C) 1997-2025 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef _KERNEL_TERMIOS_H
-#define _KERNEL_TERMIOS_H 1
-
-/* The following corresponds to the values from the Linux 2.1.20 kernel.  */
-
-/* We need the definition of tcflag_t, cc_t, and speed_t.  */
-#include <termios.h>
-
-#define __KERNEL_NCCS 19
-
-struct __kernel_termios
-  {
-    tcflag_t c_iflag;          /* input mode flags */
-    tcflag_t c_oflag;          /* output mode flags */
-    tcflag_t c_cflag;          /* control mode flags */
-    tcflag_t c_lflag;          /* local mode flags */
-    cc_t c_cc[__KERNEL_NCCS];  /* control characters */
-    cc_t c_line;               /* line discipline */
-    speed_t c_ispeed;          /* input speed */
-    speed_t c_ospeed;          /* output speed */
-  };
-
-#define _HAVE_C_ISPEED 1
-#define _HAVE_C_OSPEED 1
-
-#endif /* kernel_termios.h */
index d5df9656a8926359d53a348481c9fa1b11188d85..1e3f2781553ee0b5b2576a738bf480d21d0a2493 100644 (file)
@@ -3099,6 +3099,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
similarity index 51%
rename from sysdeps/unix/sysv/linux/mips/bits/termios-struct.h
rename to sysdeps/unix/sysv/linux/alpha/termios_arch.h
index ef698218f3a2cb6409aeb8984989443162364b43..20025f25495acd71451e76abba89812be48bace6 100644 (file)
@@ -1,5 +1,6 @@
-/* struct termios definition.  Linux/mips version.
-   Copyright (C) 2019-2025 Free Software Foundation, Inc.
+/* Architectural parameters for Linux termios - Alpha/PowerPC version
+
+   Copyright (C) 1997-2025 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
+   License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#ifndef _TERMIOS_H
-# error "Never include <bits/termios-struct.h> directly; use <termios.h> instead."
+#ifndef TERMIOS_INTERNALS_H
+# error "<termios_arch.h> should only be included from <termios_internals.h>"
 #endif
 
-#define NCCS 32
-struct termios
-  {
-    tcflag_t c_iflag;          /* input mode flags */
-    tcflag_t c_oflag;          /* output mode flags */
-    tcflag_t c_cflag;          /* control mode flags */
-    tcflag_t c_lflag;          /* local mode flags */
-    cc_t c_line;               /* line discipline */
-    cc_t c_cc[NCCS];           /* control characters */
-#define _HAVE_STRUCT_TERMIOS_C_ISPEED 0
-#define _HAVE_STRUCT_TERMIOS_C_OSPEED 0
-  };
+#define _TERMIOS2_NCCS 19
+#define _HAVE_TERMIOS2_C_CC_BEFORE_C_LINE 1
+#define _HAVE_STRUCT_OLD_TERMIOS 0
index c46c08da85c998fe9a8393329a393cdadef7bd18..7b7717d1d146f7669eb583375a372094c42ac97a 100644 (file)
@@ -2513,6 +2513,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 4df150c0f0426f6c8668d08ff8914e9a297da9a8..f64bf3f3278e65fc55248a0ba76b583dca4f9e0e 100644 (file)
@@ -2805,6 +2805,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index be294783f685ff15ca137d11cb47930eaaab7919..c065fe80fcd081055c7b279de89132827a51c515 100644 (file)
@@ -2802,6 +2802,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index e63a3eb4182eeb17b2aa22cca8f51b55e2a8edb6..1e41338b573971c5b60250dd2b481fc7f6014687 100644 (file)
 # error "Never include <bits/termios-baud.h> directly; use <termios.h> instead."
 #endif
 
-#ifdef __USE_MISC
-# define CBAUD  000000010017 /* Baud speed mask (not in POSIX).  */
-# define CBAUDEX 000000010000 /* Extra baud speed mask, included in CBAUD.
-                                (not in POSIX).  */
-# define CIBAUD         002003600000 /* Input baud rate (not used).  */
-# define CMSPAR  010000000000 /* Mark or space (stick) parity.  */
-# define CRTSCTS 020000000000 /* Flow control.  */
-#endif
+#define B0                   0U
+#define B50                 50U
+#define B75                 75U
+#define B110               110U
+#define B134               134U
+#define B150               150U
+#define B200               200U
+#define B300               300U
+#define B600               600U
+#define B1200             1200U
+#define B1800             1800U
+#define B2400             2400U
+#define B4800             4800U
+#define B7200             7200U
+#define B9600             9600U
+#define B14400           14400U
+#define B19200           19200U
+#define B28800           28800U
+#define B33600           33600U
+#define B38400           38400U
+#define B57600           57600U
+#define B76800           76800U
+#define B115200         115200U
+#define B153600         153600U
+#define B230400         230400U
+#define B307200         307200U
+#define B460800         460800U
+#define B500000         500000U
+#define B576000         576000U
+#define B614400         614400U
+#define B921600         921600U
+#define B1000000       1000000U
+#define B1152000       1152000U
+#define B1500000       1500000U
+#define B2000000       2000000U
+#define B2500000       2500000U
+#define B3000000       3000000U
+#define B3500000       3500000U
+#define B4000000       4000000U
 
-/* Extra output baud rates (not in POSIX).  */
-#define  B57600    0010001
-#define  B115200   0010002
-#define  B230400   0010003
-#define  B460800   0010004
-#define  B500000   0010005
-#define  B576000   0010006
-#define  B921600   0010007
-#define  B1000000  0010010
-#define  B1152000  0010011
-#define  B1500000  0010012
-#define  B2000000  0010013
-#define  B2500000  0010014
-#define  B3000000  0010015
-#define  B3500000  0010016
-#define  B4000000  0010017
-#define __MAX_BAUD B4000000
+#define __MAX_BAUD  4294967295U
index bbbb621d4ef05818a2608abeff697b34fdeed786..befd25a758dd762e2cbc262d8567c4e1a1cb539a 100644 (file)
@@ -34,5 +34,7 @@
 #define CLOCAL 0004000
 
 #ifdef __USE_MISC
-# define ADDRB 04000000000
+# define ADDRB    04000000000
+# define CMSPAR  010000000000 /* Mark or space (stick) parity.  */
+# define CRTSCTS 020000000000 /* Flow control.  */
 #endif
diff --git a/sysdeps/unix/sysv/linux/bits/termios-cbaud.h b/sysdeps/unix/sysv/linux/bits/termios-cbaud.h
new file mode 100644 (file)
index 0000000..b9aadff
--- /dev/null
@@ -0,0 +1,47 @@
+/* termios baud rate selection definitions.  Linux/generic version.
+   Copyright (C) 2019-2025 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _TERMIOS_H
+# error "Never include <bits/termios-cbaud.h> directly; use <termios.h> instead."
+#endif
+
+#ifdef __USE_MISC
+# define CBAUD  000000010017 /* Baud speed mask (not in POSIX).  */
+# define CBAUDEX 000000010000 /* Extra baud speed mask, included in CBAUD.
+                                (not in POSIX).  */
+# define CIBAUD         002003600000 /* Input baud rate.  */
+# define IBSHIFT 16
+#endif
+
+/* Extra output baud rates (not in POSIX).  */
+#define  __BOTHER    0010000
+#define  __B57600    0010001
+#define  __B115200   0010002
+#define  __B230400   0010003
+#define  __B460800   0010004
+#define  __B500000   0010005
+#define  __B576000   0010006
+#define  __B921600   0010007
+#define  __B1000000  0010010
+#define  __B1152000  0010011
+#define  __B1500000  0010012
+#define  __B2000000  0010013
+#define  __B2500000  0010014
+#define  __B3000000  0010015
+#define  __B3500000  0010016
+#define  __B4000000  0010017
index 3bd1e228297cffe4fec600b752b7c63913f65dab..14de3fcb55077be300943bc6d1f6a0d3494258a3 100644 (file)
@@ -24,35 +24,41 @@ typedef unsigned char       cc_t;
 typedef unsigned int   speed_t;
 typedef unsigned int   tcflag_t;
 
-#include <bits/termios-struct.h>
+#ifdef _TERMIOS_H
+# include <bits/termios-struct.h>
+#endif
+
 #include <bits/termios-c_cc.h>
 #include <bits/termios-c_iflag.h>
 #include <bits/termios-c_oflag.h>
 
 /* c_cflag bit meaning */
-#define  B0    0000000         /* hang up */
-#define  B50   0000001
-#define  B75   0000002
-#define  B110  0000003
-#define  B134  0000004
-#define  B150  0000005
-#define  B200  0000006
-#define  B300  0000007
-#define  B600  0000010
-#define  B1200 0000011
-#define  B1800 0000012
-#define  B2400 0000013
-#define  B4800 0000014
-#define  B9600 0000015
-#define  B19200        0000016
-#define  B38400        0000017
+#include <bits/termios-c_cflag.h>
+
+#define __B0    0000000        /* hang up */
+#define __B50   0000001
+#define __B75   0000002
+#define __B110  0000003
+#define __B134  0000004
+#define __B150  0000005
+#define __B200  0000006
+#define __B300  0000007
+#define __B600  0000010
+#define __B1200         0000011
+#define __B1800         0000012
+#define __B2400         0000013
+#define __B4800         0000014
+#define __B9600  0000015
+#define __B19200 0000016
+#define __B38400 0000017
+#include <bits/termios-cbaud.h>
+
 #ifdef __USE_MISC
-# define EXTA B19200
-# define EXTB B38400
+# define EXTA   __B19200
+# define EXTB   __B38400
+# define BOTHER  __BOTHER
 #endif
-#include <bits/termios-baud.h>
 
-#include <bits/termios-c_cflag.h>
 #include <bits/termios-c_lflag.h>
 
 #ifdef __USE_MISC
@@ -74,3 +80,5 @@ typedef unsigned int  tcflag_t;
 #include <bits/termios-tcflow.h>
 
 #include <bits/termios-misc.h>
+
+#include <bits/termios-baud.h>
diff --git a/sysdeps/unix/sysv/linux/cfsetspeed.c b/sysdeps/unix/sysv/linux/cfsetspeed.c
new file mode 100644 (file)
index 0000000..8fd9587
--- /dev/null
@@ -0,0 +1,58 @@
+/* cfsetspeed(), Linux version.
+   Copyright (C) 1991-2025 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <termios_internals.h>
+
+/* Set both the input and output baud rates stored in *TERMIOS_P to SPEED.  */
+int
+__cfsetspeed (struct termios *termios_p, speed_t speed)
+{
+  tcflag_t cbaud = ___speed_to_cbaud (speed);
+
+  termios_p->c_ospeed = speed;
+  termios_p->c_ispeed = speed;
+  termios_p->c_cflag &= ~(CBAUD | CIBAUD);
+  termios_p->c_cflag |= cbaud | (cbaud << IBSHIFT);
+
+  return 0;
+}
+versioned_symbol (libc, __cfsetspeed, cfsetspeed, GLIBC_2_42);
+
+#if _TERMIOS_OLD_COMPAT
+
+int
+attribute_compat_text_section
+__old_cfsetspeed (old_termios_t *termios_p, speed_t speed)
+{
+  speed_t real_speed = ___cbaud_to_speed (speed, -1);
+  if (real_speed == (speed_t)-1)
+    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+
+#if !_HAVE_STRUCT_OLD_TERMIOS
+  /* Otherwise these fields don't exist in old_termios_t */
+  termios_p->c_ospeed = real_speed;
+  termios_p->c_ispeed = real_speed;
+#endif
+  termios_p->c_cflag &= ~(CBAUD | CIBAUD);
+  termios_p->c_cflag |= speed | (speed << IBSHIFT);
+
+  return 0;
+}
+compat_symbol (libc, __old_cfsetspeed, cfsetspeed, GLIBC_2_0);
+
+#endif /* _TERMIOS_OLD_COMPAT */
index f123757134c6deda964ac02af19d2d46e64eed08..69ba60ea093e73099bd7aef6b176bef6885bf77c 100644 (file)
@@ -2789,6 +2789,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 2dc85b9533030febe5c7f351b87397cf51ef1c28..dea7c09692bd55cd200934798df2fe9155f1d337 100644 (file)
@@ -2826,6 +2826,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 1e38217ec6adaa6dafe88b2679dd851e8ada3938..4c05ab1c6e0700eb5c7b6cc210ef869304217bd8 100644 (file)
@@ -3009,6 +3009,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
diff --git a/sysdeps/unix/sysv/linux/isatty.c b/sysdeps/unix/sysv/linux/isatty.c
new file mode 100644 (file)
index 0000000..3faaec5
--- /dev/null
@@ -0,0 +1,29 @@
+/* Test whether a file descriptor refers to a terminal.  Linux version.
+   Copyright (C) 1991-2025 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <termios_internals.h>
+
+/* Return 1 if FD is a terminal, 0 if not. This simply does a
+   TCGETS2 ioctl into a dummy buffer without parsing the result. */
+int
+__isatty (int fd)
+{
+  struct termios2 k_termios;
+  return INLINE_SYSCALL_CALL (ioctl, fd, TCGETS2, &k_termios) == 0;
+}
+weak_alias (__isatty, isatty)
index 7f110be00c0a3ed39c7909827a8be0e38a7dc14f..406decba62a1dbefcf558b405f4510e5e301bcc9 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <sysdep.h>
-#include <termios.h>
-#include <kernel_termios.h>
-#include <sys/ioctl.h>
+#include <termios_internals.h>
 
 /* Return 1 if FD is a terminal, 0 if not, without changing errno  */
 int
 __isatty_nostatus (int fd)
 {
-  struct __kernel_termios k_termios;
-  return INTERNAL_SYSCALL_CALL (ioctl, fd, TCGETS, &k_termios) == 0;
+  struct termios2 k_termios;
+  return INTERNAL_SYSCALL_CALL (ioctl, fd, TCGETS2, &k_termios) == 0;
 }
index 86b2d3ce512588c8823c11076c91116092836402..a49a9159cfa7d4496395581e64a2a7ad2d8b99a8 100644 (file)
    configurations).  */
 #define __ASSUME_SET_ROBUST_LIST       1
 
+/* The termios2 interface was introduced across all architectures except
+   Alpha in kernel 2.6.22. */
+#define __ASSUME_TERMIOS2      1
+
 /* Support for various CLOEXEC and NONBLOCK flags was added in
    2.6.27.  */
 #define __ASSUME_IN_NONBLOCK   1
index 927fc2144526bce9884332717e240c56d065df80..6ab4968d17ce5038f16ba155919a22bfd05c30e4 100644 (file)
@@ -2273,6 +2273,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 74da49d9da42d697f85dc4d0c66c97fab2603132..e553bdc8a3b04598f8c41786d556e53bc410ee76 100644 (file)
@@ -2785,6 +2785,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index e5d678111f49da5415006b07b2535a23da85bf83..1239f0d7a02919f45723ec8e0844f50f32d61a1e 100644 (file)
@@ -2952,6 +2952,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 4dbd4b60450fe3a7fc9f66afd8fe313f1496bbd0..943e89a45fd494680f64d91593ebcfa07197186f 100644 (file)
@@ -2838,6 +2838,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index c5965bb50cf57f86648819cdafb97d9cc57b950c..9c303d9d9aa8dddee877ab80c67af3d41ec1dcd1 100644 (file)
@@ -2835,6 +2835,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 9ea0fa65a4ac3c41c6f7c87afa872f08757108ce..48f0037fe62ad489649bf78923288ab3f21d4690 100644 (file)
@@ -26,6 +26,10 @@ libc {
     pthread_attr_setstack;
     pthread_attr_setstacksize;
   }
+  GLIBC_2.42 {
+    tcgetattr;
+    tcsetattr;
+  }
   GLIBC_PRIVATE {
     # nptl/pthread_cond_timedwait.c uses INTERNAL_VSYSCALL(clock_gettime).
     __vdso_clock_gettime;
index 10715e07779fc4e44508dd1aaf11857ba49bdde4..6eb6fd476b0d54a1d455f9361e3c8629c6bffa8a 100644 (file)
@@ -2913,7 +2913,14 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
+GLIBC_2.42 tcgetattr F
+GLIBC_2.42 tcsetattr F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
 GLIBC_2.42 ulabs F
index 3d229b9853f0a6ba2bf6cfed2e9cdda9eb052a9b..58a43bb9b3d36b8dc0d1bc2ea4375aad073fb3bc 100644 (file)
@@ -2911,7 +2911,14 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
+GLIBC_2.42 tcgetattr F
+GLIBC_2.42 tcsetattr F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
 GLIBC_2.42 ulabs F
index e4cb45275b989cdb142206c642211b74a2986476..abab2ad807584624791015c1a8d9fa9e549b6577 100644 (file)
@@ -2919,7 +2919,14 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
+GLIBC_2.42 tcgetattr F
+GLIBC_2.42 tcsetattr F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
 GLIBC_2.42 ulabs F
index 8a32d2585dccb52c0bdc57ff91cf469a9a59fe62..2e31f6eed6b7d15f583d99892ceb524fe49be417 100644 (file)
@@ -2821,7 +2821,14 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
+GLIBC_2.42 tcgetattr F
+GLIBC_2.42 tcsetattr F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
 GLIBC_2.42 ulabs F
similarity index 54%
rename from sysdeps/unix/sysv/linux/kernel_termios.h
rename to sysdeps/unix/sysv/linux/mips/termios_arch.h
index f02a197518b563de6428996c0d3e04f5b6782ec8..392d9aa792ed052b926fb877b1efd44d9c215b22 100644 (file)
@@ -1,4 +1,6 @@
-/* Copyright (C) 1997-2025 Free Software Foundation, Inc.
+/* Architectural parameters for Linux termios - MIPS version
+
+   Copyright (C) 1991-2025 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#ifndef _KERNEL_TERMIOS_H
-#define _KERNEL_TERMIOS_H 1
-/* The following corresponds to the values from the Linux 2.1.20 kernel.  */
-
-#define __KERNEL_NCCS 19
-
-struct __kernel_termios
-  {
-    tcflag_t c_iflag;          /* input mode flags */
-    tcflag_t c_oflag;          /* output mode flags */
-    tcflag_t c_cflag;          /* control mode flags */
-    tcflag_t c_lflag;          /* local mode flags */
-    cc_t c_line;               /* line discipline */
-    cc_t c_cc[__KERNEL_NCCS];  /* control characters */
-  };
-
-#define _HAVE_C_ISPEED 0
-#define _HAVE_C_OSPEED 0
-
-#endif /* kernel_termios.h */
+#define _TERMIOS2_NCCS 23
+#define _HAVE_TERMIOS2_C_CC_BEFORE_C_LINE 0
+
+#define _HAVE_STRUCT_OLD_TERMIOS 1
+
+#define OLD_NCCS 32
+struct old_termios
+{
+  tcflag_t c_iflag;            /* input mode flags */
+  tcflag_t c_oflag;            /* output mode flags */
+  tcflag_t c_cflag;            /* control mode flags */
+  tcflag_t c_lflag;            /* local mode flags */
+  cc_t c_line;                 /* line discipline */
+  cc_t c_cc[OLD_NCCS];         /* control characters */
+};
diff --git a/sysdeps/unix/sysv/linux/old_termios.h b/sysdeps/unix/sysv/linux/old_termios.h
new file mode 100644 (file)
index 0000000..56d19ba
--- /dev/null
@@ -0,0 +1,23 @@
+/* old_termios.h for Linux other than MIPS and SPARC
+
+   Copyright (C) 2025 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* By default, no old termios structure */
+#define _HAVE_STRUCT_OLD_TERMIOS 0
+#define OLD_NCCS NCCS
+typedef struct termios old_termios_t;
index 64dac95b2afda0a0118b28bac18628d4bc4efe6b..b54c078b520cecbebdce9b883087f2136014fd4e 100644 (file)
@@ -2263,6 +2263,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 9ea8cfbe725e2294a9571c3f51806b678097bc12..a90d581484ef4478dfab01c3fb1ca9eeb1a3af8a 100644 (file)
@@ -35,5 +35,7 @@
 #define CLOCAL 00100000
 
 #ifdef __USE_MISC
-# define ADDRB 04000000000
+# define ADDRB    04000000000
+# define CMSPAR  010000000000 /* Mark or space (stick) parity.  */
+# define CRTSCTS 020000000000 /* Flow control.  */
 #endif
similarity index 58%
rename from sysdeps/unix/sysv/linux/powerpc/bits/termios-baud.h
rename to sysdeps/unix/sysv/linux/powerpc/bits/termios-cbaud.h
index 374d9f89498fcedb92c62a33c2da942cca7775ba..7bcbba441ae8d190dae52780ad8ea0a33b9ede74 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #ifndef _TERMIOS_H
-# error "Never include <bits/termios-baud.h> directly; use <termios.h> instead."
+# error "Never include <bits/termios-cbaud.h> directly; use <termios.h> instead."
 #endif
 
 #ifdef __USE_MISC
-# define CBAUD 0000377
-# define CBAUDEX 0000020
-# define CMSPAR   010000000000         /* mark or space (stick) parity */
-# define CRTSCTS  020000000000         /* flow control */
+# define CBAUD     000000377
+# define CBAUDEX    000000020
+# define CIBAUD     077600000
+# define IBSHIFT    16
 #endif
 
-#define  B57600   00020
-#define  B115200  00021
-#define  B230400  00022
-#define  B460800  00023
-#define  B500000  00024
-#define  B576000  00025
-#define  B921600  00026
-#define  B1000000 00027
-#define  B1152000 00030
-#define  B1500000 00031
-#define  B2000000 00032
-#define  B2500000 00033
-#define  B3000000 00034
-#define  B3500000 00035
-#define  B4000000 00036
-#define __MAX_BAUD B4000000
+#define  __B57600   00020
+#define  __B115200  00021
+#define  __B230400  00022
+#define  __B460800  00023
+#define  __B500000  00024
+#define  __B576000  00025
+#define  __B921600  00026
+#define  __B1000000 00027
+#define  __B1152000 00030
+#define  __B1500000 00031
+#define  __B2000000 00032
+#define  __B2500000 00033
+#define  __B3000000 00034
+#define  __B3500000 00035
+#define  __B4000000 00036
+#define  __BOTHER   00037
diff --git a/sysdeps/unix/sysv/linux/powerpc/kernel_termios.h b/sysdeps/unix/sysv/linux/powerpc/kernel_termios.h
deleted file mode 100644 (file)
index f6ea570..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright (C) 1997-2025 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
-
-#ifndef _KERNEL_TERMIOS_H
-#define _KERNEL_TERMIOS_H 1
-
-/* We need the definition of tcflag_t, cc_t, and speed_t.  */
-#include <termios.h>
-
-#define __KERNEL_NCCS 19
-
-struct __kernel_termios
-  {
-    tcflag_t c_iflag;          /* input mode flags */
-    tcflag_t c_oflag;          /* output mode flags */
-    tcflag_t c_cflag;          /* control mode flags */
-    tcflag_t c_lflag;          /* local mode flags */
-    cc_t c_cc[__KERNEL_NCCS];  /* control characters */
-    cc_t c_line;               /* line discipline */
-    speed_t c_ispeed;           /* input speed */
-    speed_t c_ospeed;           /* output speed */
-  };
-
-#define _HAVE_C_ISPEED 1
-#define _HAVE_C_OSPEED 1
-
-/* We have the kernel termios structure, so we can presume this code knows
-   what it's doing...  */
-
-#undef  TCGETS
-#undef  TCSETS
-#undef  TCSETSW
-#undef  TCSETSF
-#define TCGETS _IOR ('t', 19, struct __kernel_termios)
-#define TCSETS _IOW ('t', 20, struct __kernel_termios)
-#define TCSETSW        _IOW ('t', 21, struct __kernel_termios)
-#define TCSETSF        _IOW ('t', 22, struct __kernel_termios)
-
-#endif /* kernel_termios.h */
index cc5e93c77c9ddb54b51f2dd7cc5e37246358037a..c30e17cdfca2a320f0d4f48c953304656a1a6241 100644 (file)
@@ -3142,6 +3142,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 98149970836773af349cf77b1a91c689cd5b52b2..f3c0c0205249cb746e934a5fc47b43a7338f5ec6 100644 (file)
@@ -3187,6 +3187,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 7f46295c11fd09cb8e5150d877db2c6a12f2c968..6e1d141ca7fdc747a90cb98bb33a4018c7c0342a 100644 (file)
@@ -2896,6 +2896,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index f24f81bb5f33009406a2aff0cc1df1be11aa69ab..441296c7e8bad108654e072a74bc306d5e5bef4f 100644 (file)
@@ -2972,6 +2972,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
similarity index 51%
rename from sysdeps/unix/sysv/linux/sparc/bits/termios-struct.h
rename to sysdeps/unix/sysv/linux/powerpc/termios_arch.h
index 269ca9d6758352d9c49cbc15d256e0bc8d68f761..20025f25495acd71451e76abba89812be48bace6 100644 (file)
@@ -1,5 +1,6 @@
-/* struct termios definition.  Linux/sparc version.
-   Copyright (C) 2019-2025 Free Software Foundation, Inc.
+/* Architectural parameters for Linux termios - Alpha/PowerPC version
+
+   Copyright (C) 1997-2025 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
+   License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#ifndef _TERMIOS_H
-# error "Never include <bits/termios-struct.h> directly; use <termios.h> instead."
+#ifndef TERMIOS_INTERNALS_H
+# error "<termios_arch.h> should only be included from <termios_internals.h>"
 #endif
 
-#define NCCS 17
-struct termios
-  {
-    tcflag_t c_iflag;          /* input mode flags */
-    tcflag_t c_oflag;          /* output mode flags */
-    tcflag_t c_cflag;          /* control mode flags */
-    tcflag_t c_lflag;          /* local mode flags */
-    cc_t c_line;               /* line discipline */
-    cc_t c_cc[NCCS];           /* control characters */
-#define _HAVE_STRUCT_TERMIOS_C_ISPEED 0
-#define _HAVE_STRUCT_TERMIOS_C_OSPEED 0
-  };
+#define _TERMIOS2_NCCS 19
+#define _HAVE_TERMIOS2_C_CC_BEFORE_C_LINE 1
+#define _HAVE_STRUCT_OLD_TERMIOS 0
index 9330c7ab762abf7539aa853375f492d901e0e609..bcc0ed8d6a5f71a7e98128f4aad277603dde4176 100644 (file)
@@ -2516,6 +2516,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index ea4555d39e007223147febc78112e344ab59b25c..d55b553c0e3988cba6d23fc34a1ea76fdb7a2864 100644 (file)
@@ -2716,6 +2716,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 3e625fa4e928c11dc572f87ccc899f2caf0d5a92..a45b8874f0a3740d4dd28bb83257bb1bf13555d9 100644 (file)
@@ -3140,6 +3140,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 46b4a04f65079eb253daefe9abbff23ef8b71ce4..17483dcc48959e271ed97ccdcfdb7976976eed38 100644 (file)
@@ -2933,6 +2933,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index 36a94c9210ce55e8acd17b2e4054c8772ba98c4b..cb62b6e083eb7d2a3716765d5005dcc3d1f1ebb0 100644 (file)
@@ -2832,6 +2832,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index f79aba6aab3dbc5c372841b7dfe84f48fd50683d..ee6f2d017073b8b548b8b7eebf16c18c6b58e4e7 100644 (file)
@@ -2829,6 +2829,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index f127bdf0b88df418effccfe580906d99f70a3b71..7dd61a54c44736640910c5b4031f8bfab26ca4e0 100644 (file)
@@ -29,6 +29,10 @@ libc {
 
     __getshmlba;
   }
+  GLIBC_2.42 {
+    tcgetattr;
+    tcsetattr;
+  }
   GLIBC_PRIVATE {
     # nptl/pthread_cond_timedwait.c uses INTERNAL_VSYSCALL(clock_gettime).
     __vdso_clock_gettime;
similarity index 57%
rename from sysdeps/unix/sysv/linux/sparc/bits/termios-baud.h
rename to sysdeps/unix/sysv/linux/sparc/bits/termios-cbaud.h
index 677db7ba116af1fef747a69cd3048dc2e0ebb7d7..34eba1818449a6c0ea666b97a4b5335ca61d3df0 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #ifndef _TERMIOS_H
-# error "Never include <bits/termios-baud.h> directly; use <termios.h> instead."
+# error "Never include <bits/termios-cbaud.h> directly; use <termios.h> instead."
 #endif
 
 #ifdef __USE_MISC
 # define CBAUD   0x0000100f
 # define CBAUDEX 0x00001000
-# define CIBAUD         0x100f0000     /* input baud rate (not used) */
-# define CMSPAR  0x40000000    /* mark or space (stick) parity */
-# define CRTSCTS 0x80000000    /* flow control */
+# define CIBAUD         0x100f0000     /* input baud rate */
+# define IBSHIFT 16
 #endif
 
-#define  B57600  0x00001001
-#define  B115200 0x00001002
-#define  B230400 0x00001003
-#define  B460800 0x00001004
-#define  B76800  0x00001005
-#define  B153600 0x00001006
-#define  B307200 0x00001007
-#define  B614400 0x00001008
-#define  B921600 0x00001009
-#define  B500000 0x0000100a
-#define  B576000 0x0000100b
-#define B1000000 0x0000100c
-#define B1152000 0x0000100d
-#define B1500000 0x0000100e
-#define B2000000 0x0000100f
-#define __MAX_BAUD B2000000
+#define  __B57600  0x00001001
+#define  __B115200 0x00001002
+#define  __B230400 0x00001003
+#define  __B460800 0x00001004
+#define  __B76800  0x00001005
+#define  __B153600 0x00001006
+#define  __B307200 0x00001007
+#define  __B614400 0x00001008
+#define  __B921600 0x00001009
+#define  __B500000 0x0000100a
+#define  __B576000 0x0000100b
+#define __B1000000 0x0000100c
+#define __B1152000 0x0000100d
+#define __B1500000 0x0000100e
+#define __B2000000 0x0000100f
+#define __BOTHER   0x00001000
index 4a6acc08e04760e489c423d9a323f52b8f4cb8c5..943e130d3a8af0be604121d0c8386926755ab4f2 100644 (file)
@@ -3161,7 +3161,14 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
+GLIBC_2.42 tcgetattr F
+GLIBC_2.42 tcsetattr F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
 GLIBC_2.42 ulabs F
index 931109dab18a313bf226687cc4d3e58156d5b171..1017babb1d593987f74def595db669ca8a8c5353 100644 (file)
@@ -2797,7 +2797,14 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
+GLIBC_2.42 tcgetattr F
+GLIBC_2.42 tcsetattr F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
 GLIBC_2.42 ulabs F
similarity index 51%
rename from sysdeps/unix/sysv/linux/sparc/kernel_termios.h
rename to sysdeps/unix/sysv/linux/sparc/termios_arch.h
index 401079c4e55dd7437edc854feb6a87ba8833e59e..f3b3f656d14e0fef9709dd39a48df80652aee641 100644 (file)
@@ -1,4 +1,6 @@
-/* Copyright (C) 1997-2025 Free Software Foundation, Inc.
+/* Architectural parameters for Linux termios - SPARC version
+
+   Copyright (C) 1991-2025 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#ifndef _KERNEL_TERMIOS_H
-#define _KERNEL_TERMIOS_H 1
-/* The following corresponds to the values from the Linux 2.1.20 kernel.  */
-
-/* We need the definition of tcflag_t, cc_t, and speed_t.  */
-#include <termios.h>
-
-#define __KERNEL_NCCS 17
-
-struct __kernel_termios
-  {
-    tcflag_t c_iflag;          /* input mode flags */
-    tcflag_t c_oflag;          /* output mode flags */
-    tcflag_t c_cflag;          /* control mode flags */
-    tcflag_t c_lflag;          /* local mode flags */
-    cc_t c_line;               /* line discipline */
-    cc_t c_cc[__KERNEL_NCCS];  /* control characters */
-  };
-
-#define _HAVE_C_ISPEED 0
-#define _HAVE_C_OSPEED 0
-
-#endif /* kernel_termios.h */
+#define _TERMIOS2_NCCS 19
+#define _HAVE_TERMIOS2_C_CC_BEFORE_C_LINE 0
+
+#define _HAVE_STRUCT_OLD_TERMIOS 1
+
+#define OLD_NCCS 17
+struct old_termios
+{
+  tcflag_t c_iflag;            /* input mode flags */
+  tcflag_t c_oflag;            /* output mode flags */
+  tcflag_t c_cflag;            /* control mode flags */
+  tcflag_t c_lflag;            /* local mode flags */
+  cc_t c_line;                 /* line discipline */
+  cc_t c_cc[OLD_NCCS];         /* control characters */
+};
index 017f74177f9be9ee8ddd4c33ed8370ccd361d735..c9f4bb9d3f63c4e800d9041475a45fdc5d107b98 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <stddef.h>
-#include <errno.h>
-#include <termios.h>
-#include <sysdep.h>
+#include <termios_internals.h>
 
-/* This is a gross hack around a kernel bug.  If the cfsetispeed functions
-   is called with the SPEED argument set to zero this means use the same
-   speed as for output.  But we don't have independent input and output
-   speeds and therefore cannot record this.
+/* Conversions between legacy c_cflag fields and actual baud rates */
 
-   We use an unused bit in the `c_iflag' field to keep track of this
-   use of `cfsetispeed'.  The value here must correspond to the one used
-   in `tcsetattr.c'.  */
-#define IBAUD0 020000000000
+/* These expressions may seem complicated; the _cbix() macro
+   compresses the CBAUD field into an index in the range 0-31. On most
+   Linux platforms, the CBAUD field is 5 bits, but the topmost bit
+   indicated by CBAUDEX, is discontinous with the rest.
+
+   The resulting masks look like:
+
+               Alpha           PowerPC         others
+
+   CBAUD       0x001f          0x00ff          0x100f
+   CBAUDEX     0x0000          0x0010          0x1000
+
+   LOWCBAUD    0x001f          0x000f          0x000f
+   CBAUDMASK   0x001f          0x001f          0x100f
+
+   CBAUDMASK is used to test for invalid values passed to the
+   compatibility functions or in termios::c_cflag on PowerPC.
+
+   The divide-multiply sequence in the _cbix() macro gets converted
+   to shift and masks as necessary by the compiler. */
+
+#define LOWCBAUD (CBAUD & (CBAUDEX-1))
+#define _cbix(x) (((x) & LOWCBAUD) | \
+                 (CBAUDEX ? ((x) & CBAUDEX)/CBAUDEX * (LOWCBAUD+1) : 0))
+#define CBAUDMASK (LOWCBAUD | CBAUDEX)
+
+/* Compile time sanity checks for broken CBAUD or CIBAUD definitions */
+#if CIBAUD != (CBAUD << IBSHIFT)
+# error "CIBAUD should == CBAUD << IBSHIFT"
+#elif CBAUDEX & (CBAUDEX-1)
+# error "CBAUDEX should either be 0 or a single bit"
+#elif !(CBAUD & 1)
+# error "The CBAUD field should start at bit 0"
+#elif CBAUDEX & ~CBAUD
+# error "CBAUD should include the CBAUDEX bit"
+#endif
+
+speed_t
+___cbaud_to_speed (tcflag_t c_cflag, speed_t other)
+{
+  static const speed_t cbaudix_to_speed [] =
+    {
+      [0 ... _cbix(CBAUDMASK)] = -1,
+      [_cbix(__B0)] = 0,
+      [_cbix(__B50)] = 50,
+      [_cbix(__B75)] = 75,
+      [_cbix(__B110)] = 110,
+      [_cbix(__B134)] = 134,
+      [_cbix(__B150)] = 150,
+      [_cbix(__B200)] = 200,
+      [_cbix(__B300)] = 300,
+      [_cbix(__B600)] = 600,
+      [_cbix(__B1200)] = 1200,
+      [_cbix(__B1800)] = 1800,
+      [_cbix(__B2400)] = 2400,
+      [_cbix(__B4800)] = 4800,
+      [_cbix(__B9600)] = 9600,
+      [_cbix(__B19200)] = 19200,
+      [_cbix(__B38400)] = 38400,
+      [_cbix(__B57600)] = 57600,
+      [_cbix(__B115200)] = 115200,
+      [_cbix(__B230400)] = 230400,
+      [_cbix(__B460800)] = 460800,
+      [_cbix(__B500000)] = 500000,
+      [_cbix(__B576000)] = 576000,
+      [_cbix(__B921600)] = 921600,
+      [_cbix(__B1000000)] = 1000000,
+      [_cbix(__B1152000)] = 1152000,
+      [_cbix(__B1500000)] = 1500000,
+      [_cbix(__B2000000)] = 2000000,
+#ifdef __B7200
+      [_cbix(__B7200)] = 7200,
+#endif
+#ifdef __B14400
+      [_cbix(__B14400)] = 14400,
+#endif
+#ifdef __B28800
+      [_cbix(__B28800)] = 28800,
+#endif
+#ifdef __B76800
+      [_cbix(__B76800)] = 76800,
+#endif
+#ifdef __B153600
+      [_cbix(__B153600)] = 153600,
+#endif
+#ifdef __B307200
+      [_cbix(__B307200)] = 307200,
+#endif
+#ifdef __B614400
+      [_cbix(__B614400)] = 614400,
+#endif
+#ifdef __B2500000
+      [_cbix(__B2500000)] = 2500000,
+#endif
+#ifdef __B3000000
+      [_cbix(__B3000000)] = 3000000,
+#endif
+#ifdef __B3500000
+      [_cbix(__B3500000)] = 3500000,
+#endif
+#ifdef __B4000000
+      [_cbix(__B4000000)] = 4000000,
+#endif
+    };
+  speed_t speed;
+
+  if (c_cflag & (tcflag_t)(~CBAUDMASK))
+    return other;
+
+  speed = cbaudix_to_speed[_cbix(c_cflag)];
+  return speed == (speed_t)-1 ? other : speed;
+}
+
+tcflag_t
+___speed_to_cbaud (speed_t speed)
+{
+  switch (speed) {
+  case 0:
+    return __B0;
+  case 50:
+    return __B50;
+  case 75:
+    return __B75;
+  case 110:
+    return __B110;
+  case 134:
+    return __B134;
+  case 150:
+    return __B150;
+  case 200:
+    return __B200;
+  case 300:
+    return __B300;
+  case 600:
+    return __B600;
+  case 1200:
+    return __B1200;
+  case 1800:
+    return __B1800;
+  case 2400:
+    return __B2400;
+  case 4800:
+    return __B4800;
+  case 9600:
+    return __B9600;
+  case 19200:
+    return __B19200;
+  case 38400:
+    return __B38400;
+  case 57600:
+    return __B57600;
+  case 115200:
+    return __B115200;
+  case 230400:
+    return __B230400;
+  case 460800:
+    return __B460800;
+  case 500000:
+    return __B500000;
+  case 576000:
+    return __B576000;
+  case 921600:
+    return __B921600;
+  case 1000000:
+    return __B1000000;
+  case 1152000:
+    return __B1152000;
+  case 1500000:
+    return __B1500000;
+  case 2000000:
+    return __B2000000;
+#ifdef __B76800
+  case 76800:
+    return __B76800;
+#endif
+#ifdef __B153600
+  case 153600:
+    return __B153600;
+#endif
+#ifdef __B307200
+  case 307200:
+    return __B307200;
+#endif
+#ifdef __B614400
+  case 614400:
+    return __B614400;
+#endif
+#ifdef __B2500000
+  case 2500000:
+    return __B2500000;
+#endif
+#ifdef __B3000000
+  case 3000000:
+    return __B3000000;
+#endif
+#ifdef __B3500000
+  case 3500000:
+    return __B3500000;
+#endif
+#ifdef __B4000000
+  case 4000000:
+    return __B4000000;
+#endif
+  default:
+    return __BOTHER;
+  }
+}
+
+
+/* Canonicalize the representation of speed fields in a kernel
+   termios2 structure.  Specifically, if there is a valid legacy cbaud
+   representation (not __BOTHER), use it and propagate the
+   corresponding speed value to ispeed/ospeed, otherwise the other way
+   around if possible.  Finally, if the input speed is zero, copy the
+   output speed to the input speed.
+
+   The kernel doesn't do this canonicalization, which can affect
+   legacy utilities, so do it here.
+
+   This is used by tcgetattr() and tcsetattr(). */
+void
+___termios2_canonicalize_speeds (struct termios2 *k_termios_p)
+{
+  k_termios_p->c_ospeed =
+      ___cbaud_to_speed (cbaud (k_termios_p->c_cflag),  k_termios_p->c_ospeed);
+  k_termios_p->c_ispeed =
+      ___cbaud_to_speed (cibaud (k_termios_p->c_cflag), k_termios_p->c_ispeed);
+
+  if (!k_termios_p->c_ispeed)
+    k_termios_p->c_ispeed = k_termios_p->c_ospeed;
+
+  k_termios_p->c_cflag &= ~(CBAUD | CIBAUD);
+  k_termios_p->c_cflag |= ___speed_to_cbaud (k_termios_p->c_ospeed);
+  k_termios_p->c_cflag |= ___speed_to_cbaud (k_termios_p->c_ispeed) << IBSHIFT;
+}
 
 
 /* Return the output baud rate stored in *TERMIOS_P.  */
 speed_t
-cfgetospeed (const struct termios *termios_p)
+__cfgetospeed (const struct termios *termios_p)
 {
-  return termios_p->c_cflag & (CBAUD | CBAUDEX);
+  return termios_p->c_ospeed;
 }
+versioned_symbol (libc, __cfgetospeed, cfgetospeed, GLIBC_2_42);
 
-/* Return the input baud rate stored in *TERMIOS_P.
-   Although for Linux there is no difference between input and output
-   speed, the numerical 0 is a special case for the input baud rate. It
-   should set the input baud rate to the output baud rate. */
+/* Return the input baud rate stored in *TERMIOS_P.  */
 speed_t
-cfgetispeed (const struct termios *termios_p)
+__cfgetispeed (const struct termios *termios_p)
 {
-  return ((termios_p->c_iflag & IBAUD0)
-         ? 0 : termios_p->c_cflag & (CBAUD | CBAUDEX));
+  return termios_p->c_ispeed;
 }
+versioned_symbol (libc, __cfgetispeed, cfgetispeed, GLIBC_2_42);
 
 /* Set the output baud rate stored in *TERMIOS_P to SPEED.  */
 int
-cfsetospeed (struct termios *termios_p, speed_t speed)
+__cfsetospeed (struct termios *termios_p, speed_t speed)
 {
-  if ((speed & ~CBAUD) != 0
-      && (speed < B57600 || speed > __MAX_BAUD))
-    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+  tcflag_t cbaud = ___speed_to_cbaud (speed);
 
-#if _HAVE_STRUCT_TERMIOS_C_OSPEED
   termios_p->c_ospeed = speed;
+  termios_p->c_cflag &= ~CBAUD;
+  termios_p->c_cflag |= cbaud;
+
+  return 0;
+}
+versioned_symbol (libc, __cfsetospeed, cfsetospeed, GLIBC_2_42);
+
+/* Set the input baud rate stored in *TERMIOS_P to SPEED. */
+int
+__cfsetispeed (struct termios *termios_p, speed_t speed)
+{
+  tcflag_t cbaud = ___speed_to_cbaud (speed);
+
+  termios_p->c_ispeed = speed;
+  termios_p->c_cflag &= ~CIBAUD;
+  termios_p->c_cflag |= cbaud << IBSHIFT;
+
+  return 0;
+}
+versioned_symbol (libc, __cfsetispeed, cfsetispeed, GLIBC_2_42);
+
+#if _TERMIOS_OLD_COMPAT
+
+/* Legacy versions which returns cbaud-encoded speed_t values */
+
+speed_t
+attribute_compat_text_section
+__old_cfgetospeed (const old_termios_t *termios_p)
+{
+  return cbaud (termios_p->c_cflag);
+}
+compat_symbol (libc, __old_cfgetospeed, cfgetospeed, GLIBC_2_0);
+
+speed_t
+attribute_compat_text_section
+__old_cfgetispeed (const old_termios_t *termios_p)
+{
+  return cibaud (termios_p->c_cflag);
+}
+compat_symbol (libc, __old_cfgetispeed, cfgetispeed, GLIBC_2_0);
+
+int
+attribute_compat_text_section
+__old_cfsetospeed (old_termios_t *termios_p, speed_t speed)
+{
+  speed_t real_speed = ___cbaud_to_speed (speed, -1);
+  if (real_speed == (speed_t)-1)
+    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+
+#if !_HAVE_STRUCT_OLD_TERMIOS
+  /* Otherwise this field doesn't exist in old_termios_t */
+  termios_p->c_ospeed = real_speed;
 #endif
-  termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
+  termios_p->c_cflag &= ~CBAUD;
   termios_p->c_cflag |= speed;
 
   return 0;
 }
-libc_hidden_def (cfsetospeed)
+compat_symbol (libc, __old_cfsetospeed, cfsetospeed, GLIBC_2_0);
 
-
-/* Set the input baud rate stored in *TERMIOS_P to SPEED.
-   Although for Linux there is no difference between input and output
-   speed, the numerical 0 is a special case for the input baud rate.  It
-   should set the input baud rate to the output baud rate.  */
 int
-cfsetispeed (struct termios *termios_p, speed_t speed)
+attribute_compat_text_section
+__old_cfsetispeed (old_termios_t *termios_p, speed_t speed)
 {
-  if ((speed & ~CBAUD) != 0
-      && (speed < B57600 || speed > __MAX_BAUD))
+  speed_t real_speed = ___cbaud_to_speed (speed, -1);
+  if (real_speed == (speed_t)-1)
     return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
 
-#if _HAVE_STRUCT_TERMIOS_C_ISPEED
-  termios_p->c_ispeed = speed;
+#if !_HAVE_STRUCT_OLD_TERMIOS
+  /* Otherwise this field doesn't exist in old_termios_t */
+  termios_p->c_ispeed = real_speed;
 #endif
-  if (speed == 0)
-    termios_p->c_iflag |= IBAUD0;
-  else
-    {
-      termios_p->c_iflag &= ~IBAUD0;
-      termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
-      termios_p->c_cflag |= speed;
-    }
+  termios_p->c_cflag &= ~CIBAUD;
+  termios_p->c_cflag |= speed << IBSHIFT;
 
   return 0;
 }
-libc_hidden_def (cfsetispeed)
+compat_symbol (libc, __old_cfsetispeed, cfsetispeed, GLIBC_2_0);
+
+#endif /* _TERMIOS_OLD_COMPAT */
index d672e0c3b1d82e66e89b6b9a3801ddbdc8625fc3..ca175697a3f4fa62759ae73a17d122656190c3d6 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sysdep.h>
-
-/* The difference here is that the termios structure used in the
-   kernel is not the same as we use in the libc.  Therefore we must
-   translate it here.  */
-#include <kernel_termios.h>
+#include <termios_internals.h>
 
 /* Put the state of FD into *TERMIOS_P.  */
 int
 __tcgetattr (int fd, struct termios *termios_p)
 {
-  struct __kernel_termios k_termios;
-  int retval;
-
-  retval = INLINE_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios);
+  struct termios2 k_termios;
+  long int retval = INLINE_SYSCALL_CALL (ioctl, fd, TCGETS2, &k_termios);
 
-  if (__glibc_likely (retval == 0))
+  if (__glibc_likely (retval != -1))
     {
-      termios_p->c_iflag = k_termios.c_iflag;
-      termios_p->c_oflag = k_termios.c_oflag;
-      termios_p->c_cflag = k_termios.c_cflag;
-      termios_p->c_lflag = k_termios.c_lflag;
-      termios_p->c_line = k_termios.c_line;
-#if _HAVE_STRUCT_TERMIOS_C_ISPEED
-# if _HAVE_C_ISPEED
-      termios_p->c_ispeed = k_termios.c_ispeed;
-# else
-      termios_p->c_ispeed = k_termios.c_cflag & (CBAUD | CBAUDEX);
-# endif
-#endif
-#if _HAVE_STRUCT_TERMIOS_C_OSPEED
-# if _HAVE_C_OSPEED
+      ___termios2_canonicalize_speeds (&k_termios);
+
+      memset (termios_p, 0, sizeof (*termios_p));
+      termios_p->c_iflag  = k_termios.c_iflag;
+      termios_p->c_oflag  = k_termios.c_oflag;
+      termios_p->c_cflag  = k_termios.c_cflag;
+      termios_p->c_lflag  = k_termios.c_lflag;
+      termios_p->c_line   = k_termios.c_line;
       termios_p->c_ospeed = k_termios.c_ospeed;
-# else
-      termios_p->c_ospeed = k_termios.c_cflag & (CBAUD | CBAUDEX);
-# endif
-#endif
-      if (sizeof (cc_t) == 1 || _POSIX_VDISABLE == 0
-         || (unsigned char) _POSIX_VDISABLE == (unsigned char) -1)
-       memset (__mempcpy (&termios_p->c_cc[0], &k_termios.c_cc[0],
-                          __KERNEL_NCCS * sizeof (cc_t)),
-               _POSIX_VDISABLE, (NCCS - __KERNEL_NCCS) * sizeof (cc_t));
-      else
-       {
-         memcpy (&termios_p->c_cc[0], &k_termios.c_cc[0],
-                 __KERNEL_NCCS * sizeof (cc_t));
+      termios_p->c_ispeed = k_termios.c_ispeed;
 
-         for (size_t cnt = __KERNEL_NCCS; cnt < NCCS; ++cnt)
-           termios_p->c_cc[cnt] = _POSIX_VDISABLE;
-       }
+      copy_c_cc (termios_p->c_cc, NCCS, k_termios.c_cc, _TERMIOS2_NCCS);
     }
 
   return retval;
 }
-
 libc_hidden_def (__tcgetattr)
+
+#if _TERMIOS_OLD_COMPAT && _HAVE_STRUCT_OLD_TERMIOS
+
+versioned_symbol (libc, __tcgetattr, tcgetattr, GLIBC_2_42);
+
+/* Legacy version for shorter struct termios */
+int
+attribute_compat_text_section
+__old_tcgetattr (int fd, old_termios_t *termios_p)
+{
+  struct termios new_termios;
+  int retval = __tcgetattr (fd, &new_termios);
+  if (__glibc_likely (retval != -1))
+    {
+      memcpy (termios_p, &new_termios, sizeof (*termios_p));
+    }
+  return retval;
+}
+compat_symbol (libc, __old_tcgetattr, tcgetattr, GLIBC_2_0);
+
+#else
+
 weak_alias (__tcgetattr, tcgetattr)
+
+#endif
index 49d9d245a06795d37da7846b70abb09770d70c2c..4f07a03e665772ac12def539d1c620526519a096 100644 (file)
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <string.h>
-#include <termios.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sysdep.h>
-
-/* The difference here is that the termios structure used in the
-   kernel is not the same as we use in the libc.  Therefore we must
-   translate it here.  */
-#include <kernel_termios.h>
-
-
-/* This is a gross hack around a kernel bug.  If the cfsetispeed functions
-   is called with the SPEED argument set to zero this means use the same
-   speed as for output.  But we don't have independent input and output
-   speeds and therefore cannot record this.
-
-   We use an unused bit in the `c_iflag' field to keep track of this
-   use of `cfsetispeed'.  The value here must correspond to the one used
-   in `speed.c'.  */
-#define IBAUD0 020000000000
+#include <termios_internals.h>
 
+#define static_assert_equal(x,y) _Static_assert ((x) == (y), #x " != " #y)
 
 /* Set the state of FD to *TERMIOS_P.  */
 int
 __tcsetattr (int fd, int optional_actions, const struct termios *termios_p)
 {
-  struct __kernel_termios k_termios;
-  unsigned long int cmd;
+  struct termios2 k_termios;
+  unsigned long cmd;
 
-  switch (optional_actions)
-    {
-    case TCSANOW:
-      cmd = TCSETS;
-      break;
-    case TCSADRAIN:
-      cmd = TCSETSW;
-      break;
-    case TCSAFLUSH:
-      cmd = TCSETSF;
-      break;
-    default:
-      return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
-    }
+  memset (&k_termios, 0, sizeof k_termios);
 
-  k_termios.c_iflag = termios_p->c_iflag & ~IBAUD0;
+  k_termios.c_iflag = termios_p->c_iflag;
   k_termios.c_oflag = termios_p->c_oflag;
   k_termios.c_cflag = termios_p->c_cflag;
   k_termios.c_lflag = termios_p->c_lflag;
-  k_termios.c_line = termios_p->c_line;
-#if _HAVE_C_ISPEED && _HAVE_STRUCT_TERMIOS_C_ISPEED
-  k_termios.c_ispeed = termios_p->c_ispeed;
-#endif
-#if _HAVE_C_OSPEED && _HAVE_STRUCT_TERMIOS_C_OSPEED
+  k_termios.c_line  = termios_p->c_line;
+
   k_termios.c_ospeed = termios_p->c_ospeed;
-#endif
-  memcpy (&k_termios.c_cc[0], &termios_p->c_cc[0],
-         __KERNEL_NCCS * sizeof (cc_t));
+  k_termios.c_ispeed = termios_p->c_ispeed;
+
+  ___termios2_canonicalize_speeds (&k_termios);
+
+  copy_c_cc (k_termios.c_cc, _TERMIOS2_NCCS, termios_p->c_cc, NCCS);
+
+  /*
+   * Choose the proper ioctl number to invoke.
+   *
+   * Alpha got TCSETS2 late (Linux 4.20), but has the same structure
+   * format, and it only needs TCSETS2 if either it needs to use
+   * __BOTHER or split speed.  All other architectures have TCSETS2 as
+   * far back as the current glibc supports.  Calling TCSETS with
+   * __BOTHER causes unpredictable results on old Alpha kernels and
+   * could even crash them.
+   */
+  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);
+
+  cmd = (long)optional_actions - TCSANOW;
+  if (cmd > 2)
+    return INLINE_SYSCALL_ERROR_RETURN_VALUE (EINVAL);
+
+  if (__ASSUME_TERMIOS2 ||
+      k_termios.c_ospeed != k_termios.c_ispeed ||
+      cbaud (k_termios.c_cflag) == __BOTHER)
+    {
+      cmd += TCSETS2;
+    }
+  else
+    {
+      cmd += TCSETS;
+      k_termios.c_cflag &= ~CIBAUD;
+    }
 
-  return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios);
+  return INLINE_SYSCALL_CALL (ioctl, fd, cmd, &k_termios);
 }
 libc_hidden_def (__tcsetattr)
+
+#if _HAVE_STRUCT_OLD_TERMIOS && _TERMIOS_OLD_COMPAT
+
+versioned_symbol (libc, __tcsetattr, tcsetattr, GLIBC_2_42);
+
+/* Legacy version for shorter struct termios without speed fields */
+int
+attribute_compat_text_section
+__old_tcsetattr (int fd, int optional_actions, const old_termios_t *termios_p)
+{
+  struct termios new_termios;
+
+  memset (&new_termios, 0, sizeof (new_termios));
+  new_termios.c_iflag  = termios_p->c_iflag;
+  new_termios.c_oflag  = termios_p->c_oflag;
+  new_termios.c_cflag  = termios_p->c_cflag;
+  new_termios.c_lflag  = termios_p->c_lflag;
+  new_termios.c_line   = termios_p->c_line;
+  copy_c_cc(new_termios.c_cc, NCCS, termios_p->c_cc, OLD_NCCS);
+
+  return __tcsetattr (fd, optional_actions, &new_termios);
+}
+compat_symbol (libc, __old_tcsetattr, tcsetattr, GLIBC_2_0);
+
+#else
+
 weak_alias (__tcsetattr, tcsetattr)
+
+#endif
similarity index 50%
rename from sysdeps/unix/sysv/linux/mips/kernel_termios.h
rename to sysdeps/unix/sysv/linux/termios_arch.h
index fd8d35a93e6848c1f37d9f0a58ce8e341c2d194c..8dbf420c286c660dde9c040ae9cdaef06877f713 100644 (file)
@@ -1,4 +1,6 @@
-/* Copyright (C) 1997-2025 Free Software Foundation, Inc.
+/* Architectural parameters for Linux termios - generic version
+
+   Copyright (C) 1997-2025 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
+   License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#ifndef _KERNEL_TERMIOS_H
-#define _KERNEL_TERMIOS_H 1
-/* The following corresponds to the values from the Linux 2.1.24 kernel.  */
-
-#define __KERNEL_NCCS 23
-
-struct __kernel_termios
-  {
-    tcflag_t c_iflag;          /* input mode flags */
-    tcflag_t c_oflag;          /* output mode flags */
-    tcflag_t c_cflag;          /* control mode flags */
-    tcflag_t c_lflag;          /* local mode flags */
-    cc_t c_line;               /* line discipline */
-    cc_t c_cc[__KERNEL_NCCS];  /* control characters */
-  };
-
-#define _HAVE_C_ISPEED 0
-#define _HAVE_C_OSPEED 0
+#define _TERMIOS2_NCCS 19
+#define _HAVE_TERMIOS2_C_CC_BEFORE_C_LINE 0
 
-#endif /* kernel_termios.h */
+#define _HAVE_STRUCT_OLD_TERMIOS 0
diff --git a/sysdeps/unix/sysv/linux/termios_internals.h b/sysdeps/unix/sysv/linux/termios_internals.h
new file mode 100644 (file)
index 0000000..10b6732
--- /dev/null
@@ -0,0 +1,143 @@
+/* termios functions internal implementation header for Linux
+
+   Copyright (C) 1991-2025 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef TERMIOS_INTERNALS_H
+#define TERMIOS_INTERNALS_H 1
+
+#include <stddef.h>
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sysdep.h>
+#include <shlib-compat.h>
+
+#include <termios_arch.h>
+
+/* ---- Kernel interface definitions ---- */
+
+/* The the termios2 structure used in the kernel interfaces is not the
+   same as the termios structure we use in the libc.  Therefore we
+   must translate it here.  */
+
+struct termios2
+{
+  tcflag_t c_iflag;            /* input mode flags */
+  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
+  cc_t c_cc[_TERMIOS2_NCCS];   /* control characters */
+  cc_t c_line;                 /* line discipline */
+#else
+  cc_t c_line;                 /* line discipline */
+  cc_t c_cc[_TERMIOS2_NCCS];   /* control characters */
+#endif
+  speed_t c_ispeed;            /* input speed */
+  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 TCGETS* 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 ---- */
+
+/*
+ * Should old speed_t and struct termios (if applicable) compatibility
+ * functions be included?
+ */
+#define _TERMIOS_OLD_COMPAT SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_42)
+
+/*
+ * Old struct termios (without c_ispeed and c_ospeed fields) if
+ * applicable. The new struct termios *must* be binary identical up to
+ * the sizeof the old structure.
+ *
+ * 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
+
+/* ---- Internal function definitions ---- */
+
+/*
+ * Copy a set of c_cc fields of possibly different width. If the target
+ * field is longer, then fill with _POSIX_VDISABLE == -1.
+ */
+static inline void
+copy_c_cc (cc_t *to, size_t nto, const cc_t *from, size_t nfrom)
+{
+  if (nto < nfrom)
+    nfrom = nto;
+
+  to = __mempcpy (to, from, nfrom * sizeof(cc_t));
+  if (nto > nfrom)
+    memset (to, _POSIX_VDISABLE, (nto - nfrom) * sizeof(cc_t));
+}
+
+/* Extract the output and input legacy speed fields from c_cflag. */
+static inline tcflag_t
+cbaud (tcflag_t c_cflag)
+{
+  return c_cflag & CBAUD;
+}
+
+static inline tcflag_t
+cibaud (tcflag_t c_cflag)
+{
+  return cbaud (c_cflag >> IBSHIFT);
+}
+
+extern speed_t
+___cbaud_to_speed (tcflag_t c_cflag, speed_t other)
+    __attribute_const__ attribute_hidden;
+
+extern tcflag_t
+___speed_to_cbaud (speed_t speed)
+    __attribute_const__ attribute_hidden;
+
+extern void
+___termios2_canonicalize_speeds (struct termios2 *k_termios_p)
+    attribute_hidden;
+
+#endif /* TERMIOS_INTERNALS_H */
index 7ab9073e3a24f9f5c902e433beebaed9b2c2ead2..ccf6ca2c8876043d5a8b1d045ecd3da46c1dc243 100644 (file)
@@ -2748,6 +2748,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F
index e11876f6abc3754b36eabcf6f32372c35db260a9..1e3e283954d5e206745b9bd60fe31e904b1f76ab 100644 (file)
@@ -2767,6 +2767,11 @@ GLIBC_2.41 sched_getattr F
 GLIBC_2.41 sched_setattr F
 GLIBC_2.42 __inet_ntop_chk F
 GLIBC_2.42 __inet_pton_chk F
+GLIBC_2.42 cfgetispeed F
+GLIBC_2.42 cfgetospeed F
+GLIBC_2.42 cfsetispeed F
+GLIBC_2.42 cfsetospeed F
+GLIBC_2.42 cfsetspeed F
 GLIBC_2.42 pthread_gettid_np F
 GLIBC_2.42 uabs F
 GLIBC_2.42 uimaxabs F