From 8d4af013972f64dbabb7176706c18a94a63792f2 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Sun, 16 Aug 2020 12:12:29 -0400 Subject: improve fallback if not building for POSIX (still requires POSIX headers) --- src/stdio/freopen.c | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c index ad9e254e..516684b4 100644 --- a/src/stdio/freopen.c +++ b/src/stdio/freopen.c @@ -1,33 +1,20 @@ +#ifndef _POSIX_SOURCE +#define _POSIX_SOURCE +#define POSIX_FORCED +#endif + #include -#include "string.h" -#include "errno.h" +#include +#include +#include +#include +#include #include "_stdio.h" -#if defined _POSIX_SOURCE -#include "sys/types.h" -#include "fcntl.h" -#else -#include "fcntl/O_RDONLY.c" -#include "fcntl/O_WRONLY.c" -#include "fcntl/O_CREAT.c" -#include "fcntl/O_TRUNC.c" -#include "fcntl/O_APPEND.c" -#include "fcntl/O_RDWR.c" -#define open(fname, flags, mode) __syscall(__syscall_lookup(open), fname, flags, mode) -#endif - -#ifdef _POSIX_SOURCE -#define DEFAULT_LOCALE "POSIX" -#include "unistd.h" -#else -#define DEFAULT_LOCALE "C" -#include "_syscall.h" -#include "termios/NCCS.c" -#include "termios/speed_t.c" -#include "termios/cc_t.c" -#include "termios/tcflag_t.c" -#include "termios/struct_termios.c" +#ifdef POSIX_FORCED #include "termios/_termios.h" +#include "_syscall.h" +#define open(fname, flags, mode) __scall3(open, fname, flags, mode) #define isatty(fd) ioctl(fd, TCFLSH, 0) #endif -- cgit v1.2.1