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