diff options
author | H. Peter Anvin <hpa@zytor.com> | 2002-08-15 07:02:01 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2002-08-15 07:02:01 +0000 |
commit | 21d243929559c0f1711bfef02defe023394a823e (patch) | |
tree | 963dabfa6a1670f343489694bbd95912e3ca5d68 | |
parent | 22c4e36ce45d60b9c8f40869100822b390de2c6e (diff) | |
download | klibc-21d243929559c0f1711bfef02defe023394a823e.tar.gz |
Add support for <termios.h> as a bunch of inline wrappers around ioctl()klibc-0.39
-rw-r--r-- | include/sys/ioctl.h | 1 | ||||
-rw-r--r-- | include/termios.h | 60 | ||||
-rw-r--r-- | klibc/include/sys/ioctl.h | 1 | ||||
-rw-r--r-- | klibc/include/termios.h | 60 |
4 files changed, 122 insertions, 0 deletions
diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h index 9d647bfe802ba..b0cee4c02c91b 100644 --- a/include/sys/ioctl.h +++ b/include/sys/ioctl.h @@ -7,6 +7,7 @@ #include <klibc/extern.h> #include <linux/ioctl.h> +#include <asm/ioctls.h> __extern int ioctl(int, int, void *); diff --git a/include/termios.h b/include/termios.h new file mode 100644 index 0000000000000..b6d72b729c519 --- /dev/null +++ b/include/termios.h @@ -0,0 +1,60 @@ +/* + * termios.h + */ + +#ifndef _TERMIOS_H +#define _TERMIOS_H + +#include <extern.h> +#include <stdint.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <linux/termios.h> + +/* Redefine these so the magic constants == the ioctl number to use. */ +#undef TCSANOW +#undef TCSADRAIN +#undef TCSAFLUSH +#define TCSANOW TCSETS +#define TCSADRAIN TCSETSW +#define TCSAFLUSH TCSETSF + +static __inline__ int tcgetattr(int __fd, struct termios *__s) +{ + return ioctl(__fd, TCGETS, (void *)__s); +} + +static __inline__ int tcsetattr(int __fd, int __opt, const struct termios *__s) +{ + return ioctl(__fd, __opt, __s); +} + +static __inline__ int tcflush(int __fd, int __queue) +{ + return ioctl(__fd, TCFLSH, (void *)(uintptr_t)__queue); +} + +static __inline__ pid_t tcgetpgrp(int __fd) +{ + pid_t __p; + return ioctl(__fd, TIOCGPGRP, &__p) ? (pid_t)-1 : __p; +} + +static __inline__ pid_t tcgetsid(int __fd) +{ + pid_t __p; + return ioctl(__fd, TIOCGSID, &__p) ? (pid_t)-1 : __p; +} + +static __inline__ int tcsendbreak(int __fd, int __duration) +{ + return ioctl(__fd, TCSBRKP, (void *)(uintptr_t)__duration); +} + +static __inline__ int tcsetpgrp(int __fd, pid_t __p) +{ + return ioctl(__fd, TIOCSPGRP, &__p); +} + + +#endif /* _TERMIOS_H */ diff --git a/klibc/include/sys/ioctl.h b/klibc/include/sys/ioctl.h index 9d647bfe802ba..b0cee4c02c91b 100644 --- a/klibc/include/sys/ioctl.h +++ b/klibc/include/sys/ioctl.h @@ -7,6 +7,7 @@ #include <klibc/extern.h> #include <linux/ioctl.h> +#include <asm/ioctls.h> __extern int ioctl(int, int, void *); diff --git a/klibc/include/termios.h b/klibc/include/termios.h new file mode 100644 index 0000000000000..b6d72b729c519 --- /dev/null +++ b/klibc/include/termios.h @@ -0,0 +1,60 @@ +/* + * termios.h + */ + +#ifndef _TERMIOS_H +#define _TERMIOS_H + +#include <extern.h> +#include <stdint.h> +#include <sys/ioctl.h> +#include <sys/types.h> +#include <linux/termios.h> + +/* Redefine these so the magic constants == the ioctl number to use. */ +#undef TCSANOW +#undef TCSADRAIN +#undef TCSAFLUSH +#define TCSANOW TCSETS +#define TCSADRAIN TCSETSW +#define TCSAFLUSH TCSETSF + +static __inline__ int tcgetattr(int __fd, struct termios *__s) +{ + return ioctl(__fd, TCGETS, (void *)__s); +} + +static __inline__ int tcsetattr(int __fd, int __opt, const struct termios *__s) +{ + return ioctl(__fd, __opt, __s); +} + +static __inline__ int tcflush(int __fd, int __queue) +{ + return ioctl(__fd, TCFLSH, (void *)(uintptr_t)__queue); +} + +static __inline__ pid_t tcgetpgrp(int __fd) +{ + pid_t __p; + return ioctl(__fd, TIOCGPGRP, &__p) ? (pid_t)-1 : __p; +} + +static __inline__ pid_t tcgetsid(int __fd) +{ + pid_t __p; + return ioctl(__fd, TIOCGSID, &__p) ? (pid_t)-1 : __p; +} + +static __inline__ int tcsendbreak(int __fd, int __duration) +{ + return ioctl(__fd, TCSBRKP, (void *)(uintptr_t)__duration); +} + +static __inline__ int tcsetpgrp(int __fd, pid_t __p) +{ + return ioctl(__fd, TIOCSPGRP, &__p); +} + + +#endif /* _TERMIOS_H */ |