source: rtems/c/src/lib/libc/cfiospeed.c @ 119bced

4.104.114.84.95
Last change on this file since 119bced was 119bced, checked in by Joel Sherrill <joel.sherrill@…>, on May 22, 1998 at 2:51:11 PM

Added tcdrain(), cfgetospeed(0, cfsetospeed(), cfgetispeed(), and
cfsetispeed().

  • Property mode set to 100644
File size: 882 bytes
Line 
1/*
2 *  This file contains the RTEMS implementation of the POSIX API
3 *  routines cfgetispeed, cfgetospeed, cfsetispeed and cfsetospeed.
4 *
5 *  $Id$
6 *
7 */
8
9#include <rtems.h>
10#if defined(RTEMS_NEWLIB)
11
12#include <sys/types.h>
13#include <sys/stat.h>
14#include <errno.h>
15#include <termios.h>
16
17#include "internal.h"
18#include "libio.h"
19
20speed_t
21cfgetospeed(const struct termios *tp)
22{
23        return tp->c_cflag & CBAUD;
24}
25
26int
27cfsetospeed(struct termios *tp, speed_t speed)
28{
29        if (speed & ~CBAUD) {
30                errno = EINVAL;
31                return -1;
32        }
33        tp->c_cflag = (tp->c_cflag & ~CBAUD) | speed;
34        return 0;
35}
36
37speed_t
38cfgetispeed(const struct termios *tp)
39{
40        return (tp->c_cflag / (CIBAUD / CBAUD)) &  CBAUD;
41}
42
43int
44cfsetispeed(struct termios *tp, speed_t speed)
45{
46        if (speed & ~CBAUD) {
47                errno = EINVAL;
48                return -1;
49        }
50        tp->c_cflag = (tp->c_cflag & ~CBAUD) | (speed * (CIBAUD / CBAUD));
51        return 0;
52}
53
54#endif
Note: See TracBrowser for help on using the repository browser.