summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/stdio/__stdout_write.c
blob: 8190ec5b4c1fcb5c963ef06a96a2dfa37d89f3c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "stdio_impl.h"
#include <sys/ioctl.h>
#ifdef __wasilibc_unmodified_upstream // use isatty rather than manual ioctl
#else
#include <__function___isatty.h>
#endif

size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len)
{
#ifdef __wasilibc_unmodified_upstream // use isatty rather than manual ioctl
	struct winsize wsz;
#endif
	f->write = __stdio_write;
#ifdef __wasilibc_unmodified_upstream // use isatty rather than manual ioctl
	if (!(f->flags & F_SVB) && __syscall(SYS_ioctl, f->fd, TIOCGWINSZ, &wsz))
#else
	if (!(f->flags & F_SVB) && !__isatty(f->fd))
#endif
		f->lbf = -1;
	return __stdio_write(f, buf, len);
}