From patchwork Wed May 14 22:13:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 112261 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C79D6385700E for ; Wed, 14 May 2025 22:20:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C79D6385700E Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2025042001 header.b=XIqG9//h X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3::136]) by sourceware.org (Postfix) with ESMTPS id 843A13856DCB for ; Wed, 14 May 2025 22:14:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 843A13856DCB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zytor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 843A13856DCB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260871; cv=none; b=t8zyGj20lz2N0AAVlwVxLB7KvwOe+eSNvrl/3VS9Xr6s35oD9zaAVOEbFLr+5ui9xmqm8dbTyesxDXL5zio+ZtzUB39jPKI8gi8qoDtpuD5ICnSJTMYhtuCJG4JaTiV7LdlTIY3l71nGNBSuUsP9EHpfxt4ZCBxkNIDszhgAC34= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260871; c=relaxed/simple; bh=6Rjw3JPrX+0pzvkJTvg5anIrrejCsHBmetvgkDBzC60=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=mexjW+qGFoe9BAgnFw3QKPP4IY38jlOrUqFktkCQ9mZL5bdIUce935K6Wsd0dLlvNJdZ6Kaj4Diq0eFrnIXJudI78DPozNRv1cMNcN1x8IaT7JyvsSCxueTBMRFGbxf7N5R7OfwwrieNB7eYFgYE0apl+PGsQ5sL1El7EBWp5f0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 843A13856DCB Received: from mail.zytor.com ([IPv6:2601:646:8081:9485:69ca:8a67:356:c4ef]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54EMEBNg3155983 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 14 May 2025 15:14:20 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54EMEBNg3155983 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747260860; bh=SAuezEZ++UtQunS0tQXarHAgOekNxJtcKirc+/3EKIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XIqG9//hCtsksrKo9QbwHHBR29GSWgy/kASBE/2KM8kVzclMWnj6FQ5bre46rsIak X9tU12U71OUW26lVFO0698ZqTJHHPAID4GOXAmmuxLv3PlPKbcJRG2RCfbEVQ61TH4 QwhgExbS8Hc6OgfXfEE0CqWOl4Dvuvssfqrhke51UXb3wirTc+vVCrvFkQ3AkcrsRS 49QfOmoy8TGgM6lh5ApYllL+OBcURuRcKwgsC7H8TsdHyqPY5TDLIlgNzHXV7+1Dcg IfQHE130I/gb7GODXevWYETNH4sxaXytDLf/Sg6m8VlmHEp84etvG49Q5m5QWrPhBU biGLLp64S7thg== From: "H. Peter Anvin" To: libc-alpha@sourceware.org Cc: "H. Peter Anvin" , Florian Weimer , Andreas Schwab , Adhemerval Zanella Netto , Samuel Thibault Subject: [PATCH v5 01/12] termios: make __tcsetattr() the internal interface Date: Wed, 14 May 2025 15:13:54 -0700 Message-ID: <20250514221405.471472-2-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250514221405.471472-1-hpa@zytor.com> References: <20250514221405.471472-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org There is a prototype for an internal __tcsetattr() function in include/termios.h, but tcsetattr without __ were still declared as the actual functions. Make this match the comment and make __tcsetattr() an internal interface. This will be required to version struct termios for Linux on MIPS and SPARC. Signed-off-by: H. Peter Anvin --- include/termios.h | 2 +- login/openpty.c | 2 +- misc/getpass.c | 4 ++-- sysdeps/unix/bsd/tcsetattr.c | 6 ++++-- sysdeps/unix/sysv/linux/tcsetattr.c | 2 +- termios/tcsetattr.c | 5 +++-- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/include/termios.h b/include/termios.h index e2c35ebbae09..a79da7a1f379 100644 --- a/include/termios.h +++ b/include/termios.h @@ -10,7 +10,7 @@ extern int __tcsetattr (int __fd, int __optional_actions, extern int __libc_tcdrain (int __fd); libc_hidden_proto (__tcgetattr) -libc_hidden_proto (tcsetattr) +libc_hidden_proto (__tcsetattr) libc_hidden_proto (cfsetispeed) libc_hidden_proto (cfsetospeed) diff --git a/login/openpty.c b/login/openpty.c index fc45add3df44..f7fd6b7384e6 100644 --- a/login/openpty.c +++ b/login/openpty.c @@ -124,7 +124,7 @@ __openpty (int *pptmx, int *pterminal, char *name, /* XXX Should we ignore errors here? */ if (termp) - tcsetattr (terminal, TCSAFLUSH, termp); + __tcsetattr (terminal, TCSAFLUSH, termp); #ifdef TIOCSWINSZ if (winp) __ioctl (terminal, TIOCSWINSZ, winp); diff --git a/misc/getpass.c b/misc/getpass.c index 4fe94537b926..a68acf483a20 100644 --- a/misc/getpass.c +++ b/misc/getpass.c @@ -83,7 +83,7 @@ getpass (const char *prompt) s = t; /* Tricky, tricky. */ t.c_lflag &= ~(ECHO|ISIG); - tty_changed = (tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &t) == 0); + tty_changed = (__tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &t) == 0); } else tty_changed = 0; @@ -110,7 +110,7 @@ getpass (const char *prompt) /* Restore the original setting. */ if (tty_changed) - (void) tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &s); + (void) __tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &s); funlockfile (out); diff --git a/sysdeps/unix/bsd/tcsetattr.c b/sysdeps/unix/bsd/tcsetattr.c index 38b5f71da27e..8693d943e7fe 100644 --- a/sysdeps/unix/bsd/tcsetattr.c +++ b/sysdeps/unix/bsd/tcsetattr.c @@ -32,7 +32,7 @@ /* Set the state of FD to *TERMIOS_P. */ int -tcsetattr (int fd, int optional_actions, const struct termios *termios_p) +__tcsetattr (int fd, int optional_actions, const struct termios *termios_p) { struct termios myt; @@ -56,4 +56,6 @@ tcsetattr (int fd, int optional_actions, const struct termios *termios_p) return __ioctl (fd, TIOCSETAF, termios_p); } } -libc_hidden_def (tcsetattr) + +libc_hidden_def (__tcsetattr) +weak_alias (__tcsetattr, tcsetattr) diff --git a/sysdeps/unix/sysv/linux/tcsetattr.c b/sysdeps/unix/sysv/linux/tcsetattr.c index 5a13ad879047..49d9d245a067 100644 --- a/sysdeps/unix/sysv/linux/tcsetattr.c +++ b/sysdeps/unix/sysv/linux/tcsetattr.c @@ -77,5 +77,5 @@ __tcsetattr (int fd, int optional_actions, const struct termios *termios_p) return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios); } +libc_hidden_def (__tcsetattr) weak_alias (__tcsetattr, tcsetattr) -libc_hidden_def (tcsetattr) diff --git a/termios/tcsetattr.c b/termios/tcsetattr.c index 30bc6d64b95d..f0756be9fec3 100644 --- a/termios/tcsetattr.c +++ b/termios/tcsetattr.c @@ -23,7 +23,7 @@ static int bad_speed (speed_t speed); /* Set the state of FD to *TERMIOS_P. */ int -tcsetattr (int fd, int optional_actions, const struct termios *termios_p) +__tcsetattr (int fd, int optional_actions, const struct termios *termios_p) { if (fd < 0) { @@ -57,7 +57,8 @@ tcsetattr (int fd, int optional_actions, const struct termios *termios_p) __set_errno (ENOSYS); return -1; } -libc_hidden_def (tcsetattr) +libc_hidden_def (__tcsetattr) +weak_alias (__tcsetattr, tcsetattr) /* Strychnine checking. */ static int From patchwork Wed May 14 22:13:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 112260 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 34F7E3856DEF for ; Wed, 14 May 2025 22:17:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34F7E3856DEF Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2025042001 header.b=Gku4D3Tq X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3::136]) by sourceware.org (Postfix) with ESMTPS id 7B972385840C for ; Wed, 14 May 2025 22:14:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7B972385840C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zytor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7B972385840C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260866; cv=none; b=LKQtDmASj4+Ngbe5m7sCM1GhKtwCCgR1t+fhygQsNkhk+fGj4BBhXrg9tpvaaOodxRyzmo+7YxS86bDaRw6JP2ynYmnzAvq6rjSeYP6Xa7Q4oZSJQNEvFvY/r4OcP5Mji9Tnei5TWkk0vXmoHVjNilbrXHBJMBfXJTX4oRZP+Kk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260866; c=relaxed/simple; bh=EtWEpx0IU2A0sajANCegcDKm+CB80QkpaklqdeebGKk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jUOXygAay4rRGu0SMRocitsq3eveowTTiIWry99rjncC9fCR9dwPQDkEELcUpvedB7xe0eXJB3rmFfer5hhCANyUoevlyaKbG5vK/pezM2A7MC2ocUnap9Dsbc2O/JE6w2QlqG0mqKNvr+uksVseW6hLhCGVsAmyGYt8O6RJyJI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B972385840C Received: from mail.zytor.com ([IPv6:2601:646:8081:9485:69ca:8a67:356:c4ef]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54EMEBNh3155983 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 14 May 2025 15:14:20 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54EMEBNh3155983 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747260861; bh=Tlo+gjA4Azaeb9qIJeMArz4ykAu0CeM+xD/iyJzFRJg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gku4D3TqwOnfFXnQuL7nS6Js/7VRcidEiN86BLWYaNwy/hLUxNIVBHKXEtpMFVYbp YbjQEwC+SRo2QFbs7UxJQejF49n9KIInjpxFUJCKD4l6B6WDtuCs+LS8p5vJovo6nM L9HW3cqqypsfvMWDZn7sDJuVFBEU8hri5hSSKuoVUxPHf8SyXK3e+ofsxElTfSigfd Qq5wZGMxmD2LNhmb+YheY0PkNB4QKTAjlmtMfl+j55Df4YH4+YOsgnrD3Kb8KsOTB9 zqMGNrGN59lhOGEnfwdM/tSoWRKhasgv1n8jvhDkCs5447zQAiqGWousJNXCGnlcgQ XdvnYTs+m/ECg== From: "H. Peter Anvin" To: libc-alpha@sourceware.org Cc: "H. Peter Anvin" , Florian Weimer , Andreas Schwab , Adhemerval Zanella Netto , Samuel Thibault Subject: [PATCH v5 02/12] io: replace local_isatty() with a proper function __isatty_nostatus() Date: Wed, 14 May 2025 15:13:55 -0700 Message-ID: <20250514221405.471472-3-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250514221405.471472-1-hpa@zytor.com> References: <20250514221405.471472-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Replace local_isatty() inlined in libio with a proper function __isatty_nostatus(). This allows simpler system-specific implementations that don't need to touch errno at all. Note: I left the prototype in include/unistd.h (the internal header file.) It didn't much make sense to me to put it in a different header (not-cancel.h), but perhaps someone can elucidate the need. Add such an implementation for Linux, with a generic fallback. Signed-off-by: H. Peter Anvin (Intel) --- include/unistd.h | 1 + io/Makefile | 1 + io/isatty_nostatus.c | 29 +++++++++++++++++++++++ libio/filedoalloc.c | 12 +--------- sysdeps/unix/sysv/linux/isatty_nostatus.c | 29 +++++++++++++++++++++++ 5 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 io/isatty_nostatus.c create mode 100644 sysdeps/unix/sysv/linux/isatty_nostatus.c diff --git a/include/unistd.h b/include/unistd.h index e241603b8131..376ab5a93688 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -152,6 +152,7 @@ libc_hidden_proto (__ttyname_r) extern __pid_t _Fork (void); libc_hidden_proto (_Fork); extern int __isatty (int __fd) attribute_hidden; +extern int __isatty_nostatus (int __fd) attribute_hidden; extern int __link (const char *__from, const char *__to); extern int __symlink (const char *__from, const char *__to); extern int __symlinkat (const char *__from, int __fd, const char *__to); diff --git a/io/Makefile b/io/Makefile index e06f3cb3dba1..edee38e233d8 100644 --- a/io/Makefile +++ b/io/Makefile @@ -92,6 +92,7 @@ routines := \ getdirname \ getwd \ isatty \ + isatty_nostatus \ lchmod \ lchown \ link \ diff --git a/io/isatty_nostatus.c b/io/isatty_nostatus.c new file mode 100644 index 000000000000..e8ee796f3ba2 --- /dev/null +++ b/io/isatty_nostatus.c @@ -0,0 +1,29 @@ +/* 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 + . */ + +#include +#include + +/* Return 1 if FD is a terminal, 0 if not, without changing errno */ +int +__isatty_nostatus (int fd) +{ + int save_errno = errno; + int res = __isatty (fd); + __set_errno (save_errno); + return res; +} diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c index 9ddd75b42923..f360d96a9b57 100644 --- a/libio/filedoalloc.c +++ b/libio/filedoalloc.c @@ -61,16 +61,6 @@ #include #include -/* Return the result of isatty, without changing errno. */ -static int -local_isatty (int fd) -{ - int save_errno = errno; - int res = __isatty (fd); - __set_errno (save_errno); - return res; -} - /* Allocate a file buffer, or switch to unbuffered I/O. Streams for TTY devices default to line buffered. */ int @@ -90,7 +80,7 @@ _IO_file_doallocate (FILE *fp) #ifdef DEV_TTY_P DEV_TTY_P (&st) || #endif - local_isatty (fp->_fileno)) + __isatty_nostatus (fp->_fileno)) fp->_flags |= _IO_LINE_BUF; } #if defined _STATBUF_ST_BLKSIZE diff --git a/sysdeps/unix/sysv/linux/isatty_nostatus.c b/sysdeps/unix/sysv/linux/isatty_nostatus.c new file mode 100644 index 000000000000..7f110be00c0a --- /dev/null +++ b/sysdeps/unix/sysv/linux/isatty_nostatus.c @@ -0,0 +1,29 @@ +/* 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 + . */ + +#include +#include +#include +#include + +/* 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; +} From patchwork Wed May 14 22:13:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 112257 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3E5FA3857356 for ; Wed, 14 May 2025 22:16:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E5FA3857356 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2025042001 header.b=SPySk1br X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3::136]) by sourceware.org (Postfix) with ESMTPS id D50CD3858427 for ; Wed, 14 May 2025 22:14:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D50CD3858427 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zytor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D50CD3858427 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260867; cv=none; b=hyLIW1qybsATFq+r076XNdMLdxmi2O/LNd7iDscL+z3RV1JMPSETSWF7We0Rgj7bLsAEniaFfL/nwOtb8o3GJa9pkuXrCQx6KmIJhwIHUrPCqO2EGRnLuhrKU7mN+ZMnIUxjdS+enBvKpO6CsrCpjDn4DjNz5CDT/4WkCkwKgSc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260867; c=relaxed/simple; bh=6veNtp5Si2JWWjp4/SmN2ALZtxTYkJhd5KpPF+2+s4Q=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Ef6bcYeZ68zI71s4+KT33jz8W7Adq837d2d5r3fQLTJi2nakHoExvA//bhtb59b4Y8RnEyXat1vhMXI9Zd8dh/thhaSfmdZ7MuSRm3zrBnNx0wAXF/l6RGhz1GXMjkpWC3TMwhICIRDfq8XMIOj/9/J+mKf8C9ruQB11yX/hj/s= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D50CD3858427 Received: from mail.zytor.com ([IPv6:2601:646:8081:9485:69ca:8a67:356:c4ef]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54EMEBNi3155983 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 14 May 2025 15:14:21 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54EMEBNi3155983 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747260861; bh=PTgTq2JxyEQSTgLUXtRakAPV55nW1fKN0S9HcnjFSJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SPySk1brbQGsqA/SlmT4s53HXuhNujmbV9JRGmtkRkU29BHBzsPEZ5rEJiXfpHMak toDy6K0KEYYu2WzryRCH8rtDxHW9mq56LTXoYT3T0vXEPG1w5pnRLh3IXnd8r9elY/ IrjIy0Qv49jKrPv4OAqoAl0HLNjgtMEuN8t8O32afEGE0VA7VIqRzEi4x3AKlTx76j tqHAtw2xf0jTJb33y6Gvl65Lvj5+XxZ1Num23iy70SnA+wfFUpKr/6sPxk7pyGu/NZ eBqkBWY5tAyZrqvPmAzY3tEnw7Owilg1kbbi3LiOEJC0KSXMVLO8jLPmFqbWeZyLIJ ehDzDLpChuDzQ== From: "H. Peter Anvin" To: libc-alpha@sourceware.org Cc: "H. Peter Anvin" , Florian Weimer , Andreas Schwab , Adhemerval Zanella Netto , Samuel Thibault Subject: [PATCH v5 03/12] linux/ioctls: use for sockios ioctls Date: Wed, 14 May 2025 15:13:56 -0700 Message-ID: <20250514221405.471472-4-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250514221405.471472-1-hpa@zytor.com> References: <20250514221405.471472-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org In the kernel, these are . The differences between and the copied data in are minor; mainly some #ifdefs, so try to use directly; it is hopefully clean enough these days to use directly. Signed-off-by: H. Peter Anvin --- sysdeps/unix/sysv/linux/bits/ioctls.h | 85 +-------------------------- 1 file changed, 1 insertion(+), 84 deletions(-) diff --git a/sysdeps/unix/sysv/linux/bits/ioctls.h b/sysdeps/unix/sysv/linux/bits/ioctls.h index 7e226e4e8f13..1ddcd4f45aea 100644 --- a/sysdeps/unix/sysv/linux/bits/ioctls.h +++ b/sysdeps/unix/sysv/linux/bits/ioctls.h @@ -22,87 +22,4 @@ /* Use the definitions from the kernel header files. */ #include -/* Routing table calls. */ -#define SIOCADDRT 0x890B /* add routing table entry */ -#define SIOCDELRT 0x890C /* delete routing table entry */ -#define SIOCRTMSG 0x890D /* call to routing system */ - -/* Socket configuration controls. */ -#define SIOCGIFNAME 0x8910 /* get iface name */ -#define SIOCSIFLINK 0x8911 /* set iface channel */ -#define SIOCGIFCONF 0x8912 /* get iface list */ -#define SIOCGIFFLAGS 0x8913 /* get flags */ -#define SIOCSIFFLAGS 0x8914 /* set flags */ -#define SIOCGIFADDR 0x8915 /* get PA address */ -#define SIOCSIFADDR 0x8916 /* set PA address */ -#define SIOCGIFDSTADDR 0x8917 /* get remote PA address */ -#define SIOCSIFDSTADDR 0x8918 /* set remote PA address */ -#define SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */ -#define SIOCSIFBRDADDR 0x891a /* set broadcast PA address */ -#define SIOCGIFNETMASK 0x891b /* get network PA mask */ -#define SIOCSIFNETMASK 0x891c /* set network PA mask */ -#define SIOCGIFMETRIC 0x891d /* get metric */ -#define SIOCSIFMETRIC 0x891e /* set metric */ -#define SIOCGIFMEM 0x891f /* get memory address (BSD) */ -#define SIOCSIFMEM 0x8920 /* set memory address (BSD) */ -#define SIOCGIFMTU 0x8921 /* get MTU size */ -#define SIOCSIFMTU 0x8922 /* set MTU size */ -#define SIOCSIFNAME 0x8923 /* set interface name */ -#define SIOCSIFHWADDR 0x8924 /* set hardware address */ -#define SIOCGIFENCAP 0x8925 /* get/set encapsulations */ -#define SIOCSIFENCAP 0x8926 -#define SIOCGIFHWADDR 0x8927 /* Get hardware address */ -#define SIOCGIFSLAVE 0x8929 /* Driver slaving support */ -#define SIOCSIFSLAVE 0x8930 -#define SIOCADDMULTI 0x8931 /* Multicast address lists */ -#define SIOCDELMULTI 0x8932 -#define SIOCGIFINDEX 0x8933 /* name -> if_index mapping */ -#define SIOGIFINDEX SIOCGIFINDEX /* misprint compatibility :-) */ -#define SIOCSIFPFLAGS 0x8934 /* set/get extended flags set */ -#define SIOCGIFPFLAGS 0x8935 -#define SIOCDIFADDR 0x8936 /* delete PA address */ -#define SIOCSIFHWBROADCAST 0x8937 /* set hardware broadcast addr */ -#define SIOCGIFCOUNT 0x8938 /* get number of devices */ - -#define SIOCGIFBR 0x8940 /* Bridging support */ -#define SIOCSIFBR 0x8941 /* Set bridging options */ - -#define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */ -#define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */ - - -/* ARP cache control calls. */ - /* 0x8950 - 0x8952 * obsolete calls, don't re-use */ -#define SIOCDARP 0x8953 /* delete ARP table entry */ -#define SIOCGARP 0x8954 /* get ARP table entry */ -#define SIOCSARP 0x8955 /* set ARP table entry */ - -/* RARP cache control calls. */ -#define SIOCDRARP 0x8960 /* delete RARP table entry */ -#define SIOCGRARP 0x8961 /* get RARP table entry */ -#define SIOCSRARP 0x8962 /* set RARP table entry */ - -/* Driver configuration calls */ - -#define SIOCGIFMAP 0x8970 /* Get device parameters */ -#define SIOCSIFMAP 0x8971 /* Set device parameters */ - -/* DLCI configuration calls */ - -#define SIOCADDDLCI 0x8980 /* Create new DLCI device */ -#define SIOCDELDLCI 0x8981 /* Delete DLCI device */ - -/* Device private ioctl calls. */ - -/* These 16 ioctls are available to devices via the do_ioctl() device - vector. Each device should include this file and redefine these - names as their own. Because these are device dependent it is a good - idea _NOT_ to issue them to random objects and hope. */ - -#define SIOCDEVPRIVATE 0x89F0 /* to 89FF */ - -/* - * These 16 ioctl calls are protocol private - */ - -#define SIOCPROTOPRIVATE 0x89E0 /* to 89EF */ +#include From patchwork Wed May 14 22:13:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 112256 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 05F7E38560A3 for ; Wed, 14 May 2025 22:16:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 05F7E38560A3 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2025042001 header.b=JikDE3bN X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3::136]) by sourceware.org (Postfix) with ESMTPS id C82683857356 for ; Wed, 14 May 2025 22:14:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C82683857356 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zytor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C82683857356 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260868; cv=none; b=RtBxfU6lYPPVAMCm2GEM2Z3SDCsSSKK/11SQe5eO6r43Tjq5AYWT5Zm5KxpsUsgpp7M5GtFi7acPW+xM/X5wiSaa1sXskECNHlYsTUWwDARkJP09HuSUpRrRBxr3CvmeTA0qCUxV7Y0O3nDAcEZMzibD4fts78Tw4C27eRxg3PQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260868; c=relaxed/simple; bh=qDB0wlB87KZDe+WRwe755/8UVTHLzRhpDeChApwWQhw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ToRjNvbfloxfzi3Iuq154iUF4R219zsjVnjvAwqC542ZSmDPt8WhUXsF21jiE5frwhTZxvOejzcXSLP2grhu1TPOQIKeTK8pOjYyWWexXQis3JmViIh+6hOwcZHcY/EFE8dDfzIjWC4uNT0JhYy4UkaITc8241UnS0ZMSX1PFck= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C82683857356 Received: from mail.zytor.com ([IPv6:2601:646:8081:9485:69ca:8a67:356:c4ef]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54EMEBNj3155983 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 14 May 2025 15:14:22 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54EMEBNj3155983 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747260862; bh=j5gwKj1AfnjPCJxBlLUEmaDTWWrM+Xzh2t8crkSh7Xk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JikDE3bNjBJuFSiBDy7w1ZU3km7yt1pAETvPHsJwePD+tAVFmEU3CL6dDJo58F6aw WgdSiWuf6Br5nnu7PyfFki9YI679aHMvM1oKN+Rz9mQAEbIDvzEZtw4K/TJCKz9kHJ DU56Cow+volyF7M5Vhw4//JbLyfxI4Sy0rncfaK5U4vwHFWorPVW81ctNpLM1krZ+C iZLhbfs8aKyO3gbmQ3XsGw08ewLgpEo05T8s8sENezwKf2Gb0x6kLBvKGg0+7H4QcZ 4h9EDR5ogXzCEUC1DmRcdVKZAYZg/Y/+U2pz85NzxkC5GDC0/SzUEMGPEpNOnRaT7y SsbGlXi0t6Tbg== From: "H. Peter Anvin" To: libc-alpha@sourceware.org Cc: "H. Peter Anvin" , Florian Weimer , Andreas Schwab , Adhemerval Zanella Netto , Samuel Thibault Subject: [PATCH v5 04/12] linux/termios/powerpc: deal with powerpc-unique ioctl emulation Date: Wed, 14 May 2025 15:13:57 -0700 Message-ID: <20250514221405.471472-5-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250514221405.471472-1-hpa@zytor.com> References: <20250514221405.471472-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The powerpc architecture, only, emulates the termios ioctls using the glibc termios structure. Export the real kernel ones as the termios2 interface; although the kernel doesn't call it termios2, it is exactly the termios2 interface, and it avoids the namespace clash between the emulated ioctls and the real kernel ioctls. Signed-off-by: H. Peter Anvin --- sysdeps/unix/sysv/linux/powerpc/bits/ioctls.h | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/powerpc/bits/ioctls.h diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/ioctls.h b/sysdeps/unix/sysv/linux/powerpc/bits/ioctls.h new file mode 100644 index 000000000000..ae6eda65d542 --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/bits/ioctls.h @@ -0,0 +1,36 @@ +/* Copyright (C) 1996-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 + . */ + +#ifndef _SYS_IOCTL_H +# error "Never use directly; include instead." +#endif + +/* Use the definitions from the kernel header files. */ +#include + +/* PowerPC quirk: on PowerPC only, ioctl() emulates the TCGETS/TCSETS* + ioctls with tcgetattr/tcsetattr using the glibc struct termios. + As struct termios2 is the same as the kernel struct termios on PowerPC, + simply consider the kernel ones as the termios2 interface, even + though the kernel doesn't call it that. */ + +#define TCGETS2 _IOR ('t', 19, struct termios2) +#define TCSETS2 _IOW ('t', 20, struct termios2) +#define TCSETSW2 _IOW ('t', 21, struct termios2) +#define TCSETSF2 _IOW ('t', 22, struct termios2) + +#include From patchwork Wed May 14 22:13:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 112267 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 65510385702B for ; Wed, 14 May 2025 22:27:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 65510385702B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2025042001 header.b=A/z6KEbf X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3::136]) by sourceware.org (Postfix) with ESMTPS id 75933385701B for ; Wed, 14 May 2025 22:14:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 75933385701B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zytor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 75933385701B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260877; cv=none; b=QHyXq9wuY8YBH0J912f0rdaA3zS4FUa00LuWvX/Cf3qz8N95Uu8xC1DQNAYRZIydEaSur41atnYMHi/L+nEvqpEYmq2dcd8VTyHzEZdSvgv+NizANqxBMpNpBe9X/z02zJCmDNCWIE6LJykt+DPR3IH9LyWGNN7qAaoBChhgHb8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260877; c=relaxed/simple; bh=i+xggZ6FhA6biua5Bgdt297gje3hCvA8PV0LgyyiFTk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=BYeMLXzn76U6T9ulVH4xjojoRRojFqUywbt2XzK4XA1rh/M1AVxH2Qw21JCJSbSjHsVxztt14E2xUrYkAqua/zfkJ0hINE0va3+xA0+OSZ139w4X1aIyICW568rqp3tU2XGtqZp+kN0K9ubCrhrX1ZL/IUNHxga2sXeLnUPYKmw= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 75933385701B Received: from mail.zytor.com ([IPv6:2601:646:8081:9485:69ca:8a67:356:c4ef]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54EMEBNk3155983 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 14 May 2025 15:14:22 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54EMEBNk3155983 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747260863; bh=fNesZP3hOS1ZZWrKoZAHh4gcX1Pla/EwFv8OozyJfUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A/z6KEbfUL4cz4sfV778a3VAYSXoYbpWwyzH+tgguh2xyrjqyMwxnAu7xvwV1RhJS U2goR8VLoJo/SrAB/l2VfbiGtR3onaqOk/skcqw9KIc1YfWuakDPqJSkwZMHxusxGB 2OPyR9b7yXX3cnDBjPdjuVW9ScDVCu3K/HDzFkBeYMB2g4FJtL5IrDMqdZpSBEui0n lVEHIstoSN+91ZihLZj6vs968YGferT5dGQuT/yQGzqwBBbn9Cvqv4ZSq1eDM2MrWO VeyZQYP9K2A0n0EZ7WelBSOd7qLsUKREDGAxTtQ3vOlO7c9ZkLpUF1J6AsFnYeaw5O APdsSwY6bvjNw== From: "H. Peter Anvin" To: libc-alpha@sourceware.org Cc: "H. Peter Anvin" , Florian Weimer , Andreas Schwab , Adhemerval Zanella Netto , Samuel Thibault Subject: [PATCH v5 05/12] linux: implement arbitrary and split speeds in termios Date: Wed, 14 May 2025 15:13:58 -0700 Message-ID: <20250514221405.471472-6-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250514221405.471472-1-hpa@zytor.com> References: <20250514221405.471472-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org 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) --- NEWS | 4 + sysdeps/unix/sysv/linux/Versions | 7 + sysdeps/unix/sysv/linux/aarch64/libc.abilist | 5 + .../sysv/linux/alpha/bits/termios-c_cflag.h | 2 + .../bits/{termios-baud.h => termios-cbaud.h} | 42 +-- .../unix/sysv/linux/alpha/kernel-features.h | 11 + .../unix/sysv/linux/alpha/kernel_termios.h | 43 --- sysdeps/unix/sysv/linux/alpha/libc.abilist | 5 + sysdeps/unix/sysv/linux/arc/libc.abilist | 5 + sysdeps/unix/sysv/linux/arm/be/libc.abilist | 5 + sysdeps/unix/sysv/linux/arm/le/libc.abilist | 5 + sysdeps/unix/sysv/linux/bits/termios-baud.h | 65 ++-- .../unix/sysv/linux/bits/termios-c_cflag.h | 4 +- sysdeps/unix/sysv/linux/bits/termios-cbaud.h | 47 +++ sysdeps/unix/sysv/linux/bits/termios-struct.h | 2 +- sysdeps/unix/sysv/linux/bits/termios.h | 50 +-- sysdeps/unix/sysv/linux/cfsetspeed.c | 58 +++ sysdeps/unix/sysv/linux/csky/libc.abilist | 5 + sysdeps/unix/sysv/linux/hppa/libc.abilist | 5 + sysdeps/unix/sysv/linux/i386/libc.abilist | 5 + .../{sparc/kernel_termios.h => isatty.c} | 36 +- sysdeps/unix/sysv/linux/isatty_nostatus.c | 9 +- sysdeps/unix/sysv/linux/kernel-features.h | 4 + sysdeps/unix/sysv/linux/kernel_termios.h | 20 +- .../sysv/linux/loongarch/lp64/libc.abilist | 5 + .../sysv/linux/m68k/coldfire/libc.abilist | 5 + .../unix/sysv/linux/m68k/m680x0/libc.abilist | 5 + .../sysv/linux/microblaze/be/libc.abilist | 5 + .../sysv/linux/microblaze/le/libc.abilist | 5 + sysdeps/unix/sysv/linux/mips/Versions | 4 + .../sysv/linux/mips/bits/termios-struct.h | 34 -- sysdeps/unix/sysv/linux/mips/kernel_termios.h | 37 -- .../sysv/linux/mips/mips32/fpu/libc.abilist | 7 + .../sysv/linux/mips/mips32/nofpu/libc.abilist | 7 + .../sysv/linux/mips/mips64/n32/libc.abilist | 7 + .../sysv/linux/mips/mips64/n64/libc.abilist | 7 + sysdeps/unix/sysv/linux/mips/old_termios.h | 12 + sysdeps/unix/sysv/linux/old_termios.h | 4 + sysdeps/unix/sysv/linux/or1k/libc.abilist | 5 + .../sysv/linux/powerpc/bits/termios-c_cflag.h | 4 +- .../bits/{termios-baud.h => termios-cbaud.h} | 42 +-- .../unix/sysv/linux/powerpc/kernel_termios.h | 53 --- .../linux/powerpc/powerpc32/fpu/libc.abilist | 5 + .../powerpc/powerpc32/nofpu/libc.abilist | 5 + .../linux/powerpc/powerpc64/be/libc.abilist | 5 + .../linux/powerpc/powerpc64/le/libc.abilist | 5 + .../unix/sysv/linux/riscv/rv32/libc.abilist | 5 + .../unix/sysv/linux/riscv/rv64/libc.abilist | 5 + .../unix/sysv/linux/s390/s390-32/libc.abilist | 5 + .../unix/sysv/linux/s390/s390-64/libc.abilist | 5 + sysdeps/unix/sysv/linux/sh/be/libc.abilist | 5 + sysdeps/unix/sysv/linux/sh/le/libc.abilist | 5 + sysdeps/unix/sysv/linux/sparc/Versions | 4 + .../bits/{termios-baud.h => termios-cbaud.h} | 39 +- .../sysv/linux/sparc/bits/termios-struct.h | 34 -- sysdeps/unix/sysv/linux/sparc/old_termios.h | 12 + .../sysv/linux/sparc/sparc32/libc.abilist | 7 + .../sysv/linux/sparc/sparc64/libc.abilist | 7 + sysdeps/unix/sysv/linux/speed.c | 348 +++++++++++++++--- sysdeps/unix/sysv/linux/tcgetattr.c | 85 ++--- sysdeps/unix/sysv/linux/tcsetattr.c | 123 ++++--- sysdeps/unix/sysv/linux/termios_internals.h | 97 +++++ .../unix/sysv/linux/x86_64/64/libc.abilist | 5 + .../unix/sysv/linux/x86_64/x32/libc.abilist | 5 + 64 files changed, 1017 insertions(+), 491 deletions(-) rename sysdeps/unix/sysv/linux/alpha/bits/{termios-baud.h => termios-cbaud.h} (58%) delete mode 100644 sysdeps/unix/sysv/linux/alpha/kernel_termios.h create mode 100644 sysdeps/unix/sysv/linux/bits/termios-cbaud.h create mode 100644 sysdeps/unix/sysv/linux/cfsetspeed.c rename sysdeps/unix/sysv/linux/{sparc/kernel_termios.h => isatty.c} (51%) delete mode 100644 sysdeps/unix/sysv/linux/mips/bits/termios-struct.h delete mode 100644 sysdeps/unix/sysv/linux/mips/kernel_termios.h create mode 100644 sysdeps/unix/sysv/linux/mips/old_termios.h create mode 100644 sysdeps/unix/sysv/linux/old_termios.h rename sysdeps/unix/sysv/linux/powerpc/bits/{termios-baud.h => termios-cbaud.h} (58%) delete mode 100644 sysdeps/unix/sysv/linux/powerpc/kernel_termios.h rename sysdeps/unix/sysv/linux/sparc/bits/{termios-baud.h => termios-cbaud.h} (57%) delete mode 100644 sysdeps/unix/sysv/linux/sparc/bits/termios-struct.h create mode 100644 sysdeps/unix/sysv/linux/sparc/old_termios.h create mode 100644 sysdeps/unix/sysv/linux/termios_internals.h diff --git a/NEWS b/NEWS index afe8076dfc9d..cc668344c122 100644 --- 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 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 diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index 55d565545ab3..b721331bf71d 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -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; diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index aa6bf483dd70..fdccf84d8f88 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/alpha/bits/termios-c_cflag.h b/sysdeps/unix/sysv/linux/alpha/bits/termios-c_cflag.h index 1f9f7f2680d1..d8308848c624 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/termios-c_cflag.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/termios-c_cflag.h @@ -36,4 +36,6 @@ #ifdef __USE_MISC # define ADDRB 04000000000 +# define CMSPAR 010000000000 /* Mark or space (stick) parity. */ +# define CRTSCTS 020000000000 /* Flow control. */ #endif diff --git a/sysdeps/unix/sysv/linux/alpha/bits/termios-baud.h b/sysdeps/unix/sysv/linux/alpha/bits/termios-cbaud.h 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 324d5d8776d3..9918921bec5e 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/termios-baud.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/termios-cbaud.h @@ -17,30 +17,30 @@ . */ #ifndef _TERMIOS_H -# error "Never include directly; use instead." +# error "Never include directly; use 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 011200000 +# 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 __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 -#define __MAX_BAUD B4000000 diff --git a/sysdeps/unix/sysv/linux/alpha/kernel-features.h b/sysdeps/unix/sysv/linux/alpha/kernel-features.h index 6eae48f13e74..83fdf91222a7 100644 --- a/sysdeps/unix/sysv/linux/alpha/kernel-features.h +++ b/sysdeps/unix/sysv/linux/alpha/kernel-features.h @@ -54,4 +54,15 @@ #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 index 6a777ddb6e77..000000000000 --- a/sysdeps/unix/sysv/linux/alpha/kernel_termios.h +++ /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 - . */ - -#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 - -#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 */ diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index d5df9656a892..1e3f2781553e 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist index c46c08da85c9..7b7717d1d146 100644 --- a/sysdeps/unix/sysv/linux/arc/libc.abilist +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist index 4df150c0f042..f64bf3f3278e 100644 --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist index be294783f685..c065fe80fcd0 100644 --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/bits/termios-baud.h b/sysdeps/unix/sysv/linux/bits/termios-baud.h index e63a3eb4182e..1e41338b5739 100644 --- a/sysdeps/unix/sysv/linux/bits/termios-baud.h +++ b/sysdeps/unix/sysv/linux/bits/termios-baud.h @@ -20,29 +20,44 @@ # error "Never include directly; use 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 diff --git a/sysdeps/unix/sysv/linux/bits/termios-c_cflag.h b/sysdeps/unix/sysv/linux/bits/termios-c_cflag.h index bbbb621d4ef0..befd25a758dd 100644 --- a/sysdeps/unix/sysv/linux/bits/termios-c_cflag.h +++ b/sysdeps/unix/sysv/linux/bits/termios-c_cflag.h @@ -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 index 000000000000..bdc702074371 --- /dev/null +++ b/sysdeps/unix/sysv/linux/bits/termios-cbaud.h @@ -0,0 +1,47 @@ +/* termios baud rate selection definitions. Linux/generic version. + Copyright (C) 2019-2023 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 + . */ + +#ifndef _TERMIOS_H +# error "Never include directly; use 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 diff --git a/sysdeps/unix/sysv/linux/bits/termios-struct.h b/sysdeps/unix/sysv/linux/bits/termios-struct.h index 4c501a54b058..d7167dfa20c8 100644 --- a/sysdeps/unix/sysv/linux/bits/termios-struct.h +++ b/sysdeps/unix/sysv/linux/bits/termios-struct.h @@ -27,7 +27,7 @@ struct termios 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_line; /* line discipline */ cc_t c_cc[NCCS]; /* control characters */ speed_t c_ispeed; /* input speed */ speed_t c_ospeed; /* output speed */ diff --git a/sysdeps/unix/sysv/linux/bits/termios.h b/sysdeps/unix/sysv/linux/bits/termios.h index 3bd1e228297c..14de3fcb5507 100644 --- a/sysdeps/unix/sysv/linux/bits/termios.h +++ b/sysdeps/unix/sysv/linux/bits/termios.h @@ -24,35 +24,41 @@ typedef unsigned char cc_t; typedef unsigned int speed_t; typedef unsigned int tcflag_t; -#include +#ifdef _TERMIOS_H +# include +#endif + #include #include #include /* 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 + +#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 + #ifdef __USE_MISC -# define EXTA B19200 -# define EXTB B38400 +# define EXTA __B19200 +# define EXTB __B38400 +# define BOTHER __BOTHER #endif -#include -#include #include #ifdef __USE_MISC @@ -74,3 +80,5 @@ typedef unsigned int tcflag_t; #include #include + +#include diff --git a/sysdeps/unix/sysv/linux/cfsetspeed.c b/sysdeps/unix/sysv/linux/cfsetspeed.c new file mode 100644 index 000000000000..f350add35444 --- /dev/null +++ b/sysdeps/unix/sysv/linux/cfsetspeed.c @@ -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 + . */ + +#include + +/* Set both the input and ouptut 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 */ diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist index f123757134c6..69ba60ea093e 100644 --- a/sysdeps/unix/sysv/linux/csky/libc.abilist +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index 2dc85b953303..dea7c09692bd 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index 1e38217ec6ad..4c05ab1c6e07 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -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/sparc/kernel_termios.h b/sysdeps/unix/sysv/linux/isatty.c similarity index 51% rename from sysdeps/unix/sysv/linux/sparc/kernel_termios.h rename to sysdeps/unix/sysv/linux/isatty.c index 401079c4e55d..8828c0df93cf 100644 --- a/sysdeps/unix/sysv/linux/sparc/kernel_termios.h +++ b/sysdeps/unix/sysv/linux/isatty.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2025 Free Software Foundation, Inc. +/* 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 @@ -15,26 +15,14 @@ License along with the GNU C Library; if not, see . */ -#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 - -#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 */ +#include + +/* 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) diff --git a/sysdeps/unix/sysv/linux/isatty_nostatus.c b/sysdeps/unix/sysv/linux/isatty_nostatus.c index 7f110be00c0a..406decba62a1 100644 --- a/sysdeps/unix/sysv/linux/isatty_nostatus.c +++ b/sysdeps/unix/sysv/linux/isatty_nostatus.c @@ -15,15 +15,12 @@ License along with the GNU C Library; if not, see . */ -#include -#include -#include -#include +#include /* 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; } diff --git a/sysdeps/unix/sysv/linux/kernel-features.h b/sysdeps/unix/sysv/linux/kernel-features.h index 86b2d3ce5125..a49a9159cfa7 100644 --- a/sysdeps/unix/sysv/linux/kernel-features.h +++ b/sysdeps/unix/sysv/linux/kernel-features.h @@ -54,6 +54,10 @@ 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 diff --git a/sysdeps/unix/sysv/linux/kernel_termios.h b/sysdeps/unix/sysv/linux/kernel_termios.h index f02a197518b5..8dbe9f2ba89f 100644 --- a/sysdeps/unix/sysv/linux/kernel_termios.h +++ b/sysdeps/unix/sysv/linux/kernel_termios.h @@ -17,21 +17,29 @@ #ifndef _KERNEL_TERMIOS_H #define _KERNEL_TERMIOS_H 1 -/* The following corresponds to the values from the Linux 2.1.20 kernel. */ +/* The following corresponds to the values from the Linux 2.6.23 kernel. */ -#define __KERNEL_NCCS 19 +#ifdef __mips__ +# define __KERNEL_NCCS 23 +#else +# define __KERNEL_NCCS 19 +#endif -struct __kernel_termios +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 defined(__alpha__) || defined(__powerpc__) + cc_t c_cc[__KERNEL_NCCS]; /* control characters */ + cc_t c_line; /* line discipline */ +#else cc_t c_line; /* line discipline */ cc_t c_cc[__KERNEL_NCCS]; /* control characters */ +#endif + speed_t c_ispeed; /* input speed */ + speed_t c_ospeed; /* output speed */ }; -#define _HAVE_C_ISPEED 0 -#define _HAVE_C_OSPEED 0 - #endif /* kernel_termios.h */ diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist index 927fc2144526..6ab4968d17ce 100644 --- a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist +++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index 74da49d9da42..e553bdc8a3b0 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index e5d678111f49..1239f0d7a029 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist index 4dbd4b60450f..943e89a45fd4 100644 --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist index c5965bb50cf5..9c303d9d9aa8 100644 --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/mips/Versions b/sysdeps/unix/sysv/linux/mips/Versions index 9ea0fa65a4ac..48f0037fe62a 100644 --- a/sysdeps/unix/sysv/linux/mips/Versions +++ b/sysdeps/unix/sysv/linux/mips/Versions @@ -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; diff --git a/sysdeps/unix/sysv/linux/mips/bits/termios-struct.h b/sysdeps/unix/sysv/linux/mips/bits/termios-struct.h deleted file mode 100644 index ef698218f3a2..000000000000 --- a/sysdeps/unix/sysv/linux/mips/bits/termios-struct.h +++ /dev/null @@ -1,34 +0,0 @@ -/* struct termios definition. Linux/mips 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 - . */ - -#ifndef _TERMIOS_H -# error "Never include directly; use instead." -#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 - }; diff --git a/sysdeps/unix/sysv/linux/mips/kernel_termios.h b/sysdeps/unix/sysv/linux/mips/kernel_termios.h deleted file mode 100644 index fd8d35a93e68..000000000000 --- a/sysdeps/unix/sysv/linux/mips/kernel_termios.h +++ /dev/null @@ -1,37 +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 - . */ - -#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 - -#endif /* kernel_termios.h */ diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index 10715e07779f..6eb6fd476b0d 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist index 3d229b9853f0..58a43bb9b3d3 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index e4cb45275b98..abab2ad80758 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index 8a32d2585dcc..2e31f6eed6b7 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/mips/old_termios.h b/sysdeps/unix/sysv/linux/mips/old_termios.h new file mode 100644 index 000000000000..4f095082e58f --- /dev/null +++ b/sysdeps/unix/sysv/linux/mips/old_termios.h @@ -0,0 +1,12 @@ +#define _HAVE_STRUCT_OLD_TERMIOS 1 + +#define OLD_NCCS 32 +typedef 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 */ + } old_termios_t; diff --git a/sysdeps/unix/sysv/linux/old_termios.h b/sysdeps/unix/sysv/linux/old_termios.h new file mode 100644 index 000000000000..8f837cc0ccfe --- /dev/null +++ b/sysdeps/unix/sysv/linux/old_termios.h @@ -0,0 +1,4 @@ +/* By default, no old termios structure */ +#define _HAVE_STRUCT_OLD_TERMIOS 0 +#define OLD_NCCS NCCS +typedef struct termios old_termios_t; diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist index 64dac95b2afd..b54c078b520c 100644 --- a/sysdeps/unix/sysv/linux/or1k/libc.abilist +++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/termios-c_cflag.h b/sysdeps/unix/sysv/linux/powerpc/bits/termios-c_cflag.h index 9ea8cfbe725e..a90d581484ef 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/termios-c_cflag.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/termios-c_cflag.h @@ -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 diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/termios-baud.h b/sysdeps/unix/sysv/linux/powerpc/bits/termios-cbaud.h 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 374d9f89498f..7bcbba441ae8 100644 --- a/sysdeps/unix/sysv/linux/powerpc/bits/termios-baud.h +++ b/sysdeps/unix/sysv/linux/powerpc/bits/termios-cbaud.h @@ -17,29 +17,29 @@ . */ #ifndef _TERMIOS_H -# error "Never include directly; use instead." +# error "Never include directly; use 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 index f6ea570ebea0..000000000000 --- a/sysdeps/unix/sysv/linux/powerpc/kernel_termios.h +++ /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 - . */ - -#ifndef _KERNEL_TERMIOS_H -#define _KERNEL_TERMIOS_H 1 - -/* We need the definition of tcflag_t, cc_t, and speed_t. */ -#include - -#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 */ diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index cc5e93c77c9d..c30e17cdfca2 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index 981499708367..f3c0c0205249 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist index 7f46295c11fd..6e1d141ca7fd 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist index f24f81bb5f33..441296c7e8ba 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist index 9330c7ab762a..bcc0ed8d6a5f 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index ea4555d39e00..d55b553c0e39 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index 3e625fa4e928..a45b8874f0a3 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index 46b4a04f6507..17483dcc4895 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist index 36a94c9210ce..cb62b6e083eb 100644 --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist index f79aba6aab3d..ee6f2d017073 100644 --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/sparc/Versions b/sysdeps/unix/sysv/linux/sparc/Versions index f127bdf0b88d..7dd61a54c447 100644 --- a/sysdeps/unix/sysv/linux/sparc/Versions +++ b/sysdeps/unix/sysv/linux/sparc/Versions @@ -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; diff --git a/sysdeps/unix/sysv/linux/sparc/bits/termios-baud.h b/sysdeps/unix/sysv/linux/sparc/bits/termios-cbaud.h 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 677db7ba116a..34eba1818449 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/termios-baud.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/termios-cbaud.h @@ -17,30 +17,29 @@ . */ #ifndef _TERMIOS_H -# error "Never include directly; use instead." +# error "Never include directly; use 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 diff --git a/sysdeps/unix/sysv/linux/sparc/bits/termios-struct.h b/sysdeps/unix/sysv/linux/sparc/bits/termios-struct.h deleted file mode 100644 index 269ca9d67583..000000000000 --- a/sysdeps/unix/sysv/linux/sparc/bits/termios-struct.h +++ /dev/null @@ -1,34 +0,0 @@ -/* struct termios definition. Linux/sparc 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 - . */ - -#ifndef _TERMIOS_H -# error "Never include directly; use instead." -#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 - }; diff --git a/sysdeps/unix/sysv/linux/sparc/old_termios.h b/sysdeps/unix/sysv/linux/sparc/old_termios.h new file mode 100644 index 000000000000..0ce5bb3416e5 --- /dev/null +++ b/sysdeps/unix/sysv/linux/sparc/old_termios.h @@ -0,0 +1,12 @@ +#define _HAVE_STRUCT_OLD_TERMIOS 1 + +#define OLD_NCCS 17 +typedef 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 */ + } old_termios_t; diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index 4a6acc08e047..943e130d3a8a 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index 931109dab18a..1017babb1d59 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/speed.c b/sysdeps/unix/sysv/linux/speed.c index 017f74177f9b..75879e681aee 100644 --- a/sysdeps/unix/sysv/linux/speed.c +++ b/sysdeps/unix/sysv/linux/speed.c @@ -16,82 +16,336 @@ License along with the GNU C Library; if not, see . */ -#include -#include -#include -#include +#include -/* 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) + +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 in 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 */ diff --git a/sysdeps/unix/sysv/linux/tcgetattr.c b/sysdeps/unix/sysv/linux/tcgetattr.c index d672e0c3b1d8..dbeae739cc31 100644 --- a/sysdeps/unix/sysv/linux/tcgetattr.c +++ b/sysdeps/unix/sysv/linux/tcgetattr.c @@ -15,66 +15,55 @@ License along with the GNU C Library; if not, see . */ -#include -#include -#include -#include -#include -#include -#include - -/* 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 +#include /* 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); + + 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, __KERNEL_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 diff --git a/sysdeps/unix/sysv/linux/tcsetattr.c b/sysdeps/unix/sysv/linux/tcsetattr.c index 49d9d245a067..28351b48295f 100644 --- a/sysdeps/unix/sysv/linux/tcsetattr.c +++ b/sysdeps/unix/sysv/linux/tcsetattr.c @@ -15,67 +15,94 @@ License along with the GNU C Library; if not, see . */ -#include -#include -#include -#include -#include -#include - -/* 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 - - -/* 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 +#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); - return INLINE_SYSCALL (ioctl, 3, fd, cmd, &k_termios); + copy_c_cc (k_termios.c_cc, __KERNEL_NCCS, termios_p->c_cc, NCCS); + + /* + * Choose the proper ioctl number to invoke. + * + * Alpha got TCSETS2 late, 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_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; + 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; + new_termios.c_ispeed = 0; + new_termios.c_ospeed = 0; + 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 diff --git a/sysdeps/unix/sysv/linux/termios_internals.h b/sysdeps/unix/sysv/linux/termios_internals.h new file mode 100644 index 000000000000..c1e213273155 --- /dev/null +++ b/sysdeps/unix/sysv/linux/termios_internals.h @@ -0,0 +1,97 @@ +#ifndef TERMIOS_INTERNALS_H +#define TERMIOS_INTERNALS_H 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* 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 + +/* + * 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. + * + * This will define _HAVE_STRUCT_OLD_TERMIOS to either 0 or 1. + */ +#include + +/* 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 + +/* + * 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 */ diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index 7ab9073e3a24..ccf6ca2c8876 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index e11876f6abc3..1e3e283954d5 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -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 From patchwork Wed May 14 22:13:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 112262 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7BB81385B51D for ; Wed, 14 May 2025 22:20:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BB81385B51D Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2025042001 header.b=KYkppdyM X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3::136]) by sourceware.org (Postfix) with ESMTPS id CD8753856DEF for ; Wed, 14 May 2025 22:14:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CD8753856DEF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zytor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org CD8753856DEF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260875; cv=none; b=Jtn1U5HoLpc0l5UbyIcILdTEvJ5jwRMDYwvBi2ztMREV/68CLAcIaywm5LNKCLfvqOjOWuKjcNmRcnDcg92vxubfII9JxHjsYdgVf/mCN7UhLchHtnR3qWZGrWp8ddHxEJ9SkFLPMDqqLYemXc3Q2YzvJgsyXoOPK3BLzFy3bAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260875; c=relaxed/simple; bh=nlzmYxkUoEwx+ovVw/GKy4bW5B3Fx55i1UNeo7prbcI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=l1P2CSZWxiu2xmqcL0DRX7KO2heDUIGuPO9U4dbIzguZh7fUNdBvKscoxWnnYHvZEFYr+MhsnGuoxOq2k8V+kkNXQ3tRY5pBFBc25WwPEpl0U/XiAFQ0oijEdUcme3OWR79lUFwp5QnyD3HQGoN3LAQnOyz4vJ2c2gF2IuUeJyY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD8753856DEF Received: from mail.zytor.com ([IPv6:2601:646:8081:9485:69ca:8a67:356:c4ef]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54EMEBNl3155983 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 14 May 2025 15:14:23 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54EMEBNl3155983 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747260863; bh=KXwP4yrPeHXhnzBEAOpVnnPPZM+3ZABCAuG9i1E/0Fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KYkppdyMMsJ4EDPXD7ADwHopJMbBBWZWK9tuDQ3s5XkMG2Jx4uVo5pjb0Uu+BXYIq 4gZEj+3EtoSHElAGeG4kMQRdYbxKbm4dSAIRK/LpsJZhL2/Y6Xuiw5SL0KWkKjAg1c ooYbpYRUBLXit31JMK9VQWSA+dlIuhDQP27art0wxEMReR7ifOIJB9wvIQ5ylgCUr/ 6LreoqVS2DuB6xC7VR4gvkObdD4EPRmOyJkkh986jgk+y7XndZsjl3Inc7h7yCMXbp VtoeDrFuiwYH//bDhKLrkdEKfDAqnImRiaEFOYiWE+qxbyBj69iCDZQNIhM0atdX3m WWXe6NKg+7n8w== From: "H. Peter Anvin" To: libc-alpha@sourceware.org Cc: "H. Peter Anvin" , Florian Weimer , Andreas Schwab , Adhemerval Zanella Netto , Samuel Thibault Subject: [PATCH v5 06/12] hurd/termios: remove USE_OLD_TTY Date: Wed, 14 May 2025 15:13:59 -0700 Message-ID: <20250514221405.471472-7-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250514221405.471472-1-hpa@zytor.com> References: <20250514221405.471472-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Hurd with USE_OLD_TTY was the only remaining platform with speed_t not containing a proper baud rate. From the looks of it, that code has long since bitrotted. Remove the vestiges of USE_OLD_TTY. Reviewed-by: Samuel Thibault Signed-off-by: H. Peter Anvin (Intel) --- sysdeps/mach/hurd/bits/ioctls.h | 31 ++----------------------------- termios/sys/ttychars.h | 4 ---- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/sysdeps/mach/hurd/bits/ioctls.h b/sysdeps/mach/hurd/bits/ioctls.h index f01316dbc603..faf1373dbf32 100644 --- a/sysdeps/mach/hurd/bits/ioctls.h +++ b/sysdeps/mach/hurd/bits/ioctls.h @@ -324,15 +324,8 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; From 4.4 . */ #ifdef __USE_MISC -#ifdef USE_OLD_TTY -# undef TIOCGETD -# define TIOCGETD _IOR('t', 0, int) /* get line discipline */ -# undef TIOCSETD -# define TIOCSETD _IOW('t', 1, int) /* set line discipline */ -#else -# define OTIOCGETD _IOR('t', 0, int) /* get line discipline */ -# define OTIOCSETD _IOW('t', 1, int) /* set line discipline */ -#endif +#define OTIOCGETD _IOR('t', 0, int) /* get line discipline */ +#define OTIOCSETD _IOW('t', 1, int) /* set line discipline */ #define TIOCHPCL _IO('t', 2) /* hang up on last close */ #define TIOCGETP _IOR('t', 8,struct sgttyb)/* get parameters -- gtty */ #define TIOCSETP _IOW('t', 9,struct sgttyb)/* set parameters -- stty */ @@ -411,26 +404,6 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; #define OTTYDISC 0 #define NETLDISC 1 #define NTTYDISC 2 - -/* From 4.4 . */ -#ifdef USE_OLD_TTY -# define B0 0 -# define B50 1 -# define B75 2 -# define B110 3 -# define B134 4 -# define B150 5 -# define B200 6 -# define B300 7 -# define B600 8 -# define B1200 9 -# define B1800 10 -# define B2400 11 -# define B4800 12 -# define B9600 13 -# define EXTA 14 -# define EXTB 15 -#endif /* USE_OLD_TTY */ #endif #endif /* bits/ioctls.h */ diff --git a/termios/sys/ttychars.h b/termios/sys/ttychars.h index 7043f60f81d2..eb1a815b60b8 100644 --- a/termios/sys/ttychars.h +++ b/termios/sys/ttychars.h @@ -54,8 +54,4 @@ struct ttychars { char tc_lnextc; /* literal next character */ }; -#ifdef __USE_OLD_TTY -#include /* to pick up character defaults */ -#endif - #endif /* sys/ttychars.h */ From patchwork Wed May 14 22:14:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 112264 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 24D023857015 for ; Wed, 14 May 2025 22:23:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24D023857015 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2025042001 header.b=gG+jzxPl X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3::136]) by sourceware.org (Postfix) with ESMTPS id C44A7385840E for ; Wed, 14 May 2025 22:14:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C44A7385840E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zytor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C44A7385840E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260874; cv=none; b=NyHlVU3G1JY5UUsLnp1F1mmX3qiqcZkOsoHFMZDvthgpP843lR/5NEdAVc/rnYNidUjX/0kNeiXDGQJe5rfLAm6PDjaNS4OAAcmyEWthryOL5er4J6ehSxKJOWzQITuCs/WFvOmptPBD5OavYaUO99+l5BnzGEg89NNgSuUBav8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260874; c=relaxed/simple; bh=vLAqZEwQPeRKRZCdPf/PdeYbdqxAANl7IRnGngLOYk8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=bBQnFm4rwFuhuy6Nb8tqhskPKWC6N8oU1+k8c82pn2cxtjj2MDpqcPzIHJMGATbm+CfFCuPkjsDsvIsI3h/yLlt8F299dAy6DyHkwMcDgf6Pqcd4UPUwLXY8T6o6nBeDaaLVh7zfuVtiEy68Ix19usye2527E8ItnY7NJSoFJEo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C44A7385840E Received: from mail.zytor.com ([IPv6:2601:646:8081:9485:69ca:8a67:356:c4ef]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54EMEBNm3155983 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 14 May 2025 15:14:24 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54EMEBNm3155983 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747260864; bh=bYkiilvYeD6GQ8hQW2YqgiUXBK0XmZ34flXSxRftHTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gG+jzxPlG6k0DlobqG1Z38Pbffy/EXq/LnN1vaMQXwG8CW4OI+jsDvebyBNxnP9hM QEIUMsI1gaXbG+Pyde4s3XeCblmxejlwa3Ki435oHIfyUaWJjHyZVH2HcjOk3bYr9/ sy/txis9YiTQ9tvMJOb2AIySMjLF03+XH5mZENGc2G8V+Hsg2niq+MrKI9bMPgE0nT 5nd2wyjvDJ9GuW05Ma81pXHANdsJNZK1NS10wYQqnhO3y/O+ruxwslC2ObtslFNoeL HGBMdXfsNQcEKFB7hsnTULOEx2qC5Ei5KZFroMxTwlZN0q1+Va+PYBfSfDOwUnDNAH Nif5VKBZ61gLQ== From: "H. Peter Anvin" To: libc-alpha@sourceware.org Cc: "H. Peter Anvin" , Florian Weimer , Andreas Schwab , Adhemerval Zanella Netto , Samuel Thibault Subject: [PATCH v5 07/12] termios: change the generic cfsetspeed() to support arbitrary speeds Date: Wed, 14 May 2025 15:14:00 -0700 Message-ID: <20250514221405.471472-8-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250514221405.471472-1-hpa@zytor.com> References: <20250514221405.471472-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The generic implementaion of cfsetspeed() had an internal table of permitted baud rates, which was enforced even on an implementation supporting arbitrary baud rates. This was to be able to *also* accept numeric constants as well as Bxxx values. This fundamentally makes no sense; not only does it go against the documented behavior of cfsetspeed() which is to take the same input as cfset[io]speed(), but it means cfsetspeed() is broken with regard to a platform supporting arbitrary speeds. With Linux converted to arbitrary baud rates, the only remaining case of non-arbitrary baud rates appears to be Hurd with USE_OLD_TTY, which one can presume being a legacy case that few if any people care about, and so simply strip out this code and make cfsetspeed() rely on cfsetospeed() to validate acceptable speed constants. If a new platform is introduced which does not have arbitrary baud rate support, using non-baud rate Bxxx constants (highly not recommended; should be abstracted at the glibc level) but such aliasing is desired, it should be supported by cfset[io]speed() as well, and belongs in the platform-specific code. Signed-off-by: H. Peter Anvin (Intel) --- termios/cfsetspeed.c | 138 ++----------------------------------------- 1 file changed, 5 insertions(+), 133 deletions(-) diff --git a/termios/cfsetspeed.c b/termios/cfsetspeed.c index 053e3945ea10..257c6387aaa0 100644 --- a/termios/cfsetspeed.c +++ b/termios/cfsetspeed.c @@ -19,143 +19,15 @@ #include #include -struct speed_struct -{ - speed_t value; - speed_t internal; -}; - -static const struct speed_struct speeds[] = - { -#ifdef B0 - { 0, B0 }, -#endif -#ifdef B50 - { 50, B50 }, -#endif -#ifdef B75 - { 75, B75 }, -#endif -#ifdef B110 - { 110, B110 }, -#endif -#ifdef B134 - { 134, B134 }, -#endif -#ifdef B150 - { 150, B150 }, -#endif -#ifdef B200 - { 200, B200 }, -#endif -#ifdef B300 - { 300, B300 }, -#endif -#ifdef B600 - { 600, B600 }, -#endif -#ifdef B1200 - { 1200, B1200 }, -#endif -#ifdef B1200 - { 1200, B1200 }, -#endif -#ifdef B1800 - { 1800, B1800 }, -#endif -#ifdef B2400 - { 2400, B2400 }, -#endif -#ifdef B4800 - { 4800, B4800 }, -#endif -#ifdef B9600 - { 9600, B9600 }, -#endif -#ifdef B19200 - { 19200, B19200 }, -#endif -#ifdef B38400 - { 38400, B38400 }, -#endif -#ifdef B57600 - { 57600, B57600 }, -#endif -#ifdef B76800 - { 76800, B76800 }, -#endif -#ifdef B115200 - { 115200, B115200 }, -#endif -#ifdef B153600 - { 153600, B153600 }, -#endif -#ifdef B230400 - { 230400, B230400 }, -#endif -#ifdef B307200 - { 307200, B307200 }, -#endif -#ifdef B460800 - { 460800, B460800 }, -#endif -#ifdef B500000 - { 500000, B500000 }, -#endif -#ifdef B576000 - { 576000, B576000 }, -#endif -#ifdef B921600 - { 921600, B921600 }, -#endif -#ifdef B1000000 - { 1000000, B1000000 }, -#endif -#ifdef B1152000 - { 1152000, B1152000 }, -#endif -#ifdef B1500000 - { 1500000, B1500000 }, -#endif -#ifdef B2000000 - { 2000000, B2000000 }, -#endif -#ifdef B2500000 - { 2500000, B2500000 }, -#endif -#ifdef B3000000 - { 3000000, B3000000 }, -#endif -#ifdef B3500000 - { 3500000, B3500000 }, -#endif -#ifdef B4000000 - { 4000000, B4000000 }, -#endif - }; - - /* Set both the input and output baud rates stored in *TERMIOS_P to SPEED. */ int cfsetspeed (struct termios *termios_p, speed_t speed) { - size_t cnt; - - for (cnt = 0; cnt < sizeof (speeds) / sizeof (speeds[0]); ++cnt) - if (speed == speeds[cnt].internal) - { - cfsetispeed (termios_p, speed); - cfsetospeed (termios_p, speed); - return 0; - } - else if (speed == speeds[cnt].value) - { - cfsetispeed (termios_p, speeds[cnt].internal); - cfsetospeed (termios_p, speeds[cnt].internal); - return 0; - } + int rv; - __set_errno (EINVAL); + rv = cfsetospeed (termios_p, speed); + if (rv) + return rv; - return -1; + return cfsetispeed (termios_p, speed); } From patchwork Wed May 14 22:14:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 112259 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B520C3856088 for ; Wed, 14 May 2025 22:17:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B520C3856088 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2025042001 header.b=D1CQ81mm X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3::136]) by sourceware.org (Postfix) with ESMTPS id E8F57385B51D for ; Wed, 14 May 2025 22:14:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E8F57385B51D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zytor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E8F57385B51D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260875; cv=none; b=tCXs/pI0DYBKx2HmBMO3QlLFqL4hgjO142VjdlMXg8+neO3b0IOAAodZLya3wUE/wgAnUeoT4DghlEqsHfDPNSCKL6rGOh0mpBC8/3x6wa4gZ3ig24MM2h/n4LqjrUbAyTXXhM5SfFsuBQAz8PCF7jwMdZVdl7d9EQlA8r7JttM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260875; c=relaxed/simple; bh=GzBhUCG2HGb8CtOWfJ9fGD1O5gPtkh+7blF6KUqH3w8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hR7zZq93FuUlAf63JAtogCErfWiKwnDrxwly2wYyVrJSn8eGK5+3EspIMqn1ExcGgJKKPwoXRZ+/+srQihsj9vMgLEugW/4vclPS75IkwNWT8SHH/GetewbaiexVyYg09K+nN8Nvhh5z4yiuRHTMt3Pg/bOIUdNe0L0x8asXvn8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8F57385B51D Received: from mail.zytor.com ([IPv6:2601:646:8081:9485:69ca:8a67:356:c4ef]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54EMEBNn3155983 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 14 May 2025 15:14:25 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54EMEBNn3155983 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747260865; bh=Yg7EPjkJdqsGG6ea/HFZQAezpGU75raEzUzJ1YdgN2A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D1CQ81mmo2LfXVzVTfGrPFgOYLxgmr0ofjrFn7J/yKA/0flVmNG5fWxk45L4wJcRW z1Qc/Y0TphINHwRkJ7q46yqfqUGrNS3wNxbUmrpQCB21xDue0venHYD4iDYbo24iFY MUnRy6MeG+Z1hHiNiHannPkHwg8R3D5J8e4XXgZ+Mo7poHyrb+RIoA1b69Fwdcxv7p RdQ80aKuICTkWrkC4u6NJzDVp5CU+oYtmvjD2qN4z1oTZDafwoiqMlguJeYuL+SQU2 EhOjmGyqIp7wM7liXd2ViQa+rmi+By6+hMs8HYFKIjVdHFlXfFAXIoZB9E6ukecWkJ IPJZ0YGID+Wqg== From: "H. Peter Anvin" To: libc-alpha@sourceware.org Cc: "H. Peter Anvin" , Florian Weimer , Andreas Schwab , Adhemerval Zanella Netto , Samuel Thibault Subject: [PATCH v5 08/12] hurd+generic/termios: make speed_t an unsigned int Date: Wed, 14 May 2025 15:14:01 -0700 Message-ID: <20250514221405.471472-9-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250514221405.471472-1-hpa@zytor.com> References: <20250514221405.471472-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org POSIX requires that speed_t is an unsigned integer type, so change the generic speed_t definition to be an unsigned int instead of a plain int. Reviewed-by: Samuel Thibault Signed-off-by: H. Peter Anvin (Intel) --- bits/termios.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bits/termios.h b/bits/termios.h index 9e3ed8ee7a08..398efa5ddd2f 100644 --- a/bits/termios.h +++ b/bits/termios.h @@ -105,7 +105,7 @@ typedef unsigned int tcflag_t; typedef unsigned char cc_t; /* Type of baud rate specifiers. */ -typedef int speed_t; +typedef unsigned int speed_t; /* Terminal control structure. */ struct termios From patchwork Wed May 14 22:14:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 112263 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6AF5638560A1 for ; Wed, 14 May 2025 22:22:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6AF5638560A1 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2025042001 header.b=gFWtwx/p X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3::136]) by sourceware.org (Postfix) with ESMTPS id 23820385702B for ; Wed, 14 May 2025 22:14:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 23820385702B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zytor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 23820385702B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260871; cv=none; b=j8CupFtE7ZBPEJy8gxjMc7lpXK23LtM7CLE7TwaP1ZEx78sCno0wxqsRONIGyHh18n3bEogcj5/qop4+1hOEND7vlEguA8pCYOD2UI4/pXFjCpi0IA62WojYQ1kNsZ2VN0X8085KD6feYPrYSI4ABtlfPYJGOgjQKjEuodnW0LU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260871; c=relaxed/simple; bh=4pc2KKHVEVdyOKgtpyLs/qXD1YbtF/IZ26LRyDMsTK8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=w37kvzmpND3XqozIyzd/P4TvqnQRWw4OuHySgQ+esDUPUcKKFEkb6WxrbOqRyFpFkEuOS/OWDKY3s1dEWMs95jdaEJ/55nbgPR1fu6wCpNc3HBZirkyBNEaIGTssYharHAJhyFNt1Zw3V3HsyVJitaBULTY9lCcgEaRbbT+rias= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23820385702B Received: from mail.zytor.com ([IPv6:2601:646:8081:9485:69ca:8a67:356:c4ef]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54EMEBNo3155983 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 14 May 2025 15:14:26 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54EMEBNo3155983 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747260866; bh=OWCiy5VYf07ch6EOGVUy0YW7oXAU6TXg6kQhwRx/2Xs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gFWtwx/p0Jb+FrLWv7Q8aRxa9NteCZ3tuTsro4T4OmNACwq0JIUH+zI+tF/1N1JSK V8MEspU2mXY1N3NrhYmJjx3VuLuOu2Raus5ZAb/txu9FCbgD6M7vs6JeJqb2JjKON9 m+VPQiHIkmIYhkeKOy1zYlDD9+H9Ovrc9WvXqIwQYJq2nGSh7D1DNVUTj4LA51Qc70 V9ZUJbLeL9KPbmYsgK/gLRiR6ioikWi4gFiW+OUpYciDvu+jzczaxAUPJOM1H56uQ6 WoGvrPCo9Y4sbKmjHhUoR3Lck3mMXFdX+WkG1Tnos/RcggZcFtaDwO31ei3/auSltZ 1JKIUOdXwgQaw== From: "H. Peter Anvin" To: libc-alpha@sourceware.org Cc: "H. Peter Anvin" , Florian Weimer , Andreas Schwab , Adhemerval Zanella Netto , Samuel Thibault Subject: [PATCH v5 09/12] termios: merge the termios baud definitions Date: Wed, 14 May 2025 15:14:02 -0700 Message-ID: <20250514221405.471472-10-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250514221405.471472-1-hpa@zytor.com> References: <20250514221405.471472-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, PROLO_LEO1, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Now all platforms unconditionally use the "sane" definitions of the termios baud constants. Unify them into a common file. Note: I have made them explicitly unsigned to avoid problems with compiler warnings for comparisons of unequal signedness or similar. These constants were historically octal on most platforms, and so unsigned by default. Add the full set of defined baud rate constants to the manual. Signed-off-by: H. Peter Anvin (Intel) --- .../sysv/linux/bits => bits}/termios-baud.h | 73 ++++++++++-------- bits/termios.h | 41 +--------- manual/terminal.texi | 74 ++++++++++++++++++- sysdeps/unix/sysv/linux/Makefile | 1 - sysdeps/unix/sysv/linux/bits/termios.h | 6 +- termios/Makefile | 4 +- 6 files changed, 118 insertions(+), 81 deletions(-) rename {sysdeps/unix/sysv/linux/bits => bits}/termios-baud.h (51%) diff --git a/sysdeps/unix/sysv/linux/bits/termios-baud.h b/bits/termios-baud.h similarity index 51% rename from sysdeps/unix/sysv/linux/bits/termios-baud.h rename to bits/termios-baud.h index 1e41338b5739..bafde1a6505c 100644 --- a/sysdeps/unix/sysv/linux/bits/termios-baud.h +++ b/bits/termios-baud.h @@ -1,4 +1,4 @@ -/* termios baud rate selection definitions. Linux/generic version. +/* termios baud rate selection definitions. Universal version for sane speed_t. Copyright (C) 2019-2025 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -20,37 +20,44 @@ # error "Never include directly; use instead." #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 +/* POSIX required baud rates */ +#define B0 0U /* Hang up or ispeed == ospeed */ +#define B50 50U +#define B75 75U +#define B110 110U +#define B134 134U /* Really 134.5 baud by POSIX spec */ +#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 B9600 9600U +#define B19200 19200U +#define B38400 38400U +#ifdef __USE_MISC +# define EXTA B19200 +# define EXTB B38400 +#endif + +/* Other baud rates, "nonstandard" but known to be used */ +#define B7200 7200U +#define B14400 14400U +#define B28800 28800U +#define B33600 33600U +#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 @@ -59,5 +66,7 @@ #define B3000000 3000000U #define B3500000 3500000U #define B4000000 4000000U +#define B5000000 5000000U +#define B10000000 10000000U #define __MAX_BAUD 4294967295U diff --git a/bits/termios.h b/bits/termios.h index 398efa5ddd2f..8f0b817dbf4c 100644 --- a/bits/termios.h +++ b/bits/termios.h @@ -20,6 +20,8 @@ # error "Never include directly; use instead." #endif +#include + /* These macros are also defined in some files (with numerically identical values), but this serves to shut up cpp's complaining. */ @@ -285,45 +287,6 @@ struct termios /* Input and output baud rates. */ speed_t __ispeed, __ospeed; -#define B0 0 /* Hang up. */ -#define B50 50 /* 50 baud. */ -#define B75 75 /* 75 baud. */ -#define B110 110 /* 110 baud. */ -#define B134 134 /* 134.5 baud. */ -#define B150 150 /* 150 baud. */ -#define B200 200 /* 200 baud. */ -#define B300 300 /* 300 baud. */ -#define B600 600 /* 600 baud. */ -#define B1200 1200 /* 1200 baud. */ -#define B1800 1800 /* 1800 baud. */ -#define B2400 2400 /* 2400 baud. */ -#define B4800 4800 /* 4800 baud. */ -#define B9600 9600 /* 9600 baud. */ -#define B7200 7200 /* 7200 baud. */ -#define B14400 14400 /* 14400 baud. */ -#define B19200 19200 /* 19200 baud. */ -#define B28800 28800 /* 28800 baud. */ -#define B38400 38400 /* 38400 baud. */ -#ifdef __USE_MISC -# define EXTA 19200 -# define EXTB 38400 -#endif -#define B57600 57600 -#define B76800 76800 -#define B115200 115200 -#define B230400 230400 -#define B460800 460800 -#define B500000 500000 -#define B576000 576000 -#define B921600 921600 -#define B1000000 1000000 -#define B1152000 1152000 -#define B1500000 1500000 -#define B2000000 2000000 -#define B2500000 2500000 -#define B3000000 3000000 -#define B3500000 3500000 -#define B4000000 4000000 }; #define _IOT_termios /* Hurd ioctl type field. */ \ diff --git a/manual/terminal.texi b/manual/terminal.texi index b437cb53221c..72d0282efdbc 100644 --- a/manual/terminal.texi +++ b/manual/terminal.texi @@ -1106,12 +1106,24 @@ the only speeds that typical serial lines can support. @comment POSIX.1 @vindex B4800 @comment termios.h +@comment GNU +@vindex B7200 +@comment termios.h @comment POSIX.1 @vindex B9600 @comment termios.h +@comment GNU +@vindex B14400 +@comment termios.h @comment POSIX.1 @vindex B19200 @comment termios.h +@comment GNU +@vindex B28800 +@comment termios.h +@comment GNU +@vindex B33600 +@comment termios.h @comment POSIX.1 @vindex B38400 @comment termios.h @@ -1119,18 +1131,72 @@ the only speeds that typical serial lines can support. @vindex B57600 @comment termios.h @comment GNU +@vindex B76800 +@comment termios.h +@comment GNU @vindex B115200 @comment termios.h @comment GNU +@vindex B153600 +@comment termios.h +@comment GNU @vindex B230400 @comment termios.h @comment GNU +@vindex B307200 +@comment termios.h +@comment GNU @vindex B460800 +@comment termios.h +@comment GNU +@vindex B500000 +@comment termios.h +@comment GNU +@vindex B576000 +@comment termios.h +@comment GNU +@vindex B614400 +@comment termios.h +@comment GNU +@vindex B921600 +@comment termios.h +@comment GNU +@vindex B1000000 +@comment termios.h +@comment GNU +@vindex B1152000 +@comment termios.h +@comment GNU +@vindex B1500000 +@comment termios.h +@comment GNU +@vindex B2000000 +@comment termios.h +@comment GNU +@vindex B2500000 +@comment termios.h +@comment GNU +@vindex B3000000 +@comment termios.h +@comment GNU +@vindex B3500000 +@comment termios.h +@comment GNU +@vindex B4000000 +@comment termios.h +@comment GNU +@vindex B5000000 +@comment termios.h +@comment GNU +@vindex B10000000 @smallexample -B0 B50 B75 B110 B134 B150 B200 -B300 B600 B1200 B1800 B2400 B4800 -B9600 B19200 B38400 B57600 B115200 -B230400 B460800 +B0 B50 B75 B110 B134 B150 B200 B300 B600 B1200 +B1800 B2400 B4800 B7200 B9600 B14400 B19200 +B28800 B33600 B38400 B57600 B76800 B115200 +B153600 B230400 B307200 B460800 B500000 +B576000 B614400 B921600 B1000000 B1152000 +B1500000 B2000000 B2500000 B3000000 +B3500000 B4000000 B5000000 B10000000 @end smallexample @vindex EXTA diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index ebcf820403ff..a14b8c1f6181 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -151,7 +151,6 @@ sysdep_headers += \ bits/struct_stat.h \ bits/struct_stat_time64_helper.h \ bits/syscall.h \ - bits/termios-baud.h \ bits/termios-c_cc.h \ bits/termios-c_cflag.h \ bits/termios-c_iflag.h \ diff --git a/sysdeps/unix/sysv/linux/bits/termios.h b/sysdeps/unix/sysv/linux/bits/termios.h index 14de3fcb5507..20746a072759 100644 --- a/sysdeps/unix/sysv/linux/bits/termios.h +++ b/sysdeps/unix/sysv/linux/bits/termios.h @@ -35,6 +35,7 @@ typedef unsigned int tcflag_t; /* c_cflag bit meaning */ #include +#ifdef __USE_MISC #define __B0 0000000 /* hang up */ #define __B50 0000001 #define __B75 0000002 @@ -53,9 +54,8 @@ typedef unsigned int tcflag_t; #define __B38400 0000017 #include -#ifdef __USE_MISC -# define EXTA __B19200 -# define EXTB __B38400 +# define __EXTA __B19200 +# define __EXTB __B38400 # define BOTHER __BOTHER #endif diff --git a/termios/Makefile b/termios/Makefile index 08075424cb8a..43235346f2db 100644 --- a/termios/Makefile +++ b/termios/Makefile @@ -22,8 +22,8 @@ subdir := termios include ../Makeconfig -headers := termios.h bits/termios.h sys/ttydefaults.h sys/termios.h \ - sys/ttychars.h +headers := termios.h bits/termios.h bits/termios-baud.h \ + sys/ttydefaults.h sys/termios.h sys/ttychars.h routines := speed cfsetspeed tcsetattr tcgetattr tcgetpgrp tcsetpgrp \ tcdrain tcflow tcflush tcsendbrk cfmakeraw tcgetsid From patchwork Wed May 14 22:14:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 112265 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 76715385AC3B for ; Wed, 14 May 2025 22:24:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76715385AC3B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2025042001 header.b=L8xPrw+5 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3::136]) by sourceware.org (Postfix) with ESMTPS id 745FF3858427 for ; Wed, 14 May 2025 22:14:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 745FF3858427 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zytor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 745FF3858427 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260875; cv=none; b=gSxzMljv2cxfOk2EA+RqB9rG1zzIZh3VENr4ZZoY6AIFAN8/TJ0h/V1H4iqLa4ZsFbm1U2jAEyts4jL1edg3YXw5riXP/5Rf6kWHP8LkKcGCr2N9y6XnZYtEtDEOjWQOdEr+1e13PqTaT1Hm7Z/Zkaj49ohRBHqeyTSMr6/thGM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260875; c=relaxed/simple; bh=c5w93hpGLVWthk6GT4mQ9NpTDM4VSxwOiG9ynsYmv6A=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=gm4Q7CP6yl14lLKXrp5E8EeZyRE1AsVjwW4TcnvtRX8TT0N+1AddImBYwZbm7/VeRb9gNi8fY60Skwct6y43MYOuoWJcBxb1pxYaU9/8pxDMWxuhNIFIld/jTw3+NKX2Sesuolsh/H27o5NaheADAtj8cM2/4wKrnA1cqm0syzk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 745FF3858427 Received: from mail.zytor.com ([IPv6:2601:646:8081:9485:69ca:8a67:356:c4ef]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54EMEBNp3155983 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 14 May 2025 15:14:26 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54EMEBNp3155983 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747260867; bh=AKhHZwJt5015LVmt1tZ8fnPurKLugLYywm7gejEU6yM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L8xPrw+5PsiAZGcime/4HXUrxCiax5GxFl89uWlUCWm7cAouJww2Rk6SiXFeAtujH xpwm63vmdPUN72FvHjHlkLU61qN1TUQYhx/NtfIU1dTiVKneZ3rD5R49HM9N/Nf8il E1GRlVrvNN9oJN+FtPNLcQHgFN6pN84uEp/DVXjG2tyzQ7h4a05b/zyd2HElbDvAc9 P+nNAko6e+klH/Gtxt87oN+lM4beAxhn2pZbRVx7IoQ9G3NaCu8ftc5fX2etbryPwn e+DKnYFacJBnmp7BAoTkBQ56T+r/gZDA0hrxT5G1uPBDMD8QUO/Ha0dhHfPaXXgyw8 CJ/PC6cZ0cfdw== From: "H. Peter Anvin" To: libc-alpha@sourceware.org Cc: "H. Peter Anvin" , Florian Weimer , Andreas Schwab , Adhemerval Zanella Netto , Samuel Thibault Subject: [PATCH v5 10/12] termios: add new baud_t interface, defined to be explicitly numeric Date: Wed, 14 May 2025 15:14:03 -0700 Message-ID: <20250514221405.471472-11-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250514221405.471472-1-hpa@zytor.com> References: <20250514221405.471472-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Add an explicitly numeric interface for baudrate setting. For glibc, this only announces what is a fair accompli, but this is a plausible way forward for standardization, and may be possible to infill on non-compliant systems. The POSIX committee has stated: [https://www.austingroupbugs.net/view.php?id=1916#c7135] A future version of this standard is expected to add at least the following symbolic constants for use as values of objects of type speed_t: B57600, B115200, B230400, B460800, and B921600. Implementations are encouraged to propose additional interfaces which will make it possible to set and query a wider range of speeds than just those enumerated by the constants beginning with B. If a set of common interfaces emerges between several implementations, a future version of this standard will likely add those interfaces. This is exactly that interface. The use of the term "baud" is due to the need to have a term contrasting "speed", and it is already well established as a legacy term -- including in the names of the legacy Bxxx constants. Futhermore, it *is* valid from the point of view that the termios interface fundamentally emulates an RS-232 serial port as far as the application software is concerned. Signed-off-by: H. Peter Anvin (Intel) --- include/termios.h | 25 +++++- manual/terminal.texi | 87 ++++++++++++++++--- sysdeps/mach/hurd/i386/libc.abilist | 5 ++ sysdeps/mach/hurd/x86_64/libc.abilist | 5 ++ sysdeps/unix/sysv/linux/aarch64/libc.abilist | 5 ++ sysdeps/unix/sysv/linux/alpha/libc.abilist | 5 ++ sysdeps/unix/sysv/linux/arc/libc.abilist | 5 ++ sysdeps/unix/sysv/linux/arm/be/libc.abilist | 5 ++ sysdeps/unix/sysv/linux/arm/le/libc.abilist | 5 ++ sysdeps/unix/sysv/linux/cfsetspeed.c | 1 + sysdeps/unix/sysv/linux/csky/libc.abilist | 5 ++ sysdeps/unix/sysv/linux/hppa/libc.abilist | 5 ++ sysdeps/unix/sysv/linux/i386/libc.abilist | 5 ++ .../sysv/linux/loongarch/lp64/libc.abilist | 5 ++ .../sysv/linux/m68k/coldfire/libc.abilist | 5 ++ .../unix/sysv/linux/m68k/m680x0/libc.abilist | 5 ++ .../sysv/linux/microblaze/be/libc.abilist | 5 ++ .../sysv/linux/microblaze/le/libc.abilist | 5 ++ .../sysv/linux/mips/mips32/fpu/libc.abilist | 5 ++ .../sysv/linux/mips/mips32/nofpu/libc.abilist | 5 ++ .../sysv/linux/mips/mips64/n32/libc.abilist | 5 ++ .../sysv/linux/mips/mips64/n64/libc.abilist | 5 ++ sysdeps/unix/sysv/linux/or1k/libc.abilist | 5 ++ .../linux/powerpc/powerpc32/fpu/libc.abilist | 5 ++ .../powerpc/powerpc32/nofpu/libc.abilist | 5 ++ .../linux/powerpc/powerpc64/be/libc.abilist | 5 ++ .../linux/powerpc/powerpc64/le/libc.abilist | 5 ++ .../unix/sysv/linux/riscv/rv32/libc.abilist | 5 ++ .../unix/sysv/linux/riscv/rv64/libc.abilist | 5 ++ .../unix/sysv/linux/s390/s390-32/libc.abilist | 5 ++ .../unix/sysv/linux/s390/s390-64/libc.abilist | 5 ++ sysdeps/unix/sysv/linux/sh/be/libc.abilist | 5 ++ sysdeps/unix/sysv/linux/sh/le/libc.abilist | 5 ++ .../sysv/linux/sparc/sparc32/libc.abilist | 5 ++ .../sysv/linux/sparc/sparc64/libc.abilist | 5 ++ sysdeps/unix/sysv/linux/speed.c | 4 + .../unix/sysv/linux/x86_64/64/libc.abilist | 5 ++ .../unix/sysv/linux/x86_64/x32/libc.abilist | 5 ++ termios/Makefile | 3 +- termios/Versions | 4 + termios/baud.c | 56 ++++++++++++ termios/cfsetbaud.c | 29 +++++++ termios/cfsetspeed.c | 8 +- termios/speed.c | 18 ++-- termios/termios.h | 19 +++- 45 files changed, 397 insertions(+), 27 deletions(-) create mode 100644 termios/baud.c create mode 100644 termios/cfsetbaud.c diff --git a/include/termios.h b/include/termios.h index a79da7a1f379..d46608278fec 100644 --- a/include/termios.h +++ b/include/termios.h @@ -2,7 +2,18 @@ #include #ifndef _ISOMAC -/* Now define the internal interfaces. */ +extern speed_t __cfgetospeed (const struct termios *__termios_p); +extern speed_t __cfgetispeed (const struct termios *__termios_p); +extern int __cfsetospeed (struct termios *__termios_p, speed_t __speed); +extern int __cfsetispeed (struct termios *__termios_p, speed_t __speed); +extern int __cfsetspeed (struct termios *__termios_p, speed_t __speed); + +extern baud_t __cfgetobaud (const struct termios *__termios_p); +extern baud_t __cfgetibaud (const struct termios *__termios_p); +extern int __cfsetobaud (struct termios *__termios_p, baud_t __baud); +extern int __cfsetibaud (struct termios *__termios_p, baud_t __baud); +extern int __cfsetbaud (struct termios *__termios_p, baud_t __baud); + extern int __tcgetattr (int __fd, struct termios *__termios_p); extern int __tcsetattr (int __fd, int __optional_actions, const struct termios *__termios_p); @@ -11,8 +22,16 @@ extern int __libc_tcdrain (int __fd); libc_hidden_proto (__tcgetattr) libc_hidden_proto (__tcsetattr) -libc_hidden_proto (cfsetispeed) -libc_hidden_proto (cfsetospeed) +libc_hidden_proto (__cfgetispeed) +libc_hidden_proto (__cfgetospeed) +libc_hidden_proto (__cfsetispeed) +libc_hidden_proto (__cfsetospeed) +libc_hidden_proto (__cfsetspeed) +libc_hidden_proto (__cfgetibaud) +libc_hidden_proto (__cfgetobaud) +libc_hidden_proto (__cfsetibaud) +libc_hidden_proto (__cfsetobaud) +libc_hidden_proto (__cfsetbaud) #endif #endif diff --git a/manual/terminal.texi b/manual/terminal.texi index 72d0282efdbc..fec239a8fb87 100644 --- a/manual/terminal.texi +++ b/manual/terminal.texi @@ -771,11 +771,11 @@ If this bit is set, it says to ignore the control modes and line speed values entirely. This is only meaningful in a call to @code{tcsetattr}. The @code{c_cflag} member and the line speed values returned by -@code{cfgetispeed} and @code{cfgetospeed} will be unaffected by the -call. @code{CIGNORE} is useful if you want to set all the software -modes in the other members, but leave the hardware details in -@code{c_cflag} unchanged. (This is how the @code{TCSASOFT} flag to -@code{tcsettattr} works.) +@code{cfgetispeed}, @code{cfgetospeed}, @code{cfgetibaud} and +@code{cfsetibaud} will be unaffected by the call. @code{CIGNORE} is +useful if you want to set all the software modes in the other members, +but leave the hardware details in @code{c_cflag} unchanged. (This is +how the @code{TCSASOFT} flag to @code{tcsettattr} works.) This bit is never set in the structure filled in by @code{tcgetattr}. @end deftypevr @@ -1047,14 +1047,15 @@ The @code{speed_t} type is an unsigned integer data type used to represent line speeds. @end deftp -The functions @code{cfsetospeed} and @code{cfsetispeed} report errors -only for speed values that the system simply cannot handle. If you -specify a speed value that is basically acceptable, then those functions -will succeed. But they do not check that a particular hardware device -can actually support the specified speeds---in fact, they don't know -which device you plan to set the speed for. If you use @code{tcsetattr} -to set the speed of a particular device to a value that it cannot -handle, @code{tcsetattr} returns @math{-1}. +@deftypefun speed_t cfgetospeed (const struct termios *@var{termios-p}) +@standards{POSIX.1, termios.h} +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +@c Direct access to a single termios field, except on Linux, where +@c multiple accesses may take place. No worries either way, callers +@c must ensure mutual exclusion on such non-opaque types. +This function returns the output line speed stored in the structure +@code{*@var{termios-p}}. +@end deftypefun @strong{Portability note:} In @theglibc{}, the functions above accept speeds measured in bits per second as input, and return speed @@ -1205,6 +1206,66 @@ BSD defines two additional speed symbols as aliases: @code{EXTA} is an alias for @code{B19200} and @code{EXTB} is an alias for @code{B38400}. These aliases are obsolete. +@deftypefun baud_t cfgetibaud (const struct termios *@var{termios-p}) +@standards{GNU, termios.h} +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +This function returns the input line baud rate stored in the structure +@code{*@var{termios-p}}. +@end deftypefun + +@deftypefun int cfsetobaud (struct termios *@var{termios-p}, baud_t @var{baud}) +@standards{GNU, termios.h} +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +This function stores @var{baud} in @code{*@var{termios-p}} as the output +baud rate. The normal return value is @math{0}; a value of @math{-1} +indicates an error. If @var{baud} is not a valid baud rate, @code{cfsetobaud} +returns @math{-1}. +@end deftypefun + +@deftypefun int cfsetibaud (struct termios *@var{termios-p}, baud_t @var{baud}) +@standards{GNU, termios.h} +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +This function stores @var{baud} in @code{*@var{termios-p}} as the input +baud rate. The normal return value is @math{0}; a value of @math{-1} +indicates an error. If @var{baud} is not a valid baud rate, @code{cfsetobaud} +returns @math{-1}. +@end deftypefun + +@deftypefun int cfsetbaud (struct termios *@var{termios-p}, baud_t @var{baud}) +@standards{GNU, termios.h} +@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}} +@c There's no guarantee that the two calls are atomic, but since this is +@c not an opaque type, callers ought to ensure mutual exclusion to the +@c termios object. + +@c cfsetbaud ok +@c cfsetibaud ok +@c cfsetobaud ok +This function stores @var{baud} in @code{*@var{termios-p}} as both the +input and output baud rates. The normal return value is @math{0}; a value +of @math{-1} indicates an error. If @var{baud} is not a valid baud rate, +@code{cfsetbaud} returns @math{-1}. +@end deftypefun + +@deftp {Data Type} baud_t +@standards{GNU} +The @code{baud_t} type is an unsigned integer data type used to +represent line baud rates. It will always represent the actual numeric +value representing the baud rate, unlike @code{speed_t}. In @theglibc{} +this is the same type as @code{speed_t}. +@end deftp + +The functions @code{cfsetospeed}, @code{cfsetispeed}, @code{cfsetobaud} +and @code{cfsetibaud} report errors only for speed values that the +system simply cannot handle. If you specify a speed value that is +basically acceptable, then those functions will succeed. But they do +not check that a particular hardware device can actually support the +specified speeds---in fact, they don't know which device you plan to set +the speed for. If you use @code{tcsetattr} to set the speed of a +particular device to a value that it cannot handle, either @code{tcsetattr} +returns @math{-1}, or the value is adjusted to the closest supported +value, depending on the policy of the kernel driver. + @node Special Characters @subsection Special Characters diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index 3e183f5c02ea..564d51c6f9b5 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -2586,6 +2586,11 @@ GLIBC_2.41 pthread_mutexattr_settype F GLIBC_2.41 pthread_sigmask F GLIBC_2.42 __inet_ntop_chk F GLIBC_2.42 __inet_pton_chk F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 pthread_barrier_destroy F GLIBC_2.42 pthread_barrier_init F GLIBC_2.42 pthread_barrier_wait F diff --git a/sysdeps/mach/hurd/x86_64/libc.abilist b/sysdeps/mach/hurd/x86_64/libc.abilist index 688ee26f4b25..a5e31ad4a021 100644 --- a/sysdeps/mach/hurd/x86_64/libc.abilist +++ b/sysdeps/mach/hurd/x86_64/libc.abilist @@ -2269,6 +2269,11 @@ GLIBC_2.41 pthread_mutexattr_settype F GLIBC_2.41 pthread_sigmask F GLIBC_2.42 __inet_ntop_chk F GLIBC_2.42 __inet_pton_chk F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 pthread_barrier_destroy F GLIBC_2.42 pthread_barrier_init F GLIBC_2.42 pthread_barrier_wait F diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index fdccf84d8f88..a22e65143209 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2752,9 +2752,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index 1e3f2781553e..4b5736a3b6d3 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -3099,9 +3099,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist index 7b7717d1d146..b8a44784bdc9 100644 --- a/sysdeps/unix/sysv/linux/arc/libc.abilist +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist @@ -2513,9 +2513,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist index f64bf3f3278e..959e44672f2a 100644 --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist @@ -2805,9 +2805,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist index c065fe80fcd0..a930d1a52bbf 100644 --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist @@ -2802,9 +2802,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/cfsetspeed.c b/sysdeps/unix/sysv/linux/cfsetspeed.c index f350add35444..a4cab208ddf2 100644 --- a/sysdeps/unix/sysv/linux/cfsetspeed.c +++ b/sysdeps/unix/sysv/linux/cfsetspeed.c @@ -31,6 +31,7 @@ __cfsetspeed (struct termios *termios_p, speed_t speed) return 0; } +libc_hidden_def (__cfsetspeed) versioned_symbol (libc, __cfsetspeed, cfsetspeed, GLIBC_2_42); #if _TERMIOS_OLD_COMPAT diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist index 69ba60ea093e..6325fc12c4b4 100644 --- a/sysdeps/unix/sysv/linux/csky/libc.abilist +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist @@ -2789,9 +2789,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index dea7c09692bd..86b3fbdeec14 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -2826,9 +2826,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index 4c05ab1c6e07..6555592d86d9 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -3009,9 +3009,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist index 6ab4968d17ce..a6cab9612a4c 100644 --- a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist +++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist @@ -2273,9 +2273,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index e553bdc8a3b0..7b7b72aa50f8 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -2785,9 +2785,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index 1239f0d7a029..df398e43c62d 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -2952,9 +2952,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist index 943e89a45fd4..ca8df6f4b0c1 100644 --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist @@ -2838,9 +2838,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist index 9c303d9d9aa8..950815484752 100644 --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist @@ -2835,9 +2835,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index 6eb6fd476b0d..4d51cc428f15 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -2913,9 +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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist index 58a43bb9b3d3..7f90fadc76ec 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -2911,9 +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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index abab2ad80758..fc366d1bd0de 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -2919,9 +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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index 2e31f6eed6b7..debd5c37c9af 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -2821,9 +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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist index b54c078b520c..b62d59f1afe9 100644 --- a/sysdeps/unix/sysv/linux/or1k/libc.abilist +++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist @@ -2263,9 +2263,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index c30e17cdfca2..883e66f3ae6a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -3142,9 +3142,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index f3c0c0205249..84cd9e0e18c7 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -3187,9 +3187,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist index 6e1d141ca7fd..8832568ab3bf 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist @@ -2896,9 +2896,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist index 441296c7e8ba..b6ff8016e4b3 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist @@ -2972,9 +2972,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist index bcc0ed8d6a5f..1771a2370c5a 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist @@ -2516,9 +2516,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index d55b553c0e39..4b48352fd99b 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -2716,9 +2716,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index a45b8874f0a3..f0decc787bab 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -3140,9 +3140,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index 17483dcc4895..da8a2bfb74aa 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -2933,9 +2933,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist index cb62b6e083eb..fb303418946b 100644 --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist @@ -2832,9 +2832,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist index ee6f2d017073..d71667343278 100644 --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist @@ -2829,9 +2829,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index 943e130d3a8a..6deedf216dbe 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -3161,9 +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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index 1017babb1d59..1ce22bf036b7 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -2797,9 +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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/speed.c b/sysdeps/unix/sysv/linux/speed.c index 75879e681aee..fcada7f63270 100644 --- a/sysdeps/unix/sysv/linux/speed.c +++ b/sysdeps/unix/sysv/linux/speed.c @@ -252,6 +252,7 @@ __cfgetospeed (const struct termios *termios_p) { return termios_p->c_ospeed; } +libc_hidden_def (__cfgetospeed) versioned_symbol (libc, __cfgetospeed, cfgetospeed, GLIBC_2_42); /* Return the input baud rate stored in *TERMIOS_P. */ @@ -260,6 +261,7 @@ __cfgetispeed (const struct termios *termios_p) { return termios_p->c_ispeed; } +libc_hidden_def (__cfgetispeed) versioned_symbol (libc, __cfgetispeed, cfgetispeed, GLIBC_2_42); /* Set the output baud rate stored in *TERMIOS_P to SPEED. */ @@ -274,6 +276,7 @@ __cfsetospeed (struct termios *termios_p, speed_t speed) return 0; } +libc_hidden_def (__cfsetospeed) versioned_symbol (libc, __cfsetospeed, cfsetospeed, GLIBC_2_42); /* Set the input baud rate stored in *TERMIOS_P to SPEED. */ @@ -288,6 +291,7 @@ __cfsetispeed (struct termios *termios_p, speed_t speed) return 0; } +libc_hidden_def (__cfsetispeed) versioned_symbol (libc, __cfsetispeed, cfsetispeed, GLIBC_2_42); #if _TERMIOS_OLD_COMPAT diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index ccf6ca2c8876..564877250b25 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -2748,9 +2748,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index 1e3e283954d5..25a39d094342 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2767,9 +2767,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 cfgetibaud F GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfgetobaud F GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfsetbaud F +GLIBC_2.42 cfsetibaud F GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetobaud F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 pthread_gettid_np F diff --git a/termios/Makefile b/termios/Makefile index 43235346f2db..7dc3830ab6ef 100644 --- a/termios/Makefile +++ b/termios/Makefile @@ -26,7 +26,8 @@ headers := termios.h bits/termios.h bits/termios-baud.h \ sys/ttydefaults.h sys/termios.h sys/ttychars.h routines := speed cfsetspeed tcsetattr tcgetattr tcgetpgrp tcsetpgrp \ - tcdrain tcflow tcflush tcsendbrk cfmakeraw tcgetsid + tcdrain tcflow tcflush tcsendbrk cfmakeraw tcgetsid \ + baud cfsetbaud include ../Rules diff --git a/termios/Versions b/termios/Versions index 711ed0334b52..a5eec8325753 100644 --- a/termios/Versions +++ b/termios/Versions @@ -11,4 +11,8 @@ libc { # t* tcgetsid; } + GLIBC_2.42 { + # cf*baud + cfgetibaud; cfgetobaud; cfsetibaud; cfsetobaud; cfsetbaud; + } } diff --git a/termios/baud.c b/termios/baud.c new file mode 100644 index 000000000000..27c06e937fdb --- /dev/null +++ b/termios/baud.c @@ -0,0 +1,56 @@ +/* `struct termios' speed frobnication functions, baud rate wrappers. + Any platform which doesn't have Bxxx == xxx for all baud rate + constants will need to override this file. + + 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 + . */ + +#include +#include +#include + +baud_t +__cfgetobaud (const struct termios *termios_p) +{ + return __cfgetospeed (termios_p); +} +libc_hidden_def (__cfgetobaud) +weak_alias (__cfgetobaud, cfgetobaud) + +baud_t +__cfgetibaud (const struct termios *termios_p) +{ + return __cfgetispeed (termios_p); +} +libc_hidden_def (__cfgetibaud) +weak_alias (__cfgetibaud, cfgetibaud) + +int +__cfsetobaud (struct termios *termios_p, baud_t baud) +{ + return __cfsetospeed (termios_p, baud); +} +libc_hidden_def (__cfsetobaud) +weak_alias (__cfsetobaud, cfsetobaud) + +int +__cfsetibaud (struct termios *termios_p, baud_t baud) +{ + return __cfsetispeed (termios_p, baud); +} +libc_hidden_def (__cfsetibaud) +weak_alias (__cfsetibaud, cfsetibaud) diff --git a/termios/cfsetbaud.c b/termios/cfsetbaud.c new file mode 100644 index 000000000000..b76b51e4dd77 --- /dev/null +++ b/termios/cfsetbaud.c @@ -0,0 +1,29 @@ +/* Copyright (C) 1992-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 + . */ + +#include +#include +#include + +/* Set both the input and output baud rates stored in *TERMIOS_P to BAUD. */ +int +__cfsetbaud (struct termios *termios_p, baud_t baud) +{ + return __cfsetspeed (termios_p, baud); +} +libc_hidden_def (__cfsetbaud) +weak_alias (__cfsetbaud, cfsetbaud) diff --git a/termios/cfsetspeed.c b/termios/cfsetspeed.c index 257c6387aaa0..a68e63a9a0c3 100644 --- a/termios/cfsetspeed.c +++ b/termios/cfsetspeed.c @@ -21,13 +21,15 @@ /* Set both the input and output baud rates stored in *TERMIOS_P to SPEED. */ int -cfsetspeed (struct termios *termios_p, speed_t speed) +__cfsetspeed (struct termios *termios_p, speed_t speed) { int rv; - rv = cfsetospeed (termios_p, speed); + rv = __cfsetospeed (termios_p, speed); if (rv) return rv; - return cfsetispeed (termios_p, speed); + return __cfsetispeed (termios_p, speed); } +libc_hidden_def (__cfsetspeed) +weak_alias (__cfsetspeed, cfsetspeed) diff --git a/termios/speed.c b/termios/speed.c index d65bf03567f3..5030621518fa 100644 --- a/termios/speed.c +++ b/termios/speed.c @@ -22,21 +22,25 @@ /* 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->__ospeed; } +libc_hidden_def (__cfgetospeed) +weak_alias (__cfgetospeed, cfgetospeed) /* 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->__ispeed; } +libc_hidden_def (__cfgetispeed) +weak_alias (__cfgetispeed, cfgetispeed) /* 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 (termios_p == NULL) { @@ -47,11 +51,12 @@ cfsetospeed (struct termios *termios_p, speed_t speed) termios_p->__ospeed = speed; return 0; } -libc_hidden_def (cfsetospeed) +libc_hidden_def (__cfsetospeed) +weak_alias (__cfsetospeed, cfsetospeed) /* Set the input baud rate stored in *TERMIOS_P to SPEED. */ int -cfsetispeed (struct termios *termios_p, speed_t speed) +__cfsetispeed (struct termios *termios_p, speed_t speed) { if (termios_p == NULL) { @@ -62,4 +67,5 @@ cfsetispeed (struct termios *termios_p, speed_t speed) termios_p->__ispeed = speed; return 0; } -libc_hidden_def (cfsetispeed) +libc_hidden_def (__cfsetispeed) +weak_alias (__cfsetispeed, cfsetispeed) diff --git a/termios/termios.h b/termios/termios.h index 1755c505272f..788c98240596 100644 --- a/termios/termios.h +++ b/termios/termios.h @@ -59,8 +59,25 @@ extern int cfsetispeed (struct termios *__termios_p, speed_t __speed) __THROW; #ifdef __USE_MISC /* Set both the input and output baud rates in *TERMIOS_OP to SPEED. */ extern int cfsetspeed (struct termios *__termios_p, speed_t __speed) __THROW; -#endif +/* Interfaces that are explicitly numeric representations of baud rates */ +typedef speed_t baud_t; + +/* Return the output baud rate stored in *TERMIOS_P. */ +extern baud_t cfgetobaud (const struct termios *__termios_p) __THROW; + +/* Return the input baud rate stored in *TERMIOS_P. */ +extern baud_t cfgetibaud (const struct termios *__termios_p) __THROW; + +/* Set the output baud rate stored in *TERMIOS_P to BAUD. */ +extern int cfsetobaud (struct termios *__termios_p, baud_t __baud) __THROW; + +/* Set the input baud rate stored in *TERMIOS_P to BAUD. */ +extern int cfsetibaud (struct termios *__termios_p, baud_t __baud) __THROW; + +/* Set both the input and output baud rates in *TERMIOS_OP to BAUD. */ +extern int cfsetbaud (struct termios *__termios_p, baud_t __baud) __THROW; +#endif /* Put the state of FD into *TERMIOS_P. */ extern int tcgetattr (int __fd, struct termios *__termios_p) __THROW; From patchwork Wed May 14 22:14:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 112266 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2B5FB385701B for ; Wed, 14 May 2025 22:26:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B5FB385701B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2025042001 header.b=enssmvKV X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3::136]) by sourceware.org (Postfix) with ESMTPS id 561843857015 for ; Wed, 14 May 2025 22:14:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 561843857015 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zytor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 561843857015 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260876; cv=none; b=N7gBtQyE1ofKLnvPn3fq+LPB/AiHN5Ai+IwxqunvB6SU25OnMe+jFIurDh3Cm8e+eAWUqAMidyK+GWDasoEqEKLECMPEiXKRftZl6AWtXAiI5chb8Z76Z088pYQ9gaX3INftpmisW5jHGsWXzCwWyM2EV/q0vFFQftZK4HgNDUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260876; c=relaxed/simple; bh=SqM9wOge8gw+AnqB4kkRiNnOrqqYtgPUQMyVEcee5HI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=e9SkxVKQAZaXA02FvnzsP9VbwgYsv3dKKjYu3+Lye1HOj2ph7Wl8Wex2FtNp3qJvYa+FZxtdhwWzZON88865yjjDOMPs6BPhNtjJ0oj6Gq8SWPuKkxtucSuYhK828f45hkP8h7DUNqhSGNg/o9CVOUJBfss7hczv0EoJ5bsQVH0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 561843857015 Received: from mail.zytor.com ([IPv6:2601:646:8081:9485:69ca:8a67:356:c4ef]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54EMEBNq3155983 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 14 May 2025 15:14:27 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54EMEBNq3155983 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747260867; bh=S2kDrgVNH3X+K8NEe8L1SuGSFg1hyNjXdMu0fpAjGvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=enssmvKVwOzWn3B/Asg3t6gP9pYc8WzTQxFbrxOzy03cprh/fLC8O51cZYVjrbe0V lMWmP0n6YqsQiFuZcnU0f652tEE6WJSh8n2c1IKPVIU58lbHo/db3teHIMNySIEp+M jkrmKgGweHEtd5KFz6aTUUfhE1L8VS3kn4nuNsAfb4zlMwK6tbd/nW7UqAcGugyq/6 z5Y/x8Y9IaPCan8IRdU2nA8ivuCY7oK6mKRySME70fSlbutPeDUZjKzBAbZvHczKeI nY8/XfJhme0oFH2wMCzZWDQh7Pk00KezLVmYjWtLQ7ji0G8w1AiZH8O1R3wNNcXZsm r1qmLR1cQEYRw== From: "H. Peter Anvin" To: libc-alpha@sourceware.org Cc: "H. Peter Anvin" , Florian Weimer , Andreas Schwab , Adhemerval Zanella Netto , Samuel Thibault Subject: [PATCH v5 11/12] termios: unify the naming of the termios speed fields Date: Wed, 14 May 2025 15:14:04 -0700 Message-ID: <20250514221405.471472-12-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250514221405.471472-1-hpa@zytor.com> References: <20250514221405.471472-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org The generic code has __ispeed and __ospeed; Linux has c_ispeed and c_ospeed. Use an anonymous union member to allow both set of names on all platforms. Signed-off-by: H. Peter Anvin (Intel) --- bits/termios.h | 11 +++++++- sysdeps/unix/sysv/linux/bits/termios-struct.h | 28 ++++++++++++------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/bits/termios.h b/bits/termios.h index 8f0b817dbf4c..798012cb8ebc 100644 --- a/bits/termios.h +++ b/bits/termios.h @@ -286,7 +286,16 @@ struct termios cc_t c_cc[NCCS]; /* Input and output baud rates. */ - speed_t __ispeed, __ospeed; + __extension__ union { + speed_t __ispeed; + speed_t c_ispeed; + }; +#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1 + __extension__ union { + speed_t __ospeed; + speed_t c_ospeed; + }; +#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1 }; #define _IOT_termios /* Hurd ioctl type field. */ \ diff --git a/sysdeps/unix/sysv/linux/bits/termios-struct.h b/sysdeps/unix/sysv/linux/bits/termios-struct.h index d7167dfa20c8..3e33d81df047 100644 --- a/sysdeps/unix/sysv/linux/bits/termios-struct.h +++ b/sysdeps/unix/sysv/linux/bits/termios-struct.h @@ -22,15 +22,23 @@ #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 */ - speed_t c_ispeed; /* input speed */ - speed_t c_ospeed; /* output speed */ +{ + 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 */ + + /* Input and output baud rates. */ + __extension__ union { + speed_t __ispeed; + speed_t c_ispeed; + }; #define _HAVE_STRUCT_TERMIOS_C_ISPEED 1 -#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1 + __extension__ union { + speed_t __ospeed; + speed_t c_ospeed; }; +#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1 +}; From patchwork Wed May 14 22:14:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Peter Anvin" X-Patchwork-Id: 112258 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D35453856DCB for ; Wed, 14 May 2025 22:17:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D35453856DCB Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zytor.com header.i=@zytor.com header.a=rsa-sha256 header.s=2025042001 header.b=I9VychMf X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (terminus.zytor.com [IPv6:2607:7c80:54:3::136]) by sourceware.org (Postfix) with ESMTPS id 9574B385700E for ; Wed, 14 May 2025 22:14:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9574B385700E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zytor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zytor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9574B385700E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::136 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260875; cv=none; b=EvyRNsOPGjY0KDbQAv2CMxMjFJiM53DIh4UkGMqNL0yr9/oBEavBCZVAW5DfPulzJv4Tg4uUmzT96CYgnpSWGUlBthnvPoqO3fmBFU2WRwbHkyxku5jyCBltGsSErGl8H4awkqhPs1dxB1NhJLiU4Z0XD4BaRc7o55eQr2ee+ak= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747260875; c=relaxed/simple; bh=EZS/zb/bG5ryOA9RzLRKkXep6Kw5SqVSPDTAgaYcJKo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=e6t5UOQNnKtv+QsFgZlFFgqOs++SaFffMECv25UL8pejx3kBwcK9n0G/KS+VoFtDa8k115qi9FWvFizteVNCJJbV6s3R6LWf6JLglUnwrIpkrbfxUZ7K19qlDi2BnsqL57dmtmcPB6adjijDExlG/gLLIxwkZlV93EQQoobKl1s= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9574B385700E Received: from mail.zytor.com ([IPv6:2601:646:8081:9485:69ca:8a67:356:c4ef]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 54EMEBNr3155983 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 14 May 2025 15:14:28 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 54EMEBNr3155983 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1747260868; bh=nDeA5sGZBXDh/JKMxlBpthl0fAym8Z2nCrFmV4P0cZk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I9VychMfgL6nG7KKIdW9/ViHZHUIaQyl2o7Nhng92858mQvEa644+enr7U/E1W/0z ehdNyTGlxLZg6CUV2paShh3sgGRFPCTDBqeT8CGqa6oCvWyrsP0gCRieIi82gQnCXc vplWTN3de7IxtlPf82SdT/WRRaFJk+AKTsKxM/gIQHLcn6gfshiYSi7C8lhfMyYyiN sR6VPCsk2TYmFOCHnB/1yJdibb4volByOFdloPlNQZ3zNh77zXw1s1A0y3+WMcW3MF NSaU8HAIwplRiaumV06x//G+smYWgJrIYteHjbqz2kYW+rXDggVs4wCNoubyGmVxgy GrOLrKSjK69PA== From: "H. Peter Anvin" To: libc-alpha@sourceware.org Cc: "H. Peter Anvin" , Florian Weimer , Andreas Schwab , Adhemerval Zanella Netto , Samuel Thibault Subject: [PATCH v5 12/12] linux/termios: regression test for termios speed functions Date: Wed, 14 May 2025 15:14:05 -0700 Message-ID: <20250514221405.471472-13-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250514221405.471472-1-hpa@zytor.com> References: <20250514221405.471472-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Test that runs through a fairly large combination of the various termios speed functions, for the new speed_t interface, for the old speed_t interface (if enabled), and for the new baud_t interface. Signed-off-by: H. Peter Anvin (Intel) --- sysdeps/unix/sysv/linux/Makefile | 1 + sysdeps/unix/sysv/linux/tst-termios-linux.c | 627 ++++++++++++++++++ .../sysv/linux/tst-termios-speed-tables.c | 86 +++ 3 files changed, 714 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/tst-termios-linux.c create mode 100644 sysdeps/unix/sysv/linux/tst-termios-speed-tables.c diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index a14b8c1f6181..19e12c364ade 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -237,6 +237,7 @@ tests += \ tst-sysvsem-linux \ tst-sysvshm-linux \ tst-tgkill \ + tst-termios-linux \ tst-timerfd \ tst-ttyname-direct \ tst-ttyname-namespace \ diff --git a/sysdeps/unix/sysv/linux/tst-termios-linux.c b/sysdeps/unix/sysv/linux/tst-termios-linux.c new file mode 100644 index 000000000000..06eb9d984cb4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-termios-linux.c @@ -0,0 +1,627 @@ +/* Linux termios regression tests + + 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; see the file COPYING.LIB. If + not, see . */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +/* generic utilities */ +static unsigned int errors; + +struct where { + const char *file; + const char *func; + int line; +}; +typedef const struct where *where_t; + +#define HERE \ + ({ \ + static const struct where here = { __FILE__, __func__, __LINE__ }; \ + &here; \ + }) +#define ERROR(where, msg, ...) \ + do { \ + const where_t _w = where; \ + errors++; \ + printf ("error: %s:%s:%d: " msg "\n", \ + _w->file, _w->func, _w->line , ## __VA_ARGS__); \ + } while (0) + +static void verify_failed (where_t where, const char *expr, + const char *test, bool bad) +{ + ERROR(where, "%s%s%s %s%s%s", + bad ? "assertion " : "", + expr, + bad ? test : "", + bad ? (errno ? "failed and " : "failed") : "", + errno ? "set errno: " : "", + errno ? strerror(errno) : ""); +} + +static inline void verify_check (where_t where, const char *expr, + const char *test, bool good) +{ + bool bad = !good; + if (__builtin_expect (bad || errno, 0)) + verify_failed (where, expr, test, bad); +} + +/* Check expression for expected result */ +#define VERIFY(expr,op,res) \ + ({ \ + errno = 0; \ + __auto_type _v = (expr); \ + __auto_type _r = (res); \ + verify_check (HERE, #expr, " " #op " " #res, _v op _r); \ + _v; \ + }) + +/* Check for zero (useful for return values) */ +#if 1 +#define CHECKZERO(expr) VERIFY(expr,==,0) +#else +#define CHECKZERO(expr) \ + ({ \ + errno = 0; \ + __auto_type _v = (expr); \ + verify_check (HERE, #expr, " == 0", _v == 0); \ + _v; \ + }) +#endif + +/* Just check errno */ +#define CHECKERR(expr) \ + ({ \ + errno = 0; \ + __auto_type v = (expr); \ + verify_check (HERE, #expr, NULL, true); \ + v; \ + }) + +/* Speed function tests */ + +#define BOGUS ((speed_t)-1) +#define ANY ((speed_t)-2) + +#include "tst-termios-speed-tables.c" + +/* These intentionally are a separate implementation from speed.c; + these should be "trivially correct" and don't need to be optimized + in any way */ + +/* Returns __BOTHER if there is no legacy value for this speed */ +static speed_t speed_to_cbaud (speed_t speed) +{ + const struct cbaud_table *ct; + for (ct = cbaud_table; ct->speed != ANY; ct++) + { + if (ct->speed == speed) + break; + } + return ct->cbaud; +} + +/* Returns ANY if cbaud is __BOTHER, or BOGUS if invalid */ +static speed_t cbaud_to_speed (speed_t cbaud) +{ + const struct cbaud_table *ct; + for (ct = cbaud_table; ct->cbaud != BOGUS; ct++) + { + if (ct->cbaud == cbaud) + break; + } + return ct->speed; +} + +static const char *cbaud_name (speed_t cbaud) +{ + const struct cbaud_table *ct; + for (ct = cbaud_table; ct->cbaud != BOGUS; ct++) + { + if (ct->cbaud == cbaud) + break; + } + return ct->name; +} + +static void check_speed (where_t where, speed_t expected, + speed_t speed, speed_t cbaud, + speed_t cfspeed, baud_t cfbaud, + char io) +{ + speed_t want_cbaud; + cbaud &= CBAUD; + + if (expected != ANY && speed != expected) + { + ERROR (where, "c_%cspeed = %u, expected %u", + io, speed, expected); + return; + } + if (cfspeed != speed) + { + ERROR (where, "cfget%cspeed = %u, expected %u", + io, cfspeed, speed); + return; + } + if (cfbaud != cfspeed) + { + ERROR (where, "cfget%cbaud = %u, but cfget%cspeed = %u", + io, cfbaud, io, cfspeed); + return; + } + want_cbaud = speed_to_cbaud (speed); + if (cbaud != want_cbaud) { + ERROR (where, "c_%cspeed = %u: %s = %s (%06o), should be %s (%06o)", + io, speed, + io == 'o' ? "CBAUD" : "CIBAUD", cbaud_name (cbaud), cbaud, + cbaud_name (want_cbaud), want_cbaud); + return; + } +} + +/* Validate that the speeds in the struct termios are properly normalized. + The difference is the handling of ispeed == 0. */ + +/* Use this after cfset* () */ +static void check_speeds_cf (where_t where, const struct termios *tio_p, + speed_t ospeed, speed_t ispeed) +{ + check_speed (where, ospeed, + tio_p->c_ospeed, tio_p->c_cflag, + CHECKERR (cfgetospeed (tio_p)), + CHECKERR (cfgetobaud (tio_p)), 'o'); + check_speed (where, ispeed, + tio_p->c_ispeed, tio_p->c_cflag >> IBSHIFT, + CHECKERR (cfgetispeed (tio_p)), + CHECKERR (cfgetibaud (tio_p)), 'i'); +} + +/* Use this after tc[gs]etattr () */ +static void check_speeds_tc (where_t where, int fd, + speed_t ospeed, speed_t ispeed) +{ + struct termios tio; + + CHECKZERO (tcgetattr (fd, &tio)); + check_speeds_cf (where, &tio, ospeed, ispeed ? ispeed : ospeed); +} + +/* For search and replace convenience */ +#define check_bauds_cf check_speeds_cf +#define check_bauds_tc check_speeds_tc + +/* Common routine for setting speeds, with checking */ +static void +set_speeds (int fd, speed_t ospeed, speed_t ispeed) +{ + struct termios tio; + + CHECKZERO (tcgetattr (fd, &tio)); + CHECKZERO (cfsetospeed (&tio, ospeed)); + CHECKZERO (cfsetispeed (&tio, ispeed)); + check_speeds_cf (HERE, &tio, ospeed, ispeed); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_speeds_tc (HERE, fd, ospeed, ispeed ? ispeed : ospeed); +} + +/* Actual tests */ + +typedef void (*speed_test_t)(int ttyfd, speed_t speed); +static void +run_speed_test (int fd, speed_test_t test); + +/* New interface cfset*speed test */ +static void +new_cfspeed_test (int fd, speed_t speed) +{ + struct termios tio; + speed_t old_ospeed, old_ispeed; + + CHECKZERO (tcgetattr (fd, &tio)); + old_ospeed = CHECKERR (cfgetospeed (&tio)); + old_ispeed = CHECKERR (cfgetispeed (&tio)); + + /* Check initial normalization */ + check_speeds_cf (HERE, &tio, old_ospeed, old_ispeed); + + /* Check cfset*speed normalization */ + CHECKZERO (cfsetospeed (&tio, speed)); + check_speeds_cf (HERE, &tio, speed, old_ispeed); + CHECKZERO (cfsetispeed (&tio, speed)); + check_speeds_cf (HERE, &tio, speed, speed); + CHECKZERO (cfsetospeed (&tio, old_ospeed)); + check_speeds_cf (HERE, &tio, old_ospeed, speed); + CHECKZERO (cfsetispeed (&tio, B0)); + check_speeds_cf (HERE, &tio, old_ospeed, B0); + CHECKZERO (cfsetspeed (&tio, speed)); + check_speeds_cf (HERE, &tio, speed, speed); + CHECKZERO (cfsetospeed (&tio, old_ospeed)); + CHECKZERO (cfsetispeed (&tio, old_ispeed)); + check_speeds_cf (HERE, &tio, old_ospeed, old_ispeed); +} + +/* New interface cfset*speed test with tcsetattr */ +static void +new_tcspeed_test (int fd, speed_t speed) +{ + struct termios tio; + speed_t old_ospeed, old_ispeed; + + CHECKZERO (tcgetattr (fd, &tio)); + old_ospeed = CHECKERR (cfgetospeed (&tio)); + old_ispeed = CHECKERR (cfgetispeed (&tio)); + + /* Check initial normalization */ + check_speeds_cf (HERE, &tio, old_ospeed, old_ispeed); + + /* Check cfset*speed normalization */ + CHECKZERO (cfsetospeed (&tio, speed)); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_speeds_tc (HERE, fd, speed, old_ispeed); + CHECKZERO (cfsetispeed (&tio, speed)); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_speeds_tc (HERE, fd, speed, speed); + CHECKZERO (cfsetospeed (&tio, old_ospeed)); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_speeds_tc (HERE, fd, old_ospeed, speed); + CHECKZERO (cfsetispeed (&tio, B0)); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_speeds_tc (HERE, fd, old_ospeed, B0); + CHECKZERO (cfsetspeed (&tio, speed)); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_speeds_tc (HERE, fd, speed, speed); + CHECKZERO (cfsetospeed (&tio, old_ospeed)); + CHECKZERO (cfsetispeed (&tio, old_ispeed)); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_speeds_tc (HERE, fd, old_ospeed, old_ispeed); +} + +/* New interface cfset*baud test */ +static void +new_cfbaud_test (int fd, baud_t baud) +{ + struct termios tio; + baud_t old_obaud, old_ibaud; + + CHECKZERO (tcgetattr (fd, &tio)); + old_obaud = CHECKERR (cfgetobaud (&tio)); + old_ibaud = CHECKERR (cfgetibaud (&tio)); + + /* Check initial normalization */ + check_bauds_cf (HERE, &tio, old_obaud, old_ibaud); + + /* Check cfset*baud normalization */ + CHECKZERO (cfsetobaud (&tio, baud)); + check_bauds_cf (HERE, &tio, baud, old_ibaud); + CHECKZERO (cfsetibaud (&tio, baud)); + check_bauds_cf (HERE, &tio, baud, baud); + CHECKZERO (cfsetobaud (&tio, old_obaud)); + check_bauds_cf (HERE, &tio, old_obaud, baud); + CHECKZERO (cfsetibaud (&tio, B0)); + check_bauds_cf (HERE, &tio, old_obaud, B0); + CHECKZERO (cfsetbaud (&tio, baud)); + check_bauds_cf (HERE, &tio, baud, baud); + CHECKZERO (cfsetobaud (&tio, old_obaud)); + CHECKZERO (cfsetibaud (&tio, old_ibaud)); + check_bauds_cf (HERE, &tio, old_obaud, old_ibaud); +} + +/* New interface cfset*baud test with tcsetattr */ +static void +new_tcbaud_test (int fd, baud_t baud) +{ + struct termios tio; + baud_t old_obaud, old_ibaud; + + CHECKZERO (tcgetattr (fd, &tio)); + old_obaud = CHECKERR (cfgetobaud (&tio)); + old_ibaud = CHECKERR (cfgetibaud (&tio)); + + /* Check initial normalization */ + check_bauds_cf (HERE, &tio, old_obaud, old_ibaud); + + /* Check cfset*baud normalization */ + CHECKZERO (cfsetobaud (&tio, baud)); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_bauds_tc (HERE, fd, baud, old_ibaud); + CHECKZERO (cfsetibaud (&tio, baud)); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_bauds_tc (HERE, fd, baud, baud); + CHECKZERO (cfsetobaud (&tio, old_obaud)); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_bauds_tc (HERE, fd, old_obaud, baud); + CHECKZERO (cfsetibaud (&tio, B0)); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_bauds_tc (HERE, fd, old_obaud, B0); + CHECKZERO (cfsetbaud (&tio, baud)); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_bauds_tc (HERE, fd, baud, baud); + CHECKZERO (cfsetobaud (&tio, old_obaud)); + CHECKZERO (cfsetibaud (&tio, old_ibaud)); + CHECKZERO (tcsetattr (fd, TCSANOW, &tio)); + check_bauds_tc (HERE, fd, old_obaud, old_ibaud); +} + +/* + * Old interface tests. This depends critically on the new struct + * termios being guaranteed to be a superset of the legacy struct + * termios. + */ +#if TEST_COMPAT (libc, GLIBC_2_0, GLIBC_2_42) +extern int __old_cfsetospeed (struct termios *tio_p, speed_t speed); +compat_symbol_reference (libc, __old_cfsetospeed, cfsetospeed, GLIBC_2_0); +extern int __old_cfsetispeed (struct termios *tio_p, speed_t speed); +compat_symbol_reference (libc, __old_cfsetispeed, cfsetispeed, GLIBC_2_0); +extern speed_t __old_cfgetospeed (const struct termios *tio_p); +compat_symbol_reference (libc, __old_cfgetospeed, cfgetospeed, GLIBC_2_0); +extern speed_t __old_cfgetispeed (const struct termios *tio_p); +compat_symbol_reference (libc, __old_cfgetispeed, cfgetispeed, GLIBC_2_0); +extern int __old_tcsetattr (int fd, int act, const struct termios *tio_p); +compat_symbol_reference (libc, __old_tcsetattr, tcsetattr, GLIBC_2_0); +extern int __old_tcgetattr (int fd, struct termios *tio_p); +compat_symbol_reference (libc, __old_tcgetattr, tcgetattr, GLIBC_2_0); + +static int old_tcsetattr (int fd, const struct termios *tio_p) +{ + struct termios old_tio = *tio_p; + + /* Deliberately corrupt c_ispeed and c_ospeed */ + old_tio.c_ispeed = 0xdeadbeef; + old_tio.c_ospeed = 0xfeedface; + return __old_tcsetattr (fd, TCSANOW, &old_tio); +} +static int old_tcgetattr (int fd, struct termios *tio_p) +{ + int rv; + memset (tio_p, 0xde, sizeof *tio_p); + rv = __old_tcgetattr (fd, tio_p); + if (rv) + return rv; + + /* Deliberately corrupt c_ispeed and c_ospeed */ + tio_p->c_ispeed = 0xdeadbeef; + tio_p->c_ospeed = 0xfeedface; + return 0; +} + +/* Old interface test. This relies on the new struct termios always + being a binary superset of the old one. + This doesn't bother testing split speed, since that never worked + on the old glibc. */ +static void +old_tcspeed_test (int fd, speed_t speed) +{ + struct termios tio; + speed_t cbaud; + + if (!speed) + return; /* Skip B0 for this test */ + + cbaud = speed_to_cbaud (speed); + if (cbaud == __BOTHER) + return; + + CHECKZERO (old_tcgetattr (fd, &tio)); + CHECKZERO (__old_cfsetospeed (&tio, cbaud)); + VERIFY (__old_cfgetospeed (&tio),==,cbaud); + CHECKZERO (__old_cfsetispeed (&tio, cbaud)); + VERIFY (__old_cfgetispeed (&tio),==,cbaud); + CHECKZERO (old_tcsetattr (fd, &tio)); + check_speeds_tc (HERE, fd, speed, speed); +} + +/* Verify that invalid CBAUD values return error for the old interfaces */ +static void +old_invalid_speeds_test (int fd) +{ + struct termios tio; + speed_t cbaud; + + for (cbaud = 0 ; cbaud ; cbaud > 0xffff ? (cbaud <<= 1) : cbaud++) { + speed_t realspeed; + realspeed = (cbaud & ~CBAUD) ? BOGUS : cbaud_to_speed (cbaud); + if (realspeed >= ANY) + { + int rv; + + errno = 0; + rv = __old_cfsetospeed (&tio, cbaud); + if (rv != -1 || errno != EINVAL) + { + ERROR(HERE, "__old_cfsetospeed() accepted invalid value %06o", + cbaud); + } + + errno = 0; + rv = __old_cfsetispeed (&tio, cbaud); + if (rv != -1 || errno != EINVAL) + { + ERROR(HERE, "__old_cfsetispeed() accepted invalid value %06o", + cbaud); + } + } + else + { + CHECKZERO (__old_cfsetospeed (&tio, cbaud)); + VERIFY (__old_cfgetospeed (&tio),==,cbaud); + CHECKZERO (__old_cfsetispeed (&tio, cbaud)); + VERIFY (__old_cfgetispeed (&tio),==,cbaud); + if (cbaud) + { + CHECKZERO (old_tcsetattr (fd, &tio)); + check_speeds_tc (HERE, fd, realspeed, realspeed); + } + } + } +} + +static void +compat_tests (int fd) +{ + run_speed_test (fd, old_tcspeed_test); + old_invalid_speeds_test (fd); +} +#else /* No TEST_COMPAT */ +#define compat_tests(fd) ((void)(fd)) +#endif + +static void +run_speed_test (int fd, speed_test_t test) +{ + unsigned short seed [3] = { 0x1234, 0x5678, 0x9abc }; + struct speeds { + speed_t ospeed, ispeed; + }; + static const struct speeds initial_speeds [] = { + { 2400, 2400 }, /* Standard speed, non-split */ + { 123456, 123456 }, /* Nonstandard speed, non-split */ + { 75, 1200 }, /* Standard split speeds */ + { 9600, 456789 }, /* One standard, one nonstandard */ + { 54321, 1234567890 }, /* Nonstandard, one very high */ + { 0, 0 } + }; + + for (const struct speeds *is = initial_speeds ; is->ospeed ; is++) + { + /* Set up initial conditions */ + set_speeds (fd, is->ospeed, is->ispeed); + + /* Test all common speeds */ + for (int i = 0 ; i < NUM_TEST_SPEEDS ; i++) + { + test (fd, test_speeds[i]); + } + + /* Test pseudorandom speeds; NUM_TEST_SPEEDS here is arbitrary */ + for (int i = 0 ; i < NUM_TEST_SPEEDS ; i++) + { + test (fd, (speed_t) jrand48 (seed)); + } + + /* Test power-of-2 speeds */ + for (speed_t s = 1 ; s ; s <<= 1) + { + test (fd, s); + } + + /* Test power of 2 multiples of 300; + 300 << 23 is the maximum below 2^32 */ + for (int i = 0 ; i < 24 ; i++) + { + test (fd, B300 << i); + } + } +} + +static void +run_speed_tests (int fd) +{ + /* Test proper canonicalization using the new interface */ + run_speed_test (fd, new_cfspeed_test); + run_speed_test (fd, new_tcspeed_test); + + /* Try the new cfset*baud() functions */ + run_speed_test (fd, new_cfbaud_test); + run_speed_test (fd, new_tcbaud_test); + + /* Tests of the legacy functions */ + compat_tests (fd); +} + +/* chroot setup */ + +static char *chrootdir; + +static void +prepare (int argc, char **argv) +{ + chrootdir = xasprintf ("%s/tst-termios-XXXXXX", test_dir); + if (mkdtemp (chrootdir) == NULL) + FAIL_EXIT1 ("mkdtemp (\"%s\"): %m", chrootdir); + add_temp_file (chrootdir); +} +#define PREPARE prepare + +/* test dispatch */ + +static void +run_in_chroot (void) +{ + /* Create a pty slave to use as a tty. Most of the termios settings, + including the speeds, have no impact on a pty, but they are still + settable like for any other tty, which makes them very convenient + for testing. */ + int ptmfd, ttyfd; + + ptmfd = posix_openpt (O_RDWR|O_NOCTTY|O_NONBLOCK); + if (ptmfd < 0 || grantpt (ptmfd) || unlockpt (ptmfd)) + { + FAIL_UNSUPPORTED ("cannot create PTY in chroot: %m" + " (consider increasing limits?)"); + } + + ttyfd = ioctl (ptmfd, TIOCGPTPEER, O_RDWR|O_NOCTTY|O_NONBLOCK); + if (ttyfd < 0 || !isatty (ttyfd)) + { + FAIL_UNSUPPORTED ("failed to open PTY slave in chroot: %m"); + } + + run_speed_tests (ttyfd); + + close (ttyfd); + close (ptmfd); +} + +static int +do_test (void) +{ + errors = 0; + + support_become_root (); + run_in_chroot (); + + if (errors) + { + printf ("%s: %u error%s\n", __FILE__, errors, errors != 1 ? "s" : ""); + return 1; + } + + return 0; +} + +#include diff --git a/sysdeps/unix/sysv/linux/tst-termios-speed-tables.c b/sysdeps/unix/sysv/linux/tst-termios-speed-tables.c new file mode 100644 index 000000000000..885266d09a39 --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-termios-speed-tables.c @@ -0,0 +1,86 @@ +/* Table of legacy speed constants */ + +struct cbaud_table +{ + speed_t speed; + speed_t cbaud; + const char *name; +}; + +static const struct cbaud_table cbaud_table [] = +{ + { 0, __B0, "__B0" }, + { 50, __B50, "__B50" }, + { 75, __B75, "__B75" }, + { 110, __B110, "__B110" }, + { 134, __B134, "__B134" }, + { 150, __B150, "__B150" }, + { 200, __B200, "__B200" }, + { 300, __B300, "__B300" }, + { 600, __B600, "__B600" }, + { 1200, __B1200, "__B1200" }, + { 1800, __B1800, "__B1800" }, + { 2400, __B2400, "__B2400" }, + { 4800, __B4800, "__B4800" }, +#ifdef __B7200 + { 7200, __B7200, "__B7200" }, +#endif + { 9600, __B9600, "__B9600" }, +#ifdef __B14400 + { 14400, __B14400, "__B14400" }, +#endif + { 19200, __B19200, "__B19200" }, +#ifdef __B28800 + { 28800, __B28800, "__B28800" }, +#endif + { 38400, __B38400, "__B38400" }, + { 57600, __B57600, "__B57600" }, +#ifdef __B76800 + { 76800, __B76800, "__B76800" }, +#endif + { 115200, __B115200, "__B115200" }, +#ifdef __B153600 + { 153600, __B153600, "__B153600" }, +#endif + { 230400, __B230400, "__B230400" }, +#ifdef __B307200 + { 307200, __B307200, "__B307200" }, +#endif + { 460800, __B460800, "__B460800" }, + { 500000, __B500000, "__B500000" }, + { 576000, __B576000, "__B576000" }, +#ifdef __B614400 + { 614400, __B614400, "__B614400" }, +#endif + { 921600, __B921600, "__B921600" }, + { 1000000, __B1000000, "__B1000000" }, + { 1152000, __B1152000, "__B1152000" }, + { 1500000, __B1500000, "__B1500000" }, + { 2000000, __B2000000, "__B2000000" }, +#ifdef __B2500000 + { 2500000, __B2500000, "__B2500000" }, +#endif +#ifdef __B3000000 + { 3000000, __B3000000, "__B3000000" }, +#endif +#ifdef __B3500000 + { 3500000, __B3500000, "__B3500000" }, +#endif +#ifdef __B4000000 + { 4000000, __B4000000, "__B4000000" }, +#endif + { ANY, __BOTHER, "__BOTHER" }, + { BOGUS, BOGUS, "invalid" } +}; + +/* List of common speeds to test */ + +#define NUM_TEST_SPEEDS 41 +static const speed_t test_speeds [NUM_TEST_SPEEDS] = +{ + 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, + 4800, 7200, 9600, 14400, 19200, 28800, 33600, 38400, 57600, + 76800, 115200, 153600, 230400, 307200, 460800, 500000, + 576000, 614400, 921600, 1000000, 1152000, 1500000, 2000000, + 2500000, 3000000, 3500000, 4000000, 5000000, 10000000 +};