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