entered into RCS

This commit is contained in:
Roland McGrath 1993-05-06 23:29:21 +00:00
parent 7ebb6b1f3c
commit 4f65119178
2 changed files with 31 additions and 4 deletions

View File

@ -47,14 +47,14 @@ static CONST speed_t speeds[] =
speed_t
DEFUN(cfgetospeed, (termios_p), CONST struct termios *termios_p)
{
return speeds[termios_p->c_cflag & CBAUD];
return termios_p->c_cflag & CBAUD;
}
/* Return the input baud rate stored in *TERMIOS_P. */
speed_t
DEFUN(cfgetispeed, (termios_p), CONST struct termios *termios_p)
{
return speeds[(termios_p->c_cflag & CIBAUD) >> IBSHIFT];
return (termios_p->c_cflag & CIBAUD) >> IBSHIFT;
}
/* Set the output baud rate stored in *TERMIOS_P to SPEED. */
@ -70,8 +70,12 @@ DEFUN(cfsetospeed, (termios_p, speed),
return -1;
}
/* This allows either B1200 or 1200 to work. XXX
Do we really want to try to support this, given that
fetching the speed must return one or the other? */
for (i = 0; i < sizeof (speeds) / sizeof (speeds[0]); ++i)
if (speeds[i] == speed)
if (i == speed || speeds[i] == speed)
{
termios_p->c_cflag &= ~CBAUD;
termios_p->c_cflag |= i;
@ -95,8 +99,9 @@ DEFUN(cfsetispeed, (termios_p, speed),
return -1;
}
/* See comment in cfsetospeed (above). */
for (i = 0; i < sizeof (speeds) / sizeof (speeds[0]); ++i)
if (speeds[i] == speed)
if (i == speed || speeds[i] == speed)
{
termios_p->c_cflag &= ~CIBAUD;
termios_p->c_cflag |= i << IBSHIFT;

View File

@ -107,6 +107,28 @@ struct termios
#define CIBAUD 0x000f0000 /* Mask for input speed from c_cflag. */
#define CBAUD 0x0000000f /* Mask for output speed from c_cflag. */
#define IBSHIFT 16 /* Bits to shift for input speed. */
#endif
/* Input and output baud rates. These are encoded in c_cflag. */
#define B0 0
#define B50 1
#define B75 2
#define B110 3
#define B134 4
#define B150 5
#define B200 6
#define B300 7
#define B600 8
#define B1200 9
#define B1800 10
#define B2400 11
#define B4800 12
#define B9600 13
#define B19200 14
#define B38400 15
#ifdef __USE_BSD
#define EXTA 14
#define EXTB 15
#endif
/* Local modes. */