This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 02/12] termios: Consolidate struct termios



On 09/11/2018 11:43, Gabriel F. T. Gomes wrote:
> Hi, Adhemerval.  Could you help me with a doubt (below)?
> 
> On Mon, 15 Oct 2018, Adhemerval Zanella wrote:
> 
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/bits/termios-struct.h
>> [...]
>> +#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 */
>> +#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
>> +#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
>> +  };
> 
> The generic header will have c_line before c_cc.
> 
>> --- a/sysdeps/unix/sysv/linux/powerpc/bits/termios.h
>> +++ b/sysdeps/unix/sysv/linux/powerpc/bits/termios.h
>> [...]
>> -#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 (== c_cc[19]) */
>> -	cc_t c_cc[NCCS];		/* control characters */
>> -	speed_t c_ispeed;		/* input speed */
>> -	speed_t c_ospeed;		/* output speed */
>> -#define _HAVE_STRUCT_TERMIOS_C_ISPEED 1
>> -#define _HAVE_STRUCT_TERMIOS_C_OSPEED 1
>> -};
>> +#include <bits/termios-struct.h>
> 
> So does the powerpc-specific header.
> 
> As far as I can tell, your patch is doing the right thing, because it's
> not modifying what we currently have in glibc.
> 
> On the other hand, I just checked the source code for Linux [1] and these
> two lines are flipped.  This inconsistency between kernel and glibc looks
> weird...  Is this a bug in current glibc?
> 
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/include/uapi/asm/termbits.h#n16
> 

For termios we do not follow kernel userspace ABI, glibc defines both
input and output speed in termios structure and it differs from termios
kernel generic abi (include/uapi/asm-generic/termios.h).  In fact glibc
follows the termios2 struct definition for most architectures (although
we still issues ioctl using old API).

And we are stuck on current termios struct, so we can't change it unless
we add compatibility symbols. Which I think it is worth only if/when 
glibc start to use termios2 internally and only for architectures that
termios does not provide all information termios2 requires (sparc and
mips basically).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]