From: "Maciej W. Rozycki" <macro@orcam.me.uk>
To: sunilkumar.dora@windriver.com
Cc: gdb-patches@sourceware.org, Kevin Buettner <kevinb@redhat.com>,
Randy.MacLeod@windriver.com, Sundeep.Kokkonda@windriver.com,
schwab@linux-m68k.org, tromey@sourceware.org,
Simon Marchi <simark@simark.ca>
Subject: Re: [PATCH V3] PR gdb/33747: gdb/ser-unix: modernize Linux custom baud rate support
Date: Fri, 20 Mar 2026 01:24:40 +0000 (GMT) [thread overview]
Message-ID: <alpine.DEB.2.21.2603200048280.1878@angie.orcam.me.uk> (raw)
In-Reply-To: <20260312210106.880833-1-sunilkumar.dora@windriver.com>
On Thu, 12 Mar 2026, sunilkumar.dora@windriver.com wrote:
> diff --git a/gdb/ser-unix.c b/gdb/ser-unix.c
> index c295a9c5ba1..a15f4cc2162 100644
> --- a/gdb/ser-unix.c
> +++ b/gdb/ser-unix.c
> @@ -510,36 +510,59 @@ set_baudcode_baudrate (struct serial *scb, int baud_code)
>
> #if HAVE_CUSTOM_BAUDRATE_SUPPORT && defined(BOTHER)
>
> -/* Set a custom baud rate using the termios BOTHER. */
> +/* Set a custom baud rate.
> +
> + Prefer the POSIX cfsetispeed/cfsetospeed interface when it accepts
> + arbitrary baud rates. Otherwise fall back to Linux-specific termios2
> + (BOTHER) or legacy termios interfaces. */
>
> static void
> set_custom_baudrate_linux (int fd, int rate)
> {
> -#ifdef TCGETS2
> - struct termios2 tio;
> - const unsigned long req_get = TCGETS2;
> - const unsigned long req_set = TCSETS2;
> -#else
> +#if defined(HAVE_CFSETSPEED_ARBITRARY)
> struct termios tio;
> - const unsigned long req_get = TCGETS;
> - const unsigned long req_set = TCSETS;
> -#endif
> + if (tcgetattr (fd, &tio) < 0)
> + perror_with_name (_("Cannot get current baud rate"));
> +
> + cfsetispeed (&tio, rate);
> + cfsetospeed (&tio, rate);
> +
> + if (tcsetattr (fd, TCSANOW, &tio) < 0)
> + perror_with_name (_("Cannot set custom baud rate"));
It doesn't appear to me this code should be wrapped in:
#if ... && defined(BOTHER)
or for that matter be a part of `set_custom_baudrate_linux' (which AFAICT
should be left alone, or please point me at what actually you have changed
there that is not pure code massaging) as this is now platform-agnostic
(and I believe GNU Hurd has always supported arbitrary baud rates using
this interface). I'm leaving it up to you to come up with a name for this
new variant of the function.
Also ISTM that HAVE_CUSTOM_BAUDRATE_SUPPORT now also needs to be set if
HAVE_CFSETSPEED_ARBITRARY rather than relying on BOTHER to be defined as
well, which may not necessarily be the case (cf. GNU Hurd again).
> +#else
> + error (_("Custom baud rate not supported on this platform"));
> +#endif
This shouldn't be needed as this code is not supposed to be ever compiled
if !HAVE_CUSTOM_BAUDRATE_SUPPORT (IOW don't set the macro instead if the
conditions required are not met).
Maciej
next prev parent reply other threads:[~2026-03-20 1:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 21:01 sunilkumar.dora
2026-03-19 22:44 ` Kevin Buettner
2026-03-22 19:49 ` Sunil Kumar Dora
2026-03-20 1:24 ` Maciej W. Rozycki [this message]
2026-03-22 19:55 ` Sunil Kumar Dora
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.21.2603200048280.1878@angie.orcam.me.uk \
--to=macro@orcam.me.uk \
--cc=Randy.MacLeod@windriver.com \
--cc=Sundeep.Kokkonda@windriver.com \
--cc=gdb-patches@sourceware.org \
--cc=kevinb@redhat.com \
--cc=schwab@linux-m68k.org \
--cc=simark@simark.ca \
--cc=sunilkumar.dora@windriver.com \
--cc=tromey@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox