cfsetospeed.c 395 B

12345678910111213141516171819202122
  1. #include <termios.h>
  2. #include <sys/ioctl.h>
  3. #include <errno.h>
  4. #include "libc.h"
  5. int cfsetospeed(struct termios *tio, speed_t speed)
  6. {
  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. int cfsetispeed(struct termios *tio, speed_t speed)
  16. {
  17. return speed ? cfsetospeed(tio, speed) : 0;
  18. }
  19. weak_alias(cfsetospeed, cfsetspeed);