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