LibC: Implement tc{get,set}winsize functions

We already support the operation with ioctl, these functions are simply
the POSIX-compatible way of doing it. They were added in POSIX 2024.
This commit is contained in:
Lucas Chollet authored and Sönke Holz committed 2026-11-03 12:10:04 +01:00
1 parent 57d7d52024
commit 8e34c970b5
2 files changed
+16

No files matched your search

+13
View File
@@ -9,6 +9,7 @@
#include <errno.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>
extern "C" {
@@ -154,4 +155,16 @@ void cfmakeraw(struct termios* tp)
termios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
termios.c_cflag |= CS8;
}
// https://pubs.opengroup.org/onlinepubs/9799919799/functions/tcgetwinsize.html
int tcgetwinsize(int fildes, winsize* winsize_p)
{
return ioctl(fildes, TIOCGWINSZ, winsize_p);
}
// https://pubs.opengroup.org/onlinepubs/9799919799/functions/tcsetwinsize.html
int tcsetwinsize(int fildes, winsize const* winsize_p)
{
return ioctl(fildes, TIOCSWINSZ, winsize_p);
}
}
+3
View File
@@ -18,6 +18,9 @@ int tcsendbreak(int fd, int duration);
int tcflow(int fd, int action);
int tcflush(int fd, int queue_selector);
int tcgetwinsize(int fildes, struct winsize* winsize_p);
int tcsetwinsize(int fildes, const struct winsize* winsize_p);
speed_t cfgetispeed(const struct termios*);
speed_t cfgetospeed(const struct termios*);
int cfsetispeed(struct termios*, speed_t);