aboutsummaryrefslogtreecommitdiff
path: root/lib/mlibc/options/posix/generic/termios-stubs.cpp
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-03-07 17:28:52 -0500
committerIan Moffett <ian@osmora.org>2024-03-07 18:24:51 -0500
commitf5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 (patch)
tree93b156621dc0303816b37f60ba88051b702d92f6 /lib/mlibc/options/posix/generic/termios-stubs.cpp
parentbd5969fc876a10b18613302db7087ef3c40f18e1 (diff)
build: Build mlibc + add distclean target
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/options/posix/generic/termios-stubs.cpp')
-rw-r--r--lib/mlibc/options/posix/generic/termios-stubs.cpp103
1 files changed, 0 insertions, 103 deletions
diff --git a/lib/mlibc/options/posix/generic/termios-stubs.cpp b/lib/mlibc/options/posix/generic/termios-stubs.cpp
deleted file mode 100644
index 631456a..0000000
--- a/lib/mlibc/options/posix/generic/termios-stubs.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE
-#endif
-
-#include <errno.h>
-#include <termios.h>
-#include <sys/ioctl.h>
-
-#include <bits/ensure.h>
-#include <mlibc/posix-sysdeps.hpp>
-
-speed_t cfgetispeed(const struct termios *tios) {
- return tios->c_cflag & CBAUD;
-}
-
-speed_t cfgetospeed(const struct termios *tios) {
- return tios->c_cflag & CBAUD;
-}
-
-int cfsetispeed(struct termios *termios, speed_t speed) {
- return speed ? cfsetospeed(termios, speed) : 0;
-}
-
-int cfsetospeed(struct termios *termios, speed_t speed) {
- if(speed & ~CBAUD) {
- errno = EINVAL;
- return -1;
- }
-
- termios->c_cflag &= ~CBAUD;
- termios->c_cflag |= speed;
-
- return 0;
-}
-
-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;
-}
-
-int tcdrain(int fd) {
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_tcdrain, -1);
- if(int e = mlibc::sys_tcdrain(fd); e) {
- errno = e;
- return -1;
- }
- return 0;
-}
-
-int tcflow(int fd, int action) {
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_tcflow, -1);
- if(int e = mlibc::sys_tcflow(fd, action); e) {
- errno = e;
- return -1;
- }
- return 0;
-}
-
-int tcflush(int fd, int queue_selector) {
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_tcflush, -1);
- if(int e = mlibc::sys_tcflush(fd, queue_selector); e) {
- errno = e;
- return -1;
- }
- return 0;
-}
-
-int tcgetattr(int fd, struct termios *attr) {
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_tcgetattr, -1);
- if(int e = mlibc::sys_tcgetattr(fd, attr); e) {
- errno = e;
- return -1;
- }
- return 0;
-}
-
-pid_t tcgetsid(int fd) {
- int sid;
- if(ioctl(fd, TIOCGSID, &sid) < 0) {
- return -1;
- }
- return sid;
-}
-
-int tcsendbreak(int, int) {
- __ensure(!"Not implemented");
- __builtin_unreachable();
-}
-
-int tcsetattr(int fd, int opts, const struct termios *attr) {
- MLIBC_CHECK_OR_ENOSYS(mlibc::sys_tcsetattr, -1);
- if(int e = mlibc::sys_tcsetattr(fd, opts, attr); e) {
- errno = e;
- return -1;
- }
- return 0;
-}
-