about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--include/sys/ioctl.h7
-rw-r--r--include/termios.h10
-rw-r--r--src/stdio/__fdopen.c1
-rw-r--r--src/stdio/__stdout_write.c1
-rw-r--r--src/termios/tcgetwinsize.c8
-rw-r--r--src/termios/tcsetwinsize.c8
-rw-r--r--src/unistd/isatty.c1
7 files changed, 29 insertions, 7 deletions
diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h
index c2ce3b48..d6a7d474 100644
--- a/include/sys/ioctl.h
+++ b/include/sys/ioctl.h
@@ -47,13 +47,6 @@ extern "C" {
 
 #define TIOCSER_TEMT 1
 
-struct winsize {
-	unsigned short ws_row;
-	unsigned short ws_col;
-	unsigned short ws_xpixel;
-	unsigned short ws_ypixel;
-};
-
 #define SIOCADDRT          0x890B
 #define SIOCDELRT          0x890C
 #define SIOCRTMSG          0x890D
diff --git a/include/termios.h b/include/termios.h
index d73c780d..793cfc94 100644
--- a/include/termios.h
+++ b/include/termios.h
@@ -15,6 +15,13 @@ typedef unsigned char cc_t;
 typedef unsigned int speed_t;
 typedef unsigned int tcflag_t;
 
+struct winsize {
+	unsigned short ws_row;
+	unsigned short ws_col;
+	unsigned short ws_xpixel;
+	unsigned short ws_ypixel;
+};
+
 #define NCCS 32
 
 #include <bits/termios.h>
@@ -27,6 +34,9 @@ int cfsetispeed (struct termios *, speed_t);
 int tcgetattr (int, struct termios *);
 int tcsetattr (int, int, const struct termios *);
 
+int tcgetwinsize (int, struct winsize *);
+int tcsetwinsize (int, const struct winsize *);
+
 int tcsendbreak (int, int);
 int tcdrain (int);
 int tcflush (int, int);
diff --git a/src/stdio/__fdopen.c b/src/stdio/__fdopen.c
index 116e78e5..616f4f99 100644
--- a/src/stdio/__fdopen.c
+++ b/src/stdio/__fdopen.c
@@ -1,6 +1,7 @@
 #include "stdio_impl.h"
 #include <stdlib.h>
 #include <sys/ioctl.h>
+#include <termios.h>
 #include <fcntl.h>
 #include <errno.h>
 #include <string.h>
diff --git a/src/stdio/__stdout_write.c b/src/stdio/__stdout_write.c
index dd1ec60f..5b413c79 100644
--- a/src/stdio/__stdout_write.c
+++ b/src/stdio/__stdout_write.c
@@ -1,5 +1,6 @@
 #include "stdio_impl.h"
 #include <sys/ioctl.h>
+#include <termios.h>
 
 size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len)
 {
diff --git a/src/termios/tcgetwinsize.c b/src/termios/tcgetwinsize.c
new file mode 100644
index 00000000..9b3a65a4
--- /dev/null
+++ b/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/src/termios/tcsetwinsize.c b/src/termios/tcsetwinsize.c
new file mode 100644
index 00000000..e01d0e25
--- /dev/null
+++ b/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);
+}
diff --git a/src/unistd/isatty.c b/src/unistd/isatty.c
index 75a9c186..bc220c00 100644
--- a/src/unistd/isatty.c
+++ b/src/unistd/isatty.c
@@ -1,6 +1,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/ioctl.h>
+#include <termios.h>
 #include "syscall.h"
 
 int isatty(int fd)