diff options
| author | Jakob Kaivo <jkk@ung.org> | 2024-05-28 15:50:03 -0400 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2024-05-28 15:50:03 -0400 |
| commit | c9ec058657f9f8b3fd39a16f1a9e993b4a1e982e (patch) | |
| tree | 6cf1abadd04a1a9049d82ffe0e78be7f8b4cece2 /src/stdio | |
| parent | b4cd7036bea6c6440fbbcdaebe53c864c87a5646 (diff) | |
abstract out "forced" implementations of functions from future specifications
Diffstat (limited to 'src/stdio')
| -rw-r--r-- | src/stdio/__printf.c | 11 | ||||
| -rw-r--r-- | src/stdio/fclose.c | 15 | ||||
| -rw-r--r-- | src/stdio/fflush.c | 11 | ||||
| -rw-r--r-- | src/stdio/freopen.c | 20 | ||||
| -rw-r--r-- | src/stdio/remove.c | 28 |
5 files changed, 9 insertions, 76 deletions
diff --git a/src/stdio/__printf.c b/src/stdio/__printf.c index 7fa7a46b..1ee488d7 100644 --- a/src/stdio/__printf.c +++ b/src/stdio/__printf.c @@ -10,16 +10,7 @@ #include <unistd.h> #endif -#if __STDC_VERSION__ >= 199901L -#include <inttypes.h> -#else -#include "stdint/intmax_t.h" -#include "stdint/uintmax_t.h" -#include "stdint/intptr_t.h" -#include "stdint/UINTMAX_MAX.h" -#define strtoumax __strtoumax -#include "inttypes/strtoumax.c" -#endif +#include "_forced/strtoumax.h" #include "_stdio.h" diff --git a/src/stdio/fclose.c b/src/stdio/fclose.c index 37198fcb..cb4499ac 100644 --- a/src/stdio/fclose.c +++ b/src/stdio/fclose.c @@ -1,23 +1,10 @@ -#ifndef _POSIX_SOURCE -#define _POSIX_SOURCE -#define POSIX_FORCED -#endif - - #include <stdio.h> #include <stdlib.h> #include <string.h> -#if 0 -#include <sys/types.h> -#include <unistd.h> -#endif #include "_stdio.h" -#ifdef POSIX_FORCED -#include "_syscall.h" -#define close(_fd) __scall1(close, _fd) -#endif +#include "_forced/close.h" /** close a file stream **/ diff --git a/src/stdio/fflush.c b/src/stdio/fflush.c index 6c1e78f5..2250aaaf 100644 --- a/src/stdio/fflush.c +++ b/src/stdio/fflush.c @@ -1,15 +1,6 @@ -#ifndef _POSIX_SOURCE -#define _POSIX_SOURCE -#define POSIX_FORCED -#endif - #include <stdio.h> #include "_stdio.h" - -#ifdef POSIX_FORCED -#include "_syscall.h" -#define write(_fd, _buf, _size) __scall3(write, _fd, _buf, _size) -#endif +#include "_forced/write.h" /** flush buffered writes **/ diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c index f23d53af..60394ca6 100644 --- a/src/stdio/freopen.c +++ b/src/stdio/freopen.c @@ -1,25 +1,9 @@ -#ifndef _POSIX_SOURCE -#define _POSIX_SOURCE -#define POSIX_FORCED -#endif - #include <errno.h> #include <stdio.h> #include <string.h> #include "_stdio.h" - -#ifdef POSIX_FORCED -#include "_syscall.h" -#define open(_p, _f, _m) __scall3(open, _p, _f, _m) -#define isatty(_fd) (-1) /*ioctl(_fd, TCFLSH, 0) */ -#define TCFLSH 0x540B -#define O_RDONLY 00 -#define O_WRONLY 01 -#define O_CREAT 0100 -#define O_TRUNC 01000 -#define O_APPEND 02000 -#define O_RDWR 02 -#endif +#include "_forced/open.h" +#include "_forced/isatty.h" /** reopen a file stream with a new file **/ diff --git a/src/stdio/remove.c b/src/stdio/remove.c index 8b6c5925..e52132de 100644 --- a/src/stdio/remove.c +++ b/src/stdio/remove.c @@ -1,42 +1,22 @@ -#ifndef _POSIX_SOURCE -#define _POSIX_SOURCE -#define POSIX_FORCED -#endif - #include <stdio.h> #include "_stdio.h" - -#if 0 -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#endif - -#ifdef POSIX_FORCED -#include "_syscall.h" -#define stat(_f, _b) __scall2(stat, _f, _b) -#define rmdir(_f) __scall1(rmdir, _f) -#define unlink(_f) __scall1(unlink, _f) -#endif +#include "_forced/stat.h" +#include "_forced/rmdir.h" +#include "_forced/unlink.h" /** delete a file **/ int remove(const char *filename) { - /* struct stat st; */ + struct stat st; SIGNAL_SAFE(0); - /* stat(filename, &st); if (S_ISDIR(st.st_mode)) { return rmdir(filename); } return unlink(filename); - */ - - (void)filename; - return -1; } /*** |
