Re: [PATCH v5.2 11/12] termios: unify the naming of the termios speed fields

H. Peter Anvin hpa@zytor.com
Thu May 29 19:21:24 GMT 2025


On May 29, 2025 11:57:00 AM PDT, Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> wrote:
>
>
>On 27/05/25 19:08, H. Peter Anvin wrote:
>> The generic code has __ispeed and __ospeed; Linux has c_ispeed and
>> c_ospeed. Use an anonymous union member to allow both set of names on
>> all platforms.
>> 
>> Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
>> ---
>>  bits/termios.h                                | 11 +++++++-
>>  sysdeps/unix/sysv/linux/bits/termios-struct.h | 28 ++++++++++++-------
>>  2 files changed, 28 insertions(+), 11 deletions(-)
>> 
>> diff --git a/bits/termios.h b/bits/termios.h
>> index 8f0b817dbf4c..798012cb8ebc 100644
>> --- a/bits/termios.h
>> +++ b/bits/termios.h
>> @@ -286,7 +286,16 @@ struct termios
>>    cc_t c_cc[NCCS];
>>  
>>    /* Input and output baud rates.  */
>> -  speed_t __ispeed, __ospeed;
>> +  __extension__ union {
>> +    speed_t __ispeed;
>> +    speed_t c_ispeed;
>> +  };
>> +#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
>> +  __extension__ union {
>> +    speed_t __ospeed;
>> +    speed_t c_ospeed;
>> +  };
>> +#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
>>  };
>>  
>>  #define _IOT_termios /* Hurd ioctl type field.  */ \
>> diff --git a/sysdeps/unix/sysv/linux/bits/termios-struct.h b/sysdeps/unix/sysv/linux/bits/termios-struct.h
>> index d7167dfa20c8..3e33d81df047 100644
>> --- a/sysdeps/unix/sysv/linux/bits/termios-struct.h
>> +++ b/sysdeps/unix/sysv/linux/bits/termios-struct.h
>> @@ -22,15 +22,23 @@
>>  
>>  #define NCCS 32
>>  struct termios
>> -  {
>> -    tcflag_t c_iflag;		/* input mode flags */
>> -    tcflag_t c_oflag;		/* output mode flags */
>> -    tcflag_t c_cflag;		/* control mode flags */
>> -    tcflag_t c_lflag;		/* local mode flags */
>> -    cc_t c_line;		/* line discipline */
>> -    cc_t c_cc[NCCS];		/* control characters */
>> -    speed_t c_ispeed;		/* input speed */
>> -    speed_t c_ospeed;		/* output speed */
>> +{
>> +  tcflag_t c_iflag;		/* input mode flags */
>> +  tcflag_t c_oflag;		/* output mode flags */
>> +  tcflag_t c_cflag;		/* control mode flags */
>> +  tcflag_t c_lflag;		/* local mode flags */
>
>These indentation change seems unnecessary, maybe only add the 
>__ispeed/c_ispeed change.
>
>
>> +  cc_t c_line;			/* line discipline */
>> +  cc_t c_cc[NCCS];		/* control characters */
>> +
>> +  /* Input and output baud rates.  */
>> +  __extension__ union {
>> +    speed_t __ispeed;
>> +    speed_t c_ispeed;
>> +  };
>>  #define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
>> -#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
>> +  __extension__ union {
>> +    speed_t __ospeed;
>> +    speed_t c_ospeed;
>>    };
>> +#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
>> +};
>

Ah yes, that hunk was supposed to have been folded into a previous patch. Will fix.


More information about the Libc-alpha mailing list