b571f62e39cc132796174c89b8cfe4eae5f30ebf
[musl] / src / termios / cfsetospeed.c
1 #define _BSD_SOURCE
2 #include <termios.h>
3 #include <sys/ioctl.h>
4 #include <errno.h>
5 #include "libc.h"
6
7 int cfsetospeed(struct termios *tio, speed_t speed)
8 {
9         if (speed & ~CBAUD) {
10                 errno = EINVAL;
11                 return -1;
12         }
13         tio->c_cflag &= ~CBAUD;
14         tio->c_cflag |= speed;
15         return 0;
16 }
17
18 int cfsetispeed(struct termios *tio, speed_t speed)
19 {
20         return speed ? cfsetospeed(tio, speed) : 0;
21 }
22
23 weak_alias(cfsetospeed, cfsetspeed);