From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2WOTA4fLwWnyRTYAWB0awg (envelope-from ) for ; Mon, 23 Mar 2026 19:23:51 -0400 Received: by simark.ca (Postfix, from userid 112) id 0BA9D1E08C; Mon, 23 Mar 2026 19:23:51 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 661FA1E08C for ; Mon, 23 Mar 2026 19:23:50 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id E25434BB3BE9 for ; Mon, 23 Mar 2026 23:23:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E25434BB3BE9 Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by sourceware.org (Postfix) with ESMTP id 7A6944B9DB64; Mon, 23 Mar 2026 23:23:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A6944B9DB64 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=orcam.me.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7A6944B9DB64 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=78.133.224.34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774308206; cv=none; b=aoSIvwtSLcN33Xog9Dzhoo+5MBBsayEOzN7IaPDiVmkP/o+quVdBWB6nCiBd8X/STnHYRh8RoHFvUOiF9kgbPzynW1LBT2r+ciHybmwx5SchUMAP/+NTQ+FDDH2pZassTQeLoeZjjXcFiyu4RjM7AjrPxNpUNp9vhK3mFqQB0Io= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1774308206; c=relaxed/simple; bh=8uzAJeJCgOBi1P2Iq78GnMJsYI2OhsGpVvL9/ajb4hs=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=i6CblJ/z9xhBML3fjLuZD0TUCKpdbJJImyjNOGmO+Nentj2VeX57k6lvbUmruhlZrbLWq9TrOxCOaLpYedpTZ0pVjt9KrapWM9Hf+R8Jd57CL9ppz1auzN66malKDk4ldaS0zmx0BPgqJfSz2h8VM+sx4NXPpBYFPkibt0jKkKY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A6944B9DB64 Received: by angie.orcam.me.uk (Postfix, from userid 500) id 7DD2E92009C; Tue, 24 Mar 2026 00:23:25 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id 7B79D92009B; Mon, 23 Mar 2026 23:23:25 +0000 (GMT) Date: Mon, 23 Mar 2026 23:23:25 +0000 (GMT) From: "Maciej W. Rozycki" To: sunilkumar.dora@windriver.com cc: gdb-patches@sourceware.org, Kevin Buettner , Randy.MacLeod@windriver.com, Sundeep.Kokkonda@windriver.com, schwab@linux-m68k.org, tromey@sourceware.org, Simon Marchi Subject: Re: [PATCH V4] PR gdb/33747: gdb/ser-unix: modernize and fix custom baud rate support on musl In-Reply-To: <20260323112746.2332070-1-sunilkumar.dora@windriver.com> Message-ID: References: <20260323112746.2332070-1-sunilkumar.dora@windriver.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On Mon, 23 Mar 2026, sunilkumar.dora@windriver.com wrote: > Fix this at the macro level by requiring HAVE_STRUCT_TERMIOS_C_OSPEED > alongside BOTHER in the HAVE_CUSTOM_BAUDRATE_SUPPORT guard. This > prevents the Linux-specific path from being compiled on systems where > the required fields are unavailable, leaving set_custom_baudrate_linux() > unchanged. The GNU coding style avoids using parentheses in documentation references to functions except for actual function calls with no arguments. > This interface is supported by glibc 2.42 and later and is expected to > be standardized by a future POSIX revision. It also covers systems > such as GNU Hurd that do not provide BOTHER. Return values from > cfsetispeed() and cfsetospeed() are checked, and errors are reported > via perror_with_name(). Same here. > diff --git a/gdb/configure.ac b/gdb/configure.ac > index cf8078e1d89..e558cf44703 100644 > --- a/gdb/configure.ac > +++ b/gdb/configure.ac > @@ -725,6 +725,28 @@ AC_CONFIG_FILES([jit-reader.h:jit-reader.in]) > > AC_SEARCH_LIBS(dlopen, dl) > > +# Check whether cfsetispeed/cfsetospeed accept arbitrary baud rates. > +AC_CACHE_CHECK([whether cfsetispeed/cfsetospeed accept arbitrary baud rates], > + [gdb_cv_cfsetspeed_arbitrary], [ > + AC_COMPILE_IFELSE( > + [AC_LANG_PROGRAM([[#include ]], > + [[ > + #if B9600 != 9600 > + #error B-constants are not numeric symbols > + #endif > + ]])], > + [gdb_cv_cfsetspeed_arbitrary=yes], > + [gdb_cv_cfsetspeed_arbitrary=no]) > +]) > + > +if test "$gdb_cv_cfsetspeed_arbitrary" = yes; then > + AC_DEFINE([HAVE_CFSETSPEED_ARBITRARY], [1], > + [Define if cfsetispeed/cfsetospeed accept arbitrary baud rates]) Missing full stop in the description. > diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c > index c295a9c5ba1..0a6cdf0f630 100644 > --- a/gdb/ser-unix.c > +++ b/gdb/ser-unix.c > @@ -55,7 +55,10 @@ > > #include "gdbsupport/scoped_ignore_sigttou.h" > > -#if defined(HAVE_SYS_IOCTL_H) && (defined(BOTHER) || defined(IOSSIOSPEED)) > +#if defined(HAVE_CFSETSPEED_ARBITRARY) || \ > + (defined(HAVE_SYS_IOCTL_H) && \ > + ((defined(BOTHER) && defined(HAVE_STRUCT_TERMIOS_C_OSPEED)) || \ > + defined(IOSSIOSPEED))) The GNU coding style is to have lines split before an operator, and extra parentheses added where necessary for the indentation to show nesting, i.e.: #if (defined(HAVE_CFSETSPEED_ARBITRARY) \ || (defined(HAVE_SYS_IOCTL_H) \ && ((defined(BOTHER) && defined(HAVE_STRUCT_TERMIOS_C_OSPEED)) \ || defined(IOSSIOSPEED)))) > @@ -508,6 +511,33 @@ set_baudcode_baudrate (struct serial *scb, int baud_code) > perror_with_name (_("could not set tty state")); > } > > +#if defined(HAVE_CFSETSPEED_ARBITRARY) Please make it consistent with the existing convention, so: #if HAVE_CUSTOM_BAUDRATE_SUPPORT && defined(HAVE_CFSETSPEED_ARBITRARY) ... > + > +/* Set a custom baud rate using the POSIX cfsetispeed/cfsetospeed > + interface. Supported in glibc 2.42+ and expected to be > + standardized in a future POSIX revision. It is platform-agnostic > + and also covers systems like GNU Hurd that do not provide BOTHER. */ > + > +static void > +set_custom_baudrate_posix (int fd, int rate) > +{ > + struct termios tio; > + > + if (tcgetattr (fd, &tio) < 0) > + perror_with_name (_("Can not get current baud rate")); > + > + if (cfsetispeed (&tio, rate) < 0) > + perror_with_name (_("Can not set custom input baud rate")); > + > + if (cfsetospeed (&tio, rate) < 0) > + perror_with_name (_("Can not set custom output baud rate")); > + > + if (tcsetattr (fd, TCSANOW, &tio) < 0) > + perror_with_name (_("Can not set custom baud rate")); > +} > + > +#endif /* HAVE_CFSETSPEED_ARBITRARY */ > + > #if HAVE_CUSTOM_BAUDRATE_SUPPORT && defined(BOTHER) ... and then: #elif HAVE_CUSTOM_BAUDRATE_SUPPORT && defined(BOTHER) (and then update the comment for the trailing #endif accordingly). I think it would best be done as two separate changes in a small patch series, first to fix the compilation error with musl, and second to add the POSIX interface, so that each is a self-contained feature. Maciej