diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:54:38 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 13:54:38 +0000 |
commit | 8c1ab65c0f548d20b7f177bdb736daaf603340e1 (patch) | |
tree | df55b7e75bf43f2bf500845b105afe3ac3a5157e /libc-top-half/musl/src/termios | |
parent | Initial commit. (diff) | |
download | wasi-libc-8c1ab65c0f548d20b7f177bdb736daaf603340e1.tar.xz wasi-libc-8c1ab65c0f548d20b7f177bdb736daaf603340e1.zip |
Adding upstream version 0.0~git20221206.8b7148f.upstream/0.0_git20221206.8b7148f
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libc-top-half/musl/src/termios')
-rw-r--r-- | libc-top-half/musl/src/termios/cfgetospeed.c | 13 | ||||
-rw-r--r-- | libc-top-half/musl/src/termios/cfmakeraw.c | 13 | ||||
-rw-r--r-- | libc-top-half/musl/src/termios/cfsetospeed.c | 22 | ||||
-rw-r--r-- | libc-top-half/musl/src/termios/tcdrain.c | 8 | ||||
-rw-r--r-- | libc-top-half/musl/src/termios/tcflow.c | 7 | ||||
-rw-r--r-- | libc-top-half/musl/src/termios/tcflush.c | 7 | ||||
-rw-r--r-- | libc-top-half/musl/src/termios/tcgetattr.c | 9 | ||||
-rw-r--r-- | libc-top-half/musl/src/termios/tcgetsid.c | 10 | ||||
-rw-r--r-- | libc-top-half/musl/src/termios/tcgetwinsize.c | 8 | ||||
-rw-r--r-- | libc-top-half/musl/src/termios/tcsendbreak.c | 8 | ||||
-rw-r--r-- | libc-top-half/musl/src/termios/tcsetattr.c | 12 | ||||
-rw-r--r-- | libc-top-half/musl/src/termios/tcsetwinsize.c | 8 |
12 files changed, 125 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/termios/cfgetospeed.c b/libc-top-half/musl/src/termios/cfgetospeed.c new file mode 100644 index 0000000..55fa6f5 --- /dev/null +++ b/libc-top-half/musl/src/termios/cfgetospeed.c @@ -0,0 +1,13 @@ +#define _BSD_SOURCE +#include <termios.h> +#include <sys/ioctl.h> + +speed_t cfgetospeed(const struct termios *tio) +{ + return tio->c_cflag & CBAUD; +} + +speed_t cfgetispeed(const struct termios *tio) +{ + return cfgetospeed(tio); +} diff --git a/libc-top-half/musl/src/termios/cfmakeraw.c b/libc-top-half/musl/src/termios/cfmakeraw.c new file mode 100644 index 0000000..c9dddc1 --- /dev/null +++ b/libc-top-half/musl/src/termios/cfmakeraw.c @@ -0,0 +1,13 @@ +#define _GNU_SOURCE +#include <termios.h> + +void cfmakeraw(struct termios *t) +{ + t->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON); + t->c_oflag &= ~OPOST; + t->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); + t->c_cflag &= ~(CSIZE|PARENB); + t->c_cflag |= CS8; + t->c_cc[VMIN] = 1; + t->c_cc[VTIME] = 0; +} diff --git a/libc-top-half/musl/src/termios/cfsetospeed.c b/libc-top-half/musl/src/termios/cfsetospeed.c new file mode 100644 index 0000000..c9cbdd9 --- /dev/null +++ b/libc-top-half/musl/src/termios/cfsetospeed.c @@ -0,0 +1,22 @@ +#define _BSD_SOURCE +#include <termios.h> +#include <sys/ioctl.h> +#include <errno.h> + +int cfsetospeed(struct termios *tio, speed_t speed) +{ + if (speed & ~CBAUD) { + errno = EINVAL; + return -1; + } + tio->c_cflag &= ~CBAUD; + tio->c_cflag |= speed; + return 0; +} + +int cfsetispeed(struct termios *tio, speed_t speed) +{ + return speed ? cfsetospeed(tio, speed) : 0; +} + +weak_alias(cfsetospeed, cfsetspeed); diff --git a/libc-top-half/musl/src/termios/tcdrain.c b/libc-top-half/musl/src/termios/tcdrain.c new file mode 100644 index 0000000..c0e542b --- /dev/null +++ b/libc-top-half/musl/src/termios/tcdrain.c @@ -0,0 +1,8 @@ +#include <termios.h> +#include <sys/ioctl.h> +#include "syscall.h" + +int tcdrain(int fd) +{ + return syscall_cp(SYS_ioctl, fd, TCSBRK, 1); +} diff --git a/libc-top-half/musl/src/termios/tcflow.c b/libc-top-half/musl/src/termios/tcflow.c new file mode 100644 index 0000000..c7fc3fe --- /dev/null +++ b/libc-top-half/musl/src/termios/tcflow.c @@ -0,0 +1,7 @@ +#include <termios.h> +#include <sys/ioctl.h> + +int tcflow(int fd, int action) +{ + return ioctl(fd, TCXONC, action); +} diff --git a/libc-top-half/musl/src/termios/tcflush.c b/libc-top-half/musl/src/termios/tcflush.c new file mode 100644 index 0000000..5022266 --- /dev/null +++ b/libc-top-half/musl/src/termios/tcflush.c @@ -0,0 +1,7 @@ +#include <termios.h> +#include <sys/ioctl.h> + +int tcflush(int fd, int queue) +{ + return ioctl(fd, TCFLSH, queue); +} diff --git a/libc-top-half/musl/src/termios/tcgetattr.c b/libc-top-half/musl/src/termios/tcgetattr.c new file mode 100644 index 0000000..545a0bf --- /dev/null +++ b/libc-top-half/musl/src/termios/tcgetattr.c @@ -0,0 +1,9 @@ +#include <termios.h> +#include <sys/ioctl.h> + +int tcgetattr(int fd, struct termios *tio) +{ + if (ioctl(fd, TCGETS, tio)) + return -1; + return 0; +} diff --git a/libc-top-half/musl/src/termios/tcgetsid.c b/libc-top-half/musl/src/termios/tcgetsid.c new file mode 100644 index 0000000..1053fd6 --- /dev/null +++ b/libc-top-half/musl/src/termios/tcgetsid.c @@ -0,0 +1,10 @@ +#include <termios.h> +#include <sys/ioctl.h> + +pid_t tcgetsid(int fd) +{ + int sid; + if (ioctl(fd, TIOCGSID, &sid) < 0) + return -1; + return sid; +} diff --git a/libc-top-half/musl/src/termios/tcgetwinsize.c b/libc-top-half/musl/src/termios/tcgetwinsize.c new file mode 100644 index 0000000..9b3a65a --- /dev/null +++ b/libc-top-half/musl/src/termios/tcgetwinsize.c @@ -0,0 +1,8 @@ +#include <termios.h> +#include <sys/ioctl.h> +#include "syscall.h" + +int tcgetwinsize(int fd, struct winsize *wsz) +{ + return syscall(SYS_ioctl, fd, TIOCGWINSZ, wsz); +} diff --git a/libc-top-half/musl/src/termios/tcsendbreak.c b/libc-top-half/musl/src/termios/tcsendbreak.c new file mode 100644 index 0000000..b6df0a2 --- /dev/null +++ b/libc-top-half/musl/src/termios/tcsendbreak.c @@ -0,0 +1,8 @@ +#include <termios.h> +#include <sys/ioctl.h> + +int tcsendbreak(int fd, int dur) +{ + /* nonzero duration is implementation-defined, so ignore it */ + return ioctl(fd, TCSBRK, 0); +} diff --git a/libc-top-half/musl/src/termios/tcsetattr.c b/libc-top-half/musl/src/termios/tcsetattr.c new file mode 100644 index 0000000..94df18f --- /dev/null +++ b/libc-top-half/musl/src/termios/tcsetattr.c @@ -0,0 +1,12 @@ +#include <termios.h> +#include <sys/ioctl.h> +#include <errno.h> + +int tcsetattr(int fd, int act, const struct termios *tio) +{ + if (act < 0 || act > 2) { + errno = EINVAL; + return -1; + } + return ioctl(fd, TCSETS+act, tio); +} diff --git a/libc-top-half/musl/src/termios/tcsetwinsize.c b/libc-top-half/musl/src/termios/tcsetwinsize.c new file mode 100644 index 0000000..e01d0e2 --- /dev/null +++ b/libc-top-half/musl/src/termios/tcsetwinsize.c @@ -0,0 +1,8 @@ +#include <termios.h> +#include <sys/ioctl.h> +#include "syscall.h" + +int tcsetwinsize(int fd, const struct winsize *wsz) +{ + return syscall(SYS_ioctl, fd, TIOCSWINSZ, wsz); +} |