This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] Linux: Define struct termios2 in <termios.h> under _GNU_SOURCE [BZ #10339]
- From: Zack Weinberg <zackw at panix dot com>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 9 Apr 2019 12:24:55 -0400
- Subject: Re: [PATCH] Linux: Define struct termios2 in <termios.h> under _GNU_SOURCE [BZ #10339]
- References: <firstname.lastname@example.org>
On Tue, Apr 9, 2019 at 6:48 AM Florian Weimer <email@example.com> wrote:
> struct termios2 is required for setting arbitrary baud rates on serial
> ports. <sys/ioctl.h> and <linux/termios.h> have conflicting
> definitions in the existing termios definitions, which means that it
> is currently very difficult to use TCGETS2/TCSETS2 and struct termios2
> with glibc. Providing a definition within glibc resolves this problem.
This seems like a reasonable approach, but I am not familiar with
termios-related issues so this is not a full review. I have one
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/alpha/bits/termios2-struct.h
> @@ -0,0 +1,33 @@
> +/* struct termios2 definition. Linux/alpha version.
> + Copyright (C) 2019 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
> + <http://www.gnu.org/licenses/>. */
> +#ifndef _TERMIOS_H
> +# error "Never include <bits/termios2-struct.h> directly; use <termios.h> instead."
All new installed headers should have multiple inclusion guards, even
if they are bits headers only intended to be included by one parent
header. This removes noise from the "Multiple include guards may be
useful for:" diagnostic produced by gcc -H, and prevents e.g.
from spewing unhelpful errors (yes, the above is incorrect, but we
should still try to avoid diagnostic spew).