diff options
Diffstat (limited to 'src/stdio')
| -rw-r--r-- | src/stdio/__printf.c | 17 | ||||
| -rw-r--r-- | src/stdio/__stdio.c | 2 | ||||
| -rw-r--r-- | src/stdio/_stdio.h | 10 | ||||
| -rw-r--r-- | src/stdio/fflush.c | 2 | ||||
| -rw-r--r-- | src/stdio/fopen.c | 2 | ||||
| -rw-r--r-- | src/stdio/fputc.c | 4 | ||||
| -rw-r--r-- | src/stdio/rename.c | 4 |
7 files changed, 33 insertions, 8 deletions
diff --git a/src/stdio/__printf.c b/src/stdio/__printf.c index 26197b4a..87d9368b 100644 --- a/src/stdio/__printf.c +++ b/src/stdio/__printf.c @@ -1,4 +1,17 @@ #include "_stdio.h" +#include "stddef.h" +#include "wchar.h" +#include "inttypes.h" +#include "unistd.h" + +#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199909L +#include "../stdint/intmax_t.c" +#include "../stdint/uintmax_t.c" +#include "../stdint/intptr_t.c" +#include "../stdint/UINTMAX_MAX.c" +#define strtoumax __strtoumax +#include "../inttypes/strtoumax.c" +#endif #define NUMBUFLEN 64 @@ -311,3 +324,7 @@ int (__printf)(struct io_options *opt, const char * format, va_list arg) return nout; } + +/* +STDC(0) +*/ diff --git a/src/stdio/__stdio.c b/src/stdio/__stdio.c new file mode 100644 index 00000000..d607bde6 --- /dev/null +++ b/src/stdio/__stdio.c @@ -0,0 +1,2 @@ +#include "_stdio.h" +struct __stdio __stdio; diff --git a/src/stdio/_stdio.h b/src/stdio/_stdio.h index 84ad60ca..dac25c13 100644 --- a/src/stdio/_stdio.h +++ b/src/stdio/_stdio.h @@ -3,7 +3,6 @@ #include <stdarg.h> #include <stdio.h> -#include "nonstd/internal.h" #ifdef _POSIX_C_SOURCE #include <sys/types.h> @@ -14,7 +13,8 @@ struct __FILE { fpos_t pos; char *buf; - enum { SUPPLIED, ALLOCED, UNSET } buftype; + char ibuf[BUFSIZ]; + enum { INTERNAL, SUPPLIED, ALLOCED, UNSET } buftype; int buffering; int bsize; int isopen; @@ -54,6 +54,12 @@ struct io_options { int __printf(struct io_options * restrict, const char * restrict, va_list); int __scanf(struct io_options * restrict, const char * restrict, va_list); +struct __stdio { + struct __FILE FILES[FOPEN_MAX]; +}; + +extern struct __stdio __stdio; + #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199506L #define flockfile(_file) (void)(_file) #define funlockfile(_file) (void)(_file) diff --git a/src/stdio/fflush.c b/src/stdio/fflush.c index 9030a39f..1b70d8b0 100644 --- a/src/stdio/fflush.c +++ b/src/stdio/fflush.c @@ -7,7 +7,7 @@ int fflush(FILE *stream) flockfile(stream); if (stream == NULL) { FILE *p; - for (p = __libc(FILE_STREAMS); p != NULL; p = p->prev) { + for (p = __stdio.FILES; p != NULL; p = p->prev) { fflush(p); } } diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c index 8abf7709..95130917 100644 --- a/src/stdio/fopen.c +++ b/src/stdio/fopen.c @@ -5,7 +5,7 @@ /** open a file stream **/ FILE * fopen(const char * restrict filename, const char * restrict mode) { - struct __FILE *base = __libc(FILE_STREAMS); + struct __FILE *base = __stdio.FILES; struct __FILE *f = base; /* find the next available stream */ diff --git a/src/stdio/fputc.c b/src/stdio/fputc.c index c392a19c..20cf5c6b 100644 --- a/src/stdio/fputc.c +++ b/src/stdio/fputc.c @@ -5,8 +5,8 @@ #include "sys/types.h" #include "unistd.h" #else -#include "nonstd/syscall.h" -#define write(_fd, _buf, _size) __syscall(__lookup("write"), _fd, _buf, _size) +#include "../_syscall.h" +#define write(_fd, _buf, _size) __syscall(__syscall_lookup(write), _fd, _buf, _size) #endif /** write a character to a file stream **/ diff --git a/src/stdio/rename.c b/src/stdio/rename.c index 068cd73d..d213707b 100644 --- a/src/stdio/rename.c +++ b/src/stdio/rename.c @@ -1,11 +1,11 @@ #include <stdio.h> #include "errno.h" -#include "nonstd/syscall.h" +#include "../_syscall.h" /** rename a file **/ int rename(const char *old, const char *new) { - SYSCALL_NUMBER(sc, "rename", -1); + SYSCALL_NUMBER(sc, rename, -1); int err = 0; err = __syscall(sc, old, new); |
