From 4f65119178303987f78ad0a118a2fc87486b2302 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 6 May 1993 23:29:21 +0000 Subject: [PATCH] entered into RCS --- sysdeps/unix/bsd/sun/sunos4/speed.c | 13 +++++++++---- sysdeps/unix/bsd/sun/sunos4/termbits.h | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/sysdeps/unix/bsd/sun/sunos4/speed.c b/sysdeps/unix/bsd/sun/sunos4/speed.c index ce14479359..1c09d55dab 100644 --- a/sysdeps/unix/bsd/sun/sunos4/speed.c +++ b/sysdeps/unix/bsd/sun/sunos4/speed.c @@ -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; diff --git a/sysdeps/unix/bsd/sun/sunos4/termbits.h b/sysdeps/unix/bsd/sun/sunos4/termbits.h index b8e9cd9a17..01ab4d7874 100644 --- a/sysdeps/unix/bsd/sun/sunos4/termbits.h +++ b/sysdeps/unix/bsd/sun/sunos4/termbits.h @@ -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. */