* cfsetspeed is not consistent with Linux
@ 2021-07-11 16:33 Ken Brown
2021-07-12 8:16 ` Corinna Vinschen
0 siblings, 1 reply; 2+ messages in thread
From: Ken Brown @ 2021-07-11 16:33 UTC (permalink / raw)
To: cygwin
While investigating an emacs bug
(https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49524), I noticed a difference in
the behavior of cfsetspeed(3) on Cygwin and Linux. I'm not sure we should "fix"
this, because Cygwin's behavior is consistent with the Linux man page, and
Linux's behavior is not. But I thought I should point it out for the sake of
discussion, because Cygwin generally tries to emulate Linux. Here are the details:
The Linux man page for cfsetspeed(3) specifies that the speed argument must be
one of the constants Bnnn (e.g., B9600) defined in termios.h. But Linux in fact
allows the speed to be the numerical baud rate (e.g., 9600). Test case:
$ cat cfsetspeed_test.c
#include <termios.h>
#include <stdio.h>
int
main ()
{
struct termios tp;
printf ("Calling cfsetspeed with speed B9600\n");
if (cfsetspeed (&tp, B9600) < 0)
perror ("cfsetspeed");
else
printf ("cfgetispeed reports speed %u\n", cfgetispeed (&tp));
printf ("Calling cfsetspeed with speed 9600\n");
if (cfsetspeed (&tp, 9600) < 0)
perror ("cfsetspeed");
else
printf ("cfgetispeed reports speed %u\n", cfgetispeed (&tp));
}
$ gcc cfsetspeed_test.c
$ ./a.out
Calling cfsetspeed with speed B9600
cfgetispeed reports speed 13
Calling cfsetspeed with speed 9600
cfgetispeed reports speed 13
On Cygwin, however, the output of the same program is:
$ ./a
Calling cfsetspeed with speed B9600
cfgetispeed reports speed 13
Calling cfsetspeed with speed 9600
cfsetspeed: Invalid argument
If we decide that Cygwin should emulate Linux here, it would be a simple matter
to copy the glibc code, which checks whether the speed is a numerical baud rate
and, if so, converts it to a Bnnn constant.
Ken
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: cfsetspeed is not consistent with Linux
2021-07-11 16:33 cfsetspeed is not consistent with Linux Ken Brown
@ 2021-07-12 8:16 ` Corinna Vinschen
0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2021-07-12 8:16 UTC (permalink / raw)
To: cygwin
On Jul 11 12:33, Ken Brown via Cygwin wrote:
> While investigating an emacs bug
> (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49524), I noticed a
> difference in the behavior of cfsetspeed(3) on Cygwin and Linux. I'm not
> sure we should "fix" this, because Cygwin's behavior is consistent with the
> Linux man page, and Linux's behavior is not. But I thought I should point
> it out for the sake of discussion, because Cygwin generally tries to emulate
> Linux. Here are the details:
>
> The Linux man page for cfsetspeed(3) specifies that the speed argument must
> be one of the constants Bnnn (e.g., B9600) defined in termios.h. But Linux
> in fact allows the speed to be the numerical baud rate (e.g., 9600). Test
> case:
> [...]
> $ ./a.out
> Calling cfsetspeed with speed B9600
> cfgetispeed reports speed 13
> Calling cfsetspeed with speed 9600
> cfgetispeed reports speed 13
>
> On Cygwin, however, the output of the same program is:
>
> $ ./a
> Calling cfsetspeed with speed B9600
> cfgetispeed reports speed 13
> Calling cfsetspeed with speed 9600
> cfsetspeed: Invalid argument
>
> If we decide that Cygwin should emulate Linux here, it would be a simple
> matter to copy the glibc code, which checks whether the speed is a numerical
> baud rate and, if so, converts it to a Bnnn constant.
We can do this too. For historical reasons we should stay careful
taking over other GPLed code into the Cygwin DLL itself, but just
copying the speed_struct struct should be fine.
Corinna
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-12 8:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-11 16:33 cfsetspeed is not consistent with Linux Ken Brown
2021-07-12 8:16 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).