This is the mail archive of the libc-hacker@sourceware.cygnus.com 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]

Re: A termios path


hjl@lucon.org (H.J. Lu) writes:

> This patch for glibc 2.1 works around a Linux kernel bug, which I don't
> see any easy fix. Also
> 
> 	cfsetispeed (termios_p, (speed_t) 0)

I see this is a problem but the whole implementation in the kernel is
not suitable as it seems.  We can't independently set the input and
output speed therefore it does not make sense to remember setting the
input speed to zero means setting it to the same value as the output
speed.

I think the solution which makes most sense is to change the
cfsetispeed implementation to do nothing if the parameter is zero.
Nothing more.  This should solve the problem since it effectively
means the input speed is the output speed.

Can you try the test suite with this change?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Index: speed.c
===================================================================
RCS file: /glibc/cvsfiles/libc/sysdeps/unix/sysv/linux/speed.c,v
retrieving revision 1.6
diff -d -u -p -r1.6 speed.c
--- speed.c	1997/06/23 21:54:33	1.6
+++ speed.c	1998/12/07 21:18:03
@@ -1,5 +1,5 @@
 /* `struct termios' speed frobnication functions.  Linux version.
-   Copyright (C) 1991, 92, 93, 95, 96, 97 Free Software Foundation, Inc.
+   Copyright (C) 1991, 92, 93, 95, 96, 97, 98 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
@@ -54,5 +54,26 @@ cfsetospeed  (termios_p, speed)
 }
 
 /* Set the input baud rate stored in *TERMIOS_P to SPEED.
-   For Linux there is no difference between input and output speed.  */
-strong_alias (cfsetospeed, cfsetispeed);
+   Although for Linux there is no difference between input and output
+   speed, the numerical 0 is a special case for the input baud rate.  It
+   should set the input baud rate to the output baud rate.  */
+int
+cfsetispeed (termios_p, speed)
+     struct termios *termios_p;
+     speed_t speed;
+{
+  if ((speed & ~CBAUD) != 0
+      && (speed < B57600 || speed > B460800))
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  if (speed != 0)
+    {
+      termios_p->c_cflag &= ~(CBAUD | CBAUDEX);
+      termios_p->c_cflag |= speed;
+    }
+
+  return 0;
+}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

-- 
---------------.      drepper at gnu.org  ,-.   1325 Chesapeake Terrace
Ulrich Drepper  \    ,-------------------'   \  Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com   `------------------------


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