8 #include <klibc/extern.h>
10 #include <sys/ioctl.h>
11 #include <sys/types.h>
12 #include <linux/termios.h>
14 /* Redefine these so the magic constants == the ioctl number to use. */
18 #define TCSANOW TCSETS
19 #define TCSADRAIN TCSETSW
20 #define TCSAFLUSH TCSETSF
22 static __inline__ int tcgetattr(int __fd, struct termios *__s)
24 return ioctl(__fd, TCGETS, __s);
27 static __inline__ int tcsetattr(int __fd, int __opt, const struct termios *__s)
29 return ioctl(__fd, __opt, (void *)__s);
32 static __inline__ int tcflow(int __fd, int __action)
34 return ioctl(__fd, TCXONC, (void *)(intptr_t)__action);
37 static __inline__ int tcflush(int __fd, int __queue)
39 return ioctl(__fd, TCFLSH, (void *)(intptr_t)__queue);
42 static __inline__ pid_t tcgetpgrp(int __fd)
45 return ioctl(__fd, TIOCGPGRP, &__p) ? (pid_t)-1 : __p;
48 static __inline__ pid_t tcgetsid(int __fd)
51 return ioctl(__fd, TIOCGSID, &__p) ? (pid_t)-1 : __p;
54 static __inline__ int tcsendbreak(int __fd, int __duration)
56 return ioctl(__fd, TCSBRKP, (void *)(uintptr_t)__duration);
59 static __inline__ int tcsetpgrp(int __fd, pid_t __p)
61 return ioctl(__fd, TIOCSPGRP, &__p);
64 static __inline__ speed_t cfgetospeed(const struct termios *__s)
66 return (speed_t)(__s->c_cflag & CBAUD);
69 static __inline__ speed_t cfgetispeed(const struct termios *__s)
71 return (speed_t)(__s->c_cflag & CBAUD);
74 static __inline__ int cfsetospeed(struct termios *__s, speed_t __v)
76 __s->c_cflag = (__s->c_cflag & ~CBAUD) | (__v & CBAUD);
80 static __inline__ int cfsetispeed(struct termios *__s, speed_t __v)
82 __s->c_cflag = (__s->c_cflag & ~CBAUD) | (__v & CBAUD);
86 #endif /* _TERMIOS_H */