chiark / gitweb /
[PATCH] added klibc version 0.82 (cvs tree) to the udev tree.
[elogind.git] / klibc / klibc / include / termios.h
1 /*
2  * termios.h
3  */
4
5 #ifndef _TERMIOS_H
6 #define _TERMIOS_H
7
8 #include <klibc/extern.h>
9 #include <stdint.h>
10 #include <sys/ioctl.h>
11 #include <sys/types.h>
12 #include <linux/termios.h>
13
14 /* Redefine these so the magic constants == the ioctl number to use. */
15 #undef TCSANOW
16 #undef TCSADRAIN
17 #undef TCSAFLUSH
18 #define TCSANOW    TCSETS
19 #define TCSADRAIN  TCSETSW
20 #define TCSAFLUSH  TCSETSF
21
22 static __inline__ int tcgetattr(int __fd, struct termios *__s)
23 {
24   return ioctl(__fd, TCGETS, __s);
25 }
26
27 static __inline__ int tcsetattr(int __fd, int __opt, const struct termios *__s)
28 {
29   return ioctl(__fd, __opt, (void *)__s);
30 }
31
32 static __inline__ int tcflow(int __fd, int __action)
33 {
34   return ioctl(__fd, TCXONC, (void *)(intptr_t)__action);
35 }
36
37 static __inline__ int tcflush(int __fd, int __queue)
38 {
39   return ioctl(__fd, TCFLSH, (void *)(intptr_t)__queue);
40 }
41
42 static __inline__ pid_t tcgetpgrp(int __fd)
43 {
44   pid_t __p;
45   return ioctl(__fd, TIOCGPGRP, &__p) ? (pid_t)-1 : __p;
46 }
47
48 static __inline__ pid_t tcgetsid(int __fd)
49 {
50   pid_t __p;
51   return ioctl(__fd, TIOCGSID, &__p) ? (pid_t)-1 : __p;
52 }  
53
54 static __inline__ int tcsendbreak(int __fd, int __duration)
55 {
56   return ioctl(__fd, TCSBRKP, (void *)(uintptr_t)__duration);
57 }
58
59 static __inline__ int tcsetpgrp(int __fd, pid_t __p)
60 {
61   return ioctl(__fd, TIOCSPGRP, &__p);
62 }
63
64 static __inline__ speed_t cfgetospeed(const struct termios *__s)
65 {
66   return (speed_t)(__s->c_cflag & CBAUD);
67 }
68
69 static __inline__ speed_t cfgetispeed(const struct termios *__s)
70 {
71   return (speed_t)(__s->c_cflag & CBAUD);
72 }
73
74 static __inline__ int cfsetospeed(struct termios *__s, speed_t __v)
75 {
76   __s->c_cflag = (__s->c_cflag & ~CBAUD) | (__v & CBAUD);
77   return 0;
78 }
79
80 static __inline__ int cfsetispeed(struct termios *__s, speed_t __v)
81 {
82   __s->c_cflag = (__s->c_cflag & ~CBAUD) | (__v & CBAUD);
83   return 0;
84 }
85
86 #endif /* _TERMIOS_H */