From patchwork Sat Apr 26 02:55:31 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: 111067 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 BBF8B385843B for ; Sat, 26 Apr 2025 02:57:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BBF8B385843B 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=TqVe7fsU X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by sourceware.org (Postfix) with ESMTPS id 1673C3858D38 for ; Sat, 26 Apr 2025 02:55:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1673C3858D38 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 1673C3858D38 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636157; cv=none; b=oV73yJpsB9dhoLz1aj2web1f4tkhcNSgZT45PJrjQ1OGGHUVN6Aw4k3/OEs673eDywcFHxqcRsurl8VUFp2lkQAw/P0K4VS2vcBLM2aPL+v4HJVZ4IQfdKuSOAf+/zmwDxKOiW/JqBpe/nKAX9vcyoRY5upCHJSgXQCG3hp3/eA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636157; c=relaxed/simple; bh=g7DiZKhL3U2mJiJ7ZdAyqomWWQfu2AhIxjGq95AUs7o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=OeDuht6UjxiWc9MTcz0V2cfsYLCDCQphYP0+mjQnZ5uILTaY8F+ItJdpK4hmFUeCfGfbC1YW+iNmzUjoQdF9spsMSEcTovf1aEGm2rn9pFGd7nYUD47GXjYLTMFASLosLcrmLtpsHvKNtUtK8Ngdr0nwxcJBDNCRr4Hr5S7mI40= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1673C3858D38 Received: from carbon-x1.hos.anvin.org ([IPv6:2601:646:8081:1f93:3f9b:137e:d2cb:73f7]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 53Q2tj2l3756161 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 25 Apr 2025 19:55:53 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 53Q2tj2l3756161 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1745636153; bh=ehibyezgvWLPBUcGN1E25bCGnhSKyw9zR+rUAM7YCwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TqVe7fsU2c9ikTutlwAb6i1sRFkt7pYEgBqOjqEVVqJQw4ZLxBDx0cklwI3qOyJrF gD+V93t31GP9bjbTP6+ejfPiwHm2FNDMHvRJxlq9pic6mI0B9N2K51auZtDv7L9rQ/ NKLHljAcl+pANLj4vsWtSEr2VgtLpE+NkwE25d3a5RYOqjyiawzC/k2zo9Kir5f33G FJujs48UWoQ/Q/dtYItUbjFVFm0ziOqvRREahcBeU49e9KrikkjIFtJRgbmYVbQhUP 5Lw7zKBVeHledX46Iv0Mlh/WBG4jQrSVPJKWtM6XAygu5tN/P8cwleQRwHluZhgSVO WwKNEUplOba4A== From: "H. Peter Anvin" To: libc-alpha@sourceware.org, Florian Weimer , Andreas Schwab Cc: "H . J . Lu" , hpa@zytor.com Subject: [RFC PATCH v2 1/8] termios: make __tcsetattr() the internal interface Date: Fri, 25 Apr 2025 19:55:31 -0700 Message-ID: <20250426025538.771862-2-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250426025538.771862-1-hpa@zytor.com> References: <20250426025538.771862-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.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 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 +- sysdeps/unix/bsd/tcsetattr.c | 6 ++++-- sysdeps/unix/sysv/linux/tcsetattr.c | 2 +- termios/tcsetattr.c | 5 +++-- 5 files changed, 10 insertions(+), 7 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/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 Sat Apr 26 02:55:32 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: 111068 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 CD4CF385843B for ; Sat, 26 Apr 2025 02:58:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD4CF385843B 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=A9UaCRu5 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by sourceware.org (Postfix) with ESMTPS id 7AEA33858D3C for ; Sat, 26 Apr 2025 02:55:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7AEA33858D3C 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 7AEA33858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636157; cv=none; b=WnF/8jfa6Z8HVUeBb7xJvQYuwqLmrzR2YYElN+oGsgC02P4SBOAfcTf3Vfq17UVNTKXFzVHxeYqok8CFnC8XzxLlsaCrkbROltx8dz4xOPRjZV/mJBy1f1nlp0sfP78iuGrMqEFMJ128ZqQktvR9fVFlHfQVWcoLyhwR5M7Qvqs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636157; c=relaxed/simple; bh=OHdQhi7n1JyXIgCFLcON0rKTeFWkKUPtKGwViZxUjCU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=oyFHa76riNieX0LUzpgyD/I1EgIzjY5RMWW2hsnM4KxvdugCB/0KsV6vPojWpH/egqXPOYgb3lFDMfJ6U4xpInFFLMFqy3MXUeXD6GwpozU5uln+cXMpjaoVWq9sG6FwJ7cCQC2wbVgJc9vEXaxY7QopqCIiJg4mnRCwjLpkD9g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7AEA33858D3C Received: from carbon-x1.hos.anvin.org ([IPv6:2601:646:8081:1f93:3f9b:137e:d2cb:73f7]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 53Q2tj2m3756161 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 25 Apr 2025 19:55:54 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 53Q2tj2m3756161 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1745636154; bh=GrXRB0qiRBJSx6511DGVyx+i9ZtQot12A2wYTZll3Rk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A9UaCRu5pyH2WO5L8vqJSEpJOwFPciJwpGPn7p3y8k6rJhKNPOFsNLa1NBwcInvln U7JgD2/86LyA/aAKTzB0GExg6XjDaloYwF9G9BSxYGCGi3At/vQuL5t/lTQjE9MUZS X9aC5JIC8s3l3cWZm345Ix+83r2qFarlBkpEWjm4wmnbxBfjVKFlINp8KZBbAMQ1vA +Xz4Iun4J9KqtAOwprjUKBi1dA2R0V7/w64mwCxEn60se532fIpo4gUxdtKjvMXM1x GbZlt+yVvKKMOdSKWUSTk/hxXlrLkxd2ZLrO9XAeLMGnaGGgbugXohBOr5RuqRoIC2 1vtuIHEUgbmvQ== From: "H. Peter Anvin" To: libc-alpha@sourceware.org, Florian Weimer , Andreas Schwab Cc: "H . J . Lu" , hpa@zytor.com Subject: [RFC PATCH v2 2/8] io: make __local_isatty () a function; stub should return 0 Date: Fri, 25 Apr 2025 19:55:32 -0700 Message-ID: <20250426025538.771862-3-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250426025538.771862-1-hpa@zytor.com> References: <20250426025538.771862-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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 Make __local_isatty () an actual function instead of being an inline in libio. This allows simpler system-specific implementations that don't need to touch errno at all. Add such an implementation for Linux, with a generic fallback. The stub implementation for isatty() returned -1, errno == ENOSYS, but on a tty-less platform 0, errno == ENOTTY is more correct. Signed-off-by: H. Peter Anvin (Intel) --- include/unistd.h | 1 + io/Makefile | 1 + io/isatty.c | 4 ++-- io/local_isatty.c | 29 ++++++++++++++++++++++++++ libio/filedoalloc.c | 12 +---------- sysdeps/unix/sysv/linux/local_isatty.c | 29 ++++++++++++++++++++++++++ 6 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 io/local_isatty.c create mode 100644 sysdeps/unix/sysv/linux/local_isatty.c diff --git a/include/unistd.h b/include/unistd.h index e241603b8131..18d56bc4ee0d 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 __local_isatty (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..cc7309f6530b 100644 --- a/io/Makefile +++ b/io/Makefile @@ -96,6 +96,7 @@ routines := \ lchown \ link \ linkat \ + local_isatty \ lockf \ lockf64 \ lseek \ diff --git a/io/isatty.c b/io/isatty.c index 3f3912d8e52b..4eb95fe33eca 100644 --- a/io/isatty.c +++ b/io/isatty.c @@ -22,8 +22,8 @@ int __isatty (int fd) { - __set_errno (ENOSYS); - return -1; + __set_errno (ENOTTY); + return 0; } weak_alias (__isatty, isatty) diff --git a/io/local_isatty.c b/io/local_isatty.c new file mode 100644 index 000000000000..0044f40f2520 --- /dev/null +++ b/io/local_isatty.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 +__local_isatty (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..b1cd76e9c967 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)) + __local_isatty (fp->_fileno)) fp->_flags |= _IO_LINE_BUF; } #if defined _STATBUF_ST_BLKSIZE diff --git a/sysdeps/unix/sysv/linux/local_isatty.c b/sysdeps/unix/sysv/linux/local_isatty.c new file mode 100644 index 000000000000..3bd5f67ea7da --- /dev/null +++ b/sysdeps/unix/sysv/linux/local_isatty.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 +__local_isatty (int fd) +{ + struct __kernel_termios k_termios; + return INTERNAL_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios) == 0; +} From patchwork Sat Apr 26 02:55:33 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: 111069 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 782ED3857823 for ; Sat, 26 Apr 2025 02:59:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 782ED3857823 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=BaA8qmUt X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by sourceware.org (Postfix) with ESMTPS id 08D1D3858C54 for ; Sat, 26 Apr 2025 02:55:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 08D1D3858C54 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 08D1D3858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636158; cv=none; b=MidOESFuTj+DBu3+sIoLYX2brkk+czVgqNMLJte9YAX4v68RooGe1LH4IKGntW3K/TTAWzHuSe5buGYepSKhtj2ltINGPqcZpyxGVPOoBHVBs+Sy99og3NfkRbXAa3svfH8D9g6o9b3PsYrF5dMXoGWw0kOlSQHbnaHUanlvZas= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636158; c=relaxed/simple; bh=uyHbPOGYLxrzhuhuSuBSUZU3wdl0STDMdPAKduyNCro=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=mmwt3EB01FCOQ1LGhf/5yqIXGcSRJ9OUTjTsGJgVvH5sdd0R8pskSX00pnx6esIcvaHZAj6aDhVz2xlHLesmDEhgyLij680IdoYaSp0z8JVBPhEPnZ+PL3uVog//fepjza5GU+qzGeeRNkTO4rfSrs8OfCdzNYhgpLY1BVYlm5I= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08D1D3858C54 Received: from carbon-x1.hos.anvin.org ([IPv6:2601:646:8081:1f93:3f9b:137e:d2cb:73f7]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 53Q2tj2n3756161 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 25 Apr 2025 19:55:54 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 53Q2tj2n3756161 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1745636155; bh=MPJUMkOx0uWn0V/N/1sIY2S6QzV5vC/c2ieDBy/YX1M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BaA8qmUtMe6toVbhB0Xj1k3sVjZO6qzoFTgj6KDvBroFB338w07VvYx0ZcyEmhJ/Y h6SVBgFKId6CGBMok+B34zj3b/iMe6K6+tB1O8aQS/zgJwC7X9Xx8TLqn5G1AOQZNp hKRt6QzGdQfJVGUSXuLscEZQ9ewxe/qjussOJ2v7yBrjkjSKxcanq5QX+a6HcBk6ha 9gboLYbfaXz/3kxHqXTtRxKvbQqaDDXU+0FYjpghF1UQ+Lxw8XZC7DuERDejlkJX3n e8j+gga+pzaS0hbElby/AeSKke5wbVo9h7RtjCnIkNP5mxr4YXmSI/HLRnT8mJGmyt 0snJx60DExyBg== From: "H. Peter Anvin" To: libc-alpha@sourceware.org, Florian Weimer , Andreas Schwab Cc: "H . J . Lu" , hpa@zytor.com Subject: [RFC PATCH v2 3/8] linux/ioctls: move sockios ioctls back into a separate file Date: Fri, 25 Apr 2025 19:55:33 -0700 Message-ID: <20250426025538.771862-4-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250426025538.771862-1-hpa@zytor.com> References: <20250426025538.771862-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.0 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 In the kernel, these are . The differences between the copied data in are minor, but the kernel uses some #ifdefs which might not be safe in glibc. Futhermore, a handful of such ioctls have architecture-specific numbers, from Factor out , and use for the arch-specific ioctls. Signed-off-by: H. Peter Anvin --- sysdeps/unix/sysv/linux/Makefile | 1 + sysdeps/unix/sysv/linux/alpha/bits/ioctls.h | 2 +- sysdeps/unix/sysv/linux/bits/ioctls.h | 85 +-------------- sysdeps/unix/sysv/linux/bits/sockios.h | 108 ++++++++++++++++++++ sysdeps/unix/sysv/linux/hppa/bits/ioctls.h | 2 +- sysdeps/unix/sysv/linux/sparc/bits/ioctls.h | 2 +- 6 files changed, 113 insertions(+), 87 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/bits/sockios.h diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index ebcf820403ff..e4d4e97f2d08 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -148,6 +148,7 @@ sysdep_headers += \ bits/siginfo-consts-arch.h \ bits/signalfd.h \ bits/socket_type.h \ + bits/sockios.h \ bits/struct_stat.h \ bits/struct_stat_time64_helper.h \ bits/syscall.h \ diff --git a/sysdeps/unix/sysv/linux/alpha/bits/ioctls.h b/sysdeps/unix/sysv/linux/alpha/bits/ioctls.h index 77dc0c1c447c..2605b1870f4c 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/ioctls.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/ioctls.h @@ -33,4 +33,4 @@ #define TCSETSW _IOW ('t', 21, char[44]) #define TCSETSF _IOW ('t', 22, char[44]) -#include +#include diff --git a/sysdeps/unix/sysv/linux/bits/ioctls.h b/sysdeps/unix/sysv/linux/bits/ioctls.h index 7e226e4e8f13..7ba2d5d33e54 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 diff --git a/sysdeps/unix/sysv/linux/bits/sockios.h b/sysdeps/unix/sysv/linux/bits/sockios.h new file mode 100644 index 000000000000..3cd4260384da --- /dev/null +++ b/sysdeps/unix/sysv/linux/bits/sockios.h @@ -0,0 +1,108 @@ +/* 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 + +/* Architecture-specific socket ioctl values */ +#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 */ diff --git a/sysdeps/unix/sysv/linux/hppa/bits/ioctls.h b/sysdeps/unix/sysv/linux/hppa/bits/ioctls.h index 6563be803089..038907d6d3a5 100644 --- a/sysdeps/unix/sysv/linux/hppa/bits/ioctls.h +++ b/sysdeps/unix/sysv/linux/hppa/bits/ioctls.h @@ -33,4 +33,4 @@ #define TCSETSW _IOW ('T', 18, char[36]) #define TCSETSF _IOW ('T', 19, char[36]) -#include +#include diff --git a/sysdeps/unix/sysv/linux/sparc/bits/ioctls.h b/sysdeps/unix/sysv/linux/sparc/bits/ioctls.h index 1a95466e8fb5..f47d2bda7c30 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/ioctls.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/ioctls.h @@ -33,4 +33,4 @@ #define TCSETSW _IOW ('T', 10, char[36]) #define TCSETSF _IOW ('T', 11, char[36]) -#include +#include From patchwork Sat Apr 26 02:55:34 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: 111070 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 552A83857729 for ; Sat, 26 Apr 2025 03:02:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 552A83857729 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=b81J5oDD X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by sourceware.org (Postfix) with ESMTPS id 845993858406 for ; Sat, 26 Apr 2025 02:55:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 845993858406 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 845993858406 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636159; cv=none; b=lyVr4hOmL2O7CqbVmaLvzLzrHlo1O9rbQNZwJeFjDD32OFbUHRaWWlkuG4OtBS0yzmXkgKgAAlJCRnzx31iHn9gTJpslIPZl2kccU/3GouR3i7Rsvf0YKpvFX0p2pTjpFBOU2Y3q4h7M8MAgYnd9odKj/c33x4P/AHRZB2mpmX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636159; c=relaxed/simple; bh=qDB0wlB87KZDe+WRwe755/8UVTHLzRhpDeChApwWQhw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=S/FLnYiifj1xm5W/V0lneQt/WppUfhPU4XZigJglMbRQRJM3ayMif7EUpvUUgJuM+244W+UqJNsrFjJGgaqH57WBa5TumYp1WdDXRStuZH2TvpvDuj+BGwE4h+MMaB+J1q5AOoIBvht90K/HA1eSUwRtfsru0TXmtetmeGIpPNM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 845993858406 Received: from carbon-x1.hos.anvin.org ([IPv6:2601:646:8081:1f93:3f9b:137e:d2cb:73f7]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 53Q2tj2o3756161 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 25 Apr 2025 19:55:55 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 53Q2tj2o3756161 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1745636155; bh=j5gwKj1AfnjPCJxBlLUEmaDTWWrM+Xzh2t8crkSh7Xk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b81J5oDDLlFn83cRAI5hN3UGvwXt0ApuKCpo+jDgGzuZ+mqV6/yI6vL4dCLg9dY7d hDMIG6skVFgOUYGJhQQfFDZspPC9XPDaudDCIPH9ydilVaIavmimJs4/3SbnuY8XU5 oRcm3ph5ukcSDfxOW8ze98z2mvPvsaDYLGfihoc37Nn9saVRPgwvsT8zTrOCv22CjY Fj4DXi1+I3LsSxg5376MsFD6N3r+o0wq4f1CC68mrhx2hIxiHuR6bK63oO7CkG/wij xU20u2oHDUFH/Ms/peVBd38SsViTI/mx15xkE+mAt6F3rQtlV33tK3DWNZePl+Mx/F myzxJmorhhFQw== From: "H. Peter Anvin" To: libc-alpha@sourceware.org, Florian Weimer , Andreas Schwab Cc: "H . J . Lu" , hpa@zytor.com Subject: [RFC PATCH v2 4/8] linux/termios/powerpc: deal with powerpc-unique ioctl emulation Date: Fri, 25 Apr 2025 19:55:34 -0700 Message-ID: <20250426025538.771862-5-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250426025538.771862-1-hpa@zytor.com> References: <20250426025538.771862-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.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 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 Sat Apr 26 02:55:35 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: 111071 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 4323E3857B9F for ; Sat, 26 Apr 2025 03:03:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4323E3857B9F 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=XXtOOGN3 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by sourceware.org (Postfix) with ESMTPS id B52093858408 for ; Sat, 26 Apr 2025 02:55:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B52093858408 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 B52093858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636159; cv=none; b=eE+juIuQD+IOjXuM8xiuPKMGeaJlDSA3Vy6TsAzNh8/lTv9LYzoW9wY+Rlm69xahc5T0sqWjiC4TOGsuuiJXt167ytDQLlJ7xjdt1C9h2FX7Vmna/muDG64+GT3CRdwBYSs5PEAVl6aUS96P8T0vZdShgMV0S22lUcEm5t2pLUg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636159; c=relaxed/simple; bh=lpjRCG0SoCCl/EK8WjMMp86xV+R3HnnqYwTVwwX0/NE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=rkYw5Dj638FdKB7Lh98kVpe6mS90RTikuLTIWpmQDpTjMVcNqLqPsbbgicl6AlogaioxMjsdyT3C567H9aQqR31sVWbw4o1kpew7KsZH03B/diIFwbwZWUaeXIJc0Aa67hJYT0sANywmJu4QdA3kz4yUrMhGuNTyqmEnKHrgDg4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B52093858408 Received: from carbon-x1.hos.anvin.org ([IPv6:2601:646:8081:1f93:3f9b:137e:d2cb:73f7]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 53Q2tj2p3756161 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 25 Apr 2025 19:55:56 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 53Q2tj2p3756161 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1745636156; bh=DGNYJUEjOpiH+5iPEkCIf9icu1Y6apF7K6zpsmCFI2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XXtOOGN3dYWC79ShPm62Dj59xq/VDSDjw/4w+MVxtpw2/Ukz093T9FVuOx6ilZSFE xdRiI4dn/qVIT7fS6wv2e94CKzxuslA69qwmHid7HPS8ojN8SlhAccqj8AK0pOHazE MKrFrEMLkSKvPorapxui78YONLcVz9rCj2Wo/k4Oi3ajKoXP0iP4mhkGNGZTUfLEie 96WAd79VzLTnL1oP7/qB54xPeYxq1u6nA5wKgYXLyNFm7W12HU8++3wBl8eDoU3chQ WaF+JxpusOP7t9XjfqDtDun4h3o/w833IV+sR82+Ulz4nsXBIAEammu11Y1GACqeTM TbQTM5/I8YLiA== From: "H. Peter Anvin" To: libc-alpha@sourceware.org, Florian Weimer , Andreas Schwab Cc: "H . J . Lu" , hpa@zytor.com Subject: [RFC PATCH v2 5/8] linux: implement arbitrary and split speeds in termios Date: Fri, 25 Apr 2025 19:55:35 -0700 Message-ID: <20250426025538.771862-6-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250426025538.771862-1-hpa@zytor.com> References: <20250426025538.771862-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.7 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 | 52 +-- 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/kernel-features.h | 4 + sysdeps/unix/sysv/linux/kernel_termios.h | 20 +- sysdeps/unix/sysv/linux/local_isatty.c | 9 +- .../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 | 341 +++++++++++++++--- sysdeps/unix/sysv/linux/tcgetattr.c | 85 ++--- sysdeps/unix/sysv/linux/tcsetattr.c | 121 ++++--- 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, 1011 insertions(+), 490 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 df7268e5d0af..0d70a2601078 100644 --- a/NEWS +++ b/NEWS @@ -21,6 +21,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..be5979848d75 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2757,3 +2757,8 @@ GLIBC_2.42 uabs F GLIBC_2.42 uimaxabs F GLIBC_2.42 ulabs F GLIBC_2.42 ullabs F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed 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..1938691d3e08 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -3194,3 +3194,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist index c46c08da85c9..b966a6c5473b 100644 --- a/sysdeps/unix/sysv/linux/arc/libc.abilist +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist @@ -2518,3 +2518,8 @@ GLIBC_2.42 uabs F GLIBC_2.42 uimaxabs F GLIBC_2.42 ulabs F GLIBC_2.42 ullabs F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist index 4df150c0f042..41cad7d2f263 100644 --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist @@ -2883,3 +2883,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist index be294783f685..5980a6bf38ca 100644 --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist @@ -2880,3 +2880,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed 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..3b7df8137734 100644 --- a/sysdeps/unix/sysv/linux/bits/termios.h +++ b/sysdeps/unix/sysv/linux/bits/termios.h @@ -18,41 +18,49 @@ #ifndef _TERMIOS_H # error "Never include directly; use instead." +#elif defined(_TERMIOS_H) && defined(_TERMIO_H) +# error " and cannot both be included" #endif 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 +82,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..7ba2a41ce071 100644 --- a/sysdeps/unix/sysv/linux/csky/libc.abilist +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist @@ -2794,3 +2794,8 @@ GLIBC_2.42 uabs F GLIBC_2.42 uimaxabs F GLIBC_2.42 ulabs F GLIBC_2.42 ullabs F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index 2dc85b953303..d0794db120a6 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -2903,3 +2903,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index 1e38217ec6ad..cda6dee18d42 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -3086,3 +3086,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed 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..96be7655193b 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 (ioctl, 3, fd, TCGETS2, &k_termios) == 0; +} +weak_alias (__isatty, isatty) 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/local_isatty.c b/sysdeps/unix/sysv/linux/local_isatty.c index 3bd5f67ea7da..2b38c29e0520 100644 --- a/sysdeps/unix/sysv/linux/local_isatty.c +++ b/sysdeps/unix/sysv/linux/local_isatty.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 __local_isatty (int fd) { - struct __kernel_termios k_termios; - return INTERNAL_SYSCALL (ioctl, 3, fd, TCGETS, &k_termios) == 0; + struct termios2 k_termios; + return INTERNAL_SYSCALL (ioctl, 3, fd, TCGETS2, &k_termios) == 0; } diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist index 927fc2144526..f53381a6aff3 100644 --- a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist +++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist @@ -2278,3 +2278,8 @@ GLIBC_2.42 uabs F GLIBC_2.42 uimaxabs F GLIBC_2.42 ulabs F GLIBC_2.42 ullabs F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index 74da49d9da42..915973afae3c 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -2862,3 +2862,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index e5d678111f49..ec6b185ae191 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -3029,3 +3029,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist index 4dbd4b60450f..f1d5950cec1b 100644 --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist @@ -2843,3 +2843,8 @@ GLIBC_2.42 uabs F GLIBC_2.42 uimaxabs F GLIBC_2.42 ulabs F GLIBC_2.42 ullabs F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist index c5965bb50cf5..6d484626b7cf 100644 --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist @@ -2840,3 +2840,8 @@ GLIBC_2.42 uabs F GLIBC_2.42 uimaxabs F GLIBC_2.42 ulabs F GLIBC_2.42 ullabs F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed 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..0606142e4f78 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -2990,3 +2990,10 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F +GLIBC_2.42 tcgetattr F +GLIBC_2.42 tcsetattr 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..2b450cc0664e 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -2988,3 +2988,10 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F +GLIBC_2.42 tcgetattr F +GLIBC_2.42 tcsetattr 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..106f4af7e061 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -2996,3 +2996,10 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F +GLIBC_2.42 tcgetattr F +GLIBC_2.42 tcsetattr 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..ce3ffc653b38 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -2898,3 +2898,10 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F +GLIBC_2.42 tcgetattr F +GLIBC_2.42 tcsetattr 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..a41b34ae99f1 100644 --- a/sysdeps/unix/sysv/linux/or1k/libc.abilist +++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist @@ -2268,3 +2268,8 @@ GLIBC_2.42 uabs F GLIBC_2.42 uimaxabs F GLIBC_2.42 ulabs F GLIBC_2.42 ullabs F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed 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..affcbb09e073 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -3239,3 +3239,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed 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..2b67270c0aa4 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -3284,3 +3284,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed 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..7eb029874aee 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist @@ -2993,3 +2993,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed 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..deae41dedfd0 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist @@ -2977,3 +2977,8 @@ GLIBC_2.42 uabs F GLIBC_2.42 uimaxabs F GLIBC_2.42 ulabs F GLIBC_2.42 ullabs F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist index 9330c7ab762a..8c007148c340 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist @@ -2521,3 +2521,8 @@ GLIBC_2.42 uabs F GLIBC_2.42 uimaxabs F GLIBC_2.42 ulabs F GLIBC_2.42 ullabs F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index ea4555d39e00..f0f4a4673810 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -2721,3 +2721,8 @@ GLIBC_2.42 uabs F GLIBC_2.42 uimaxabs F GLIBC_2.42 ulabs F GLIBC_2.42 ullabs F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed 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..bb36c1db746c 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -3251,3 +3251,8 @@ GLIBC_2.9 pututline F GLIBC_2.9 pututxline F GLIBC_2.9 updwtmp F GLIBC_2.9 updwtmpx F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed 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..a93e93a19507 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -3028,3 +3028,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist index 36a94c9210ce..451f7f790f43 100644 --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist @@ -2909,3 +2909,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist index f79aba6aab3d..bc8fd612a62e 100644 --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist @@ -2906,3 +2906,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed 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..c80b9c10e3d9 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -3256,3 +3256,10 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F +GLIBC_2.42 tcgetattr F +GLIBC_2.42 tcsetattr F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index 931109dab18a..a9acb136b310 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -2874,3 +2874,10 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F +GLIBC_2.42 tcgetattr F +GLIBC_2.42 tcsetattr F diff --git a/sysdeps/unix/sysv/linux/speed.c b/sysdeps/unix/sysv/linux/speed.c index 017f74177f9b..b954a19ba1e4 100644 --- a/sysdeps/unix/sysv/linux/speed.c +++ b/sysdeps/unix/sysv/linux/speed.c @@ -16,82 +16,329 @@ 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 +speed_t +___cbaud_to_speed (tcflag_t c_cflag, speed_t other) +{ + switch (c_cflag) { + case __B0: + return 0; + case __B50: + return 50; + case __B75: + return 75; + case __B110: + return 110; + case __B134: + return 134; + case __B150: + return 150; + case __B200: + return 200; + case __B300: + return 300; + case __B600: + return 600; + case __B1200: + return 1200; + case __B1800: + return 1800; + case __B2400: + return 2400; + case __B4800: + return 4800; + case __B9600: + return 9600; + case __B19200: + return 19200; + case __B38400: + return 38400; + case __B57600: + return 57600; + case __B115200: + return 115200; + case __B230400: + return 230400; + case __B460800: + return 460800; + case __B500000: + return 500000; + case __B576000: + return 576000; + case __B921600: + return 921600; + case __B1000000: + return 1000000; + case __B1152000: + return 1152000; + case __B1500000: + return 1500000; + case __B2000000: + return 2000000; +#ifdef __B76800 + case __B76800: + return 76800; +#endif +#ifdef __B153600 + case __B153600: + return 153600; +#endif +#ifdef __B307200 + case __B307200: + return 307200; +#endif +#ifdef __B614400 + case __B614400: + return 614400; +#endif +#ifdef __B2500000 + case __B2500000: + return 2500000; +#endif +#ifdef __B3000000 + case __B3000000: + return 3000000; +#endif +#ifdef __B3500000 + case __B3500000: + return 3500000; +#endif +#ifdef __B4000000 + case __B4000000: + return 4000000; +#endif + default: + return other; + } + +} + +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..042ca492eeb4 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 (ioctl, 3, 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_ospeed; - 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..604e1f544690 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); + + 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 (ioctl, 3, 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..76244ddab801 --- /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 equivalent for + * the legth of 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..41f933aea188 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -2825,3 +2825,8 @@ GLIBC_2.9 ns_name_skip F GLIBC_2.9 ns_name_uncompress F GLIBC_2.9 ns_name_unpack F GLIBC_2.9 pipe2 F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed 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..4623721bbe6d 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2772,3 +2772,8 @@ GLIBC_2.42 uabs F GLIBC_2.42 uimaxabs F GLIBC_2.42 ulabs F GLIBC_2.42 ullabs F +GLIBC_2.42 cfgetospeed F +GLIBC_2.42 cfgetispeed F +GLIBC_2.42 cfsetospeed F +GLIBC_2.42 cfsetispeed F +GLIBC_2.42 cfsetspeed F From patchwork Sat Apr 26 02:55:36 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: 111073 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 41408385781A for ; Sat, 26 Apr 2025 03:04:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41408385781A 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=AtzdyWX6 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by sourceware.org (Postfix) with ESMTPS id DE2673858433 for ; Sat, 26 Apr 2025 02:55:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DE2673858433 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 DE2673858433 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636160; cv=none; b=KRhjFApq2yB1Sq6aXVw5oZJpOc8DvVI1czljnNOytsLz/qz9/9Z/da6Y54OxaeeQBF9yYLhDn4raAvWS39OON6lTcUw+i7cQFcftv721U4towVDPZVoe/aqDu8Fent0gQP2vyzzQD5JDVNCz36e+IlsYS28+xkuPrpBN1j+D6Z8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636160; c=relaxed/simple; bh=vLAqZEwQPeRKRZCdPf/PdeYbdqxAANl7IRnGngLOYk8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=e0ogV2/PJl3d/he7UrwY8jU3ZcTv7MNcciqR+hhAzlW+yaxZhFGP46oC08lTH2ICZCC+aQ/MyZZEHLpuaJul1Dl1whgjutqWD5HL41EiVzRiZI+L/gTKpU5nTWyST2Oeiz+6Hd1xgp47Psj/b9sH3fJJ424j5h8eHsSAA5+/k48= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DE2673858433 Received: from carbon-x1.hos.anvin.org ([IPv6:2601:646:8081:1f93:3f9b:137e:d2cb:73f7]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 53Q2tj2q3756161 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 25 Apr 2025 19:55:56 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 53Q2tj2q3756161 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1745636156; bh=bYkiilvYeD6GQ8hQW2YqgiUXBK0XmZ34flXSxRftHTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AtzdyWX68f6H33oUuUqAgTy1Q1TKiTrHDIdZIE8drce9fo9yubkzQLV8qn5dIWPHk gGi4fap9M4JpPFXgyVEPgYCdej1l57yGj1UQlVPGkiQzVO+UFi9tHNBUj1gcNiJK49 v8sCNfoA6ZsZ3vqFwOAK0BfovI0ubjztdcc+qGdwcP5gS+7o1xzzbnBnKD6qT250ze +OV2s5nIZbUG4F3brg0ddXjhg9Dn+TNokhcYu7v9gygJGL1wdAFnyj6RdY2ktuA0Q5 RQCD3jABOz76FIaMq0bv1PVEuZihDwwjcrhWIvEIpqPrdJQ8hSieae+yCPlJU0ZyHS AnNEwUmIerq0Q== From: "H. Peter Anvin" To: libc-alpha@sourceware.org, Florian Weimer , Andreas Schwab Cc: "H . J . Lu" , hpa@zytor.com Subject: [RFC PATCH v2 6/8] termios: change the generic cfsetspeed() to support arbitrary speeds Date: Fri, 25 Apr 2025 19:55:36 -0700 Message-ID: <20250426025538.771862-7-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250426025538.771862-1-hpa@zytor.com> References: <20250426025538.771862-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 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 Sat Apr 26 02:55:37 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: 111074 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 AB3E63858406 for ; Sat, 26 Apr 2025 03:07:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB3E63858406 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=dj2rWQy8 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by sourceware.org (Postfix) with ESMTPS id 42B38385843B for ; Sat, 26 Apr 2025 02:56:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 42B38385843B 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 42B38385843B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636161; cv=none; b=KoNbZs6Zmo5zP86ZFQDf10EviOBa+mYEj8U4Vpi/m9J6CqevXNEgW2jypQsiW5+MAq7mxQyNIVTvOi0Ttk1gT3Bi2akzttdGBkkY6i5tHrJVr3yqNipPZDpIAL6ABiv72UGpUXihAM6RufmSychrlPIsSAqxsRrF1YQ/B7XPy94= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636161; c=relaxed/simple; bh=RNSrFBHrk5kxtmuYzS43A+pB6U6XMuTqZh6s3JLM1u4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=eHeDpd7k/2mXCeONf5gz8kvRcKfgQfqaHpkATbaQ4NTqTT6YZaIKKZhA52tuxTZU4azjmRJ7taoRyUoW2uV1O84J5sOIe43hbJqbNlPNIvA8c/AxM3iOjZoOaMKoDoY6w4Ny6aBgjhs1/jTCVmMEUxMRL52Lmu4GL3F7AR6Ipi0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42B38385843B Received: from carbon-x1.hos.anvin.org ([IPv6:2601:646:8081:1f93:3f9b:137e:d2cb:73f7]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 53Q2tj2r3756161 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 25 Apr 2025 19:55:57 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 53Q2tj2r3756161 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1745636157; bh=MBdnmue4tehJ3QKzsCG/t8HrUImFDWzVOf4FYjJVVlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dj2rWQy8vh9JVxBj9tuVT6MnJdq31itchJUb5yA5+Hx97Yu9ZtY44YM7Gk3Kjd2Ht GTZwal8yCxLSlyRBrM38vJIofBmzqxzr0KX8LTszKiHYff/ATLQolBTSrGrmuZb0XM xtc7YuihjeSJ8I2RV3MvMYvXn2yd7AL7rcMu6fUVomIUTnRhYFDa3sLRujHbLg4Z1h GkYQOV55z8gwCP7JdFJREeyhy1MAGq8C7iVGG1rHItrOEr1NYe+1Nd910acIT1NEMV ur/CIBn9C3wHP9luBos1wAVIynFUbV3KacCoylJr4D8pdDLXEGAc4+dSJ1qMT3yQE/ j8QdiPDIgJG+A== From: "H. Peter Anvin" To: libc-alpha@sourceware.org, Florian Weimer , Andreas Schwab Cc: "H . J . Lu" , hpa@zytor.com Subject: [RFC PATCH v2 7/8] termios: add new baud_t interface, defined to be explicitly numeric Date: Fri, 25 Apr 2025 19:55:37 -0700 Message-ID: <20250426025538.771862-8-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250426025538.771862-1-hpa@zytor.com> References: <20250426025538.771862-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 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 | 86 ++++++++++++++++--- 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 | 60 +++++++++++++ termios/cfsetbaud.c | 33 +++++++ termios/cfsetspeed.c | 8 +- termios/speed.c | 18 ++-- termios/termios.h | 19 +++- 45 files changed, 404 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 b437cb53221c..366091e44696 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 @@ -1139,6 +1140,65 @@ 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 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}. +@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..00200bf9ee80 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -2688,3 +2688,8 @@ HURD_CTHREADS_0.3 __spin_lock_init F HURD_CTHREADS_0.3 __spin_lock_solid F HURD_CTHREADS_0.3 __spin_try_lock F HURD_CTHREADS_0.3 __spin_unlock F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/mach/hurd/x86_64/libc.abilist b/sysdeps/mach/hurd/x86_64/libc.abilist index 688ee26f4b25..1169bbf28100 100644 --- a/sysdeps/mach/hurd/x86_64/libc.abilist +++ b/sysdeps/mach/hurd/x86_64/libc.abilist @@ -2315,3 +2315,8 @@ HURD_CTHREADS_0.3 __spin_lock_init F HURD_CTHREADS_0.3 __spin_lock_solid F HURD_CTHREADS_0.3 __spin_try_lock F HURD_CTHREADS_0.3 __spin_unlock F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index be5979848d75..f7e5ae31ce8b 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2762,3 +2762,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index 1938691d3e08..694ffb237d33 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -3199,3 +3199,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist index b966a6c5473b..b68cc176f9d9 100644 --- a/sysdeps/unix/sysv/linux/arc/libc.abilist +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist @@ -2523,3 +2523,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist index 41cad7d2f263..98b3543ddc52 100644 --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist @@ -2888,3 +2888,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist index 5980a6bf38ca..46a27434eb8b 100644 --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist @@ -2885,3 +2885,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud 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 7ba2a41ce071..598597010f70 100644 --- a/sysdeps/unix/sysv/linux/csky/libc.abilist +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist @@ -2799,3 +2799,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index d0794db120a6..83be7c8536d5 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -2908,3 +2908,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index cda6dee18d42..ed3e6a1f9da2 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -3091,3 +3091,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist index f53381a6aff3..087bc4383b94 100644 --- a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist +++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist @@ -2283,3 +2283,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index 915973afae3c..b206786b090f 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -2867,3 +2867,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index ec6b185ae191..c1a9386e1c48 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -3034,3 +3034,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist index f1d5950cec1b..2c796e029218 100644 --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist @@ -2848,3 +2848,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist index 6d484626b7cf..1e78fce080e2 100644 --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist @@ -2845,3 +2845,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index 0606142e4f78..ed908a6d4442 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -2997,3 +2997,8 @@ GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 tcgetattr F GLIBC_2.42 tcsetattr F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist index 2b450cc0664e..2012985ebf88 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -2995,3 +2995,8 @@ GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 tcgetattr F GLIBC_2.42 tcsetattr F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index 106f4af7e061..dac4de52061c 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -3003,3 +3003,8 @@ GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 tcgetattr F GLIBC_2.42 tcsetattr F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index ce3ffc653b38..64e7805b9e87 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -2905,3 +2905,8 @@ GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 tcgetattr F GLIBC_2.42 tcsetattr F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist index a41b34ae99f1..4cff1b947251 100644 --- a/sysdeps/unix/sysv/linux/or1k/libc.abilist +++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist @@ -2273,3 +2273,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index affcbb09e073..bce86364d54c 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -3244,3 +3244,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index 2b67270c0aa4..8eb5743fe455 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -3289,3 +3289,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist index 7eb029874aee..74c33875138a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist @@ -2998,3 +2998,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist index deae41dedfd0..ad0a2f36c824 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist @@ -2982,3 +2982,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist index 8c007148c340..a5ee9dd04cc7 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist @@ -2526,3 +2526,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index f0f4a4673810..1d55458be678 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -2726,3 +2726,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index bb36c1db746c..a6f151a3a4a1 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -3256,3 +3256,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index a93e93a19507..9fce5100b511 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -3033,3 +3033,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist index 451f7f790f43..b6bc3f1941dd 100644 --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist @@ -2914,3 +2914,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist index bc8fd612a62e..dcc8edf6f677 100644 --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist @@ -2911,3 +2911,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index c80b9c10e3d9..bfb564c0a9bf 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -3263,3 +3263,8 @@ GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 tcgetattr F GLIBC_2.42 tcsetattr F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index a9acb136b310..7aa1c5e9e7e5 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -2881,3 +2881,8 @@ GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F GLIBC_2.42 tcgetattr F GLIBC_2.42 tcsetattr F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/speed.c b/sysdeps/unix/sysv/linux/speed.c index b954a19ba1e4..3d60d4e8f5da 100644 --- a/sysdeps/unix/sysv/linux/speed.c +++ b/sysdeps/unix/sysv/linux/speed.c @@ -246,6 +246,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. */ @@ -254,6 +255,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. */ @@ -267,6 +269,7 @@ __cfsetospeed (struct termios *termios_p, speed_t speed) termios_p->c_cflag |= cbaud; 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. */ @@ -281,6 +284,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 41f933aea188..0cd7b385647e 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -2830,3 +2830,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index 4623721bbe6d..7cfdba0dd5d4 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2777,3 +2777,8 @@ GLIBC_2.42 cfgetispeed F GLIBC_2.42 cfsetospeed F GLIBC_2.42 cfsetispeed F GLIBC_2.42 cfsetspeed F +GLIBC_2.42 cfgetobaud F +GLIBC_2.42 cfgetibaud F +GLIBC_2.42 cfsetobaud F +GLIBC_2.42 cfsetibaud F +GLIBC_2.42 cfsetbaud F diff --git a/termios/Makefile b/termios/Makefile index 08075424cb8a..d708e7f9508e 100644 --- a/termios/Makefile +++ b/termios/Makefile @@ -26,7 +26,8 @@ headers := termios.h bits/termios.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..2e14e6c3c4ff --- /dev/null +++ b/termios/baud.c @@ -0,0 +1,60 @@ +/* `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 + +#ifdef USE_OLD_TTY +#error "USE_OLD_TTY is not supported - does anyone actually care?" +#endif + +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..0b2991409d0e --- /dev/null +++ b/termios/cfsetbaud.c @@ -0,0 +1,33 @@ +/* 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 + +#ifdef USE_OLD_TTY +#error "USE_OLD_TTY is not supported - does anyone actually care?" +#endif + +/* 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 Sat Apr 26 02:55:38 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: 111072 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 A60D33857737 for ; Sat, 26 Apr 2025 03:04:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A60D33857737 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=BRWFTGs3 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail.zytor.com (unknown [IPv6:2607:7c80:54:3::138]) by sourceware.org (Postfix) with ESMTPS id 565563858280 for ; Sat, 26 Apr 2025 02:56:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 565563858280 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 565563858280 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:7c80:54:3::138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636162; cv=none; b=YL0fkk7Q6A0krhlts/EOdcKLML1WQE2YZfKE6Y+Gm5XMoguO6QTcEOGII33ExRCbSRhP2bJZI26lfoSCOxV0uEkfcNU3mLjdIeLmdetv7qnY/DuMSBYRTJvpedtJmgi7aMVjDPHtM70d1O/SJIWYGsp851SXFthjuV+IXhn5+3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1745636162; c=relaxed/simple; bh=Ue+rlmlQj/eJUq+tE6VNTst5VF2f1wfmjU14Lhmmi6o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sScCjiI4hsLBiM2YdC2D3aL3UOcMUK+7CXuX/fEGaYA2P9V7XcSUejPoMS73pqFQR7kA7c9XtYvaA/6WHoSmsYFWVvEo5tAhc9/GE7zkYVyxBjNxw0GhHNyD9Z4t8ocvlf6/bCf7fnl3vHdUyrHtn/wSXZr/4dHzqb8aw0A2/pI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 565563858280 Received: from carbon-x1.hos.anvin.org ([IPv6:2601:646:8081:1f93:3f9b:137e:d2cb:73f7]) (authenticated bits=0) by mail.zytor.com (8.18.1/8.17.1) with ESMTPSA id 53Q2tj2s3756161 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 25 Apr 2025 19:55:57 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 53Q2tj2s3756161 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2025042001; t=1745636158; bh=ZZOeqjKwOUEmSXfGci1LJom5Hq/bEC77mm242oxgPMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BRWFTGs3QeXqwQBlqw/ImNiSwqFb2oa3I9AkIx77jYZVp2aO7w/bSwEGZoudZtS9M RDgiWFneqte3gwOqQWdiSNPmaBImvoLdt00y3FiPHN/Hodqyuw8S9WCsK2FCUiielV pQpDkssso3Ru659Y8dC1CmV2M35wwrT8EpIL73my26tMgPUI20DC/njmLDaAYb6nH3 wGskrycWrVBeearxCyoQWQe3EJsp9tcz4FYUXlBFnwcsGGlPHTTn5sbK3fLL/K+2jK Bu4BNC71kJQgJSsguPtL5D+Timz27XfFn7B5B1MgYfOl/ZbcPewu0MciiZyy182AYX 3UP36JMZ02ecA== From: "H. Peter Anvin" To: libc-alpha@sourceware.org, Florian Weimer , Andreas Schwab Cc: "H . J . Lu" , hpa@zytor.com Subject: [RFC PATCH v2 8/8] hurd/termios: remove USE_OLD_TTY Date: Fri, 25 Apr 2025 19:55:38 -0700 Message-ID: <20250426025538.771862-9-hpa@zytor.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250426025538.771862-1-hpa@zytor.com> References: <20250426025538.771862-1-hpa@zytor.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 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. Signed-off-by: H. Peter Anvin (Intel) --- sysdeps/mach/hurd/bits/ioctls.h | 32 ++------------------------------ termios/baud.c | 4 ---- termios/cfsetbaud.c | 4 ---- termios/sys/ttychars.h | 4 ---- 4 files changed, 2 insertions(+), 42 deletions(-) diff --git a/sysdeps/mach/hurd/bits/ioctls.h b/sysdeps/mach/hurd/bits/ioctls.h index f01316dbc603..594b186990e0 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 */ @@ -412,25 +405,4 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; #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/baud.c b/termios/baud.c index 2e14e6c3c4ff..27c06e937fdb 100644 --- a/termios/baud.c +++ b/termios/baud.c @@ -23,10 +23,6 @@ #include #include -#ifdef USE_OLD_TTY -#error "USE_OLD_TTY is not supported - does anyone actually care?" -#endif - baud_t __cfgetobaud (const struct termios *termios_p) { diff --git a/termios/cfsetbaud.c b/termios/cfsetbaud.c index 0b2991409d0e..b76b51e4dd77 100644 --- a/termios/cfsetbaud.c +++ b/termios/cfsetbaud.c @@ -19,10 +19,6 @@ #include #include -#ifdef USE_OLD_TTY -#error "USE_OLD_TTY is not supported - does anyone actually care?" -#endif - /* Set both the input and output baud rates stored in *TERMIOS_P to BAUD. */ int __cfsetbaud (struct termios *termios_p, baud_t baud) 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 */