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