From 835f9f950e2f6059532bd9ab9857a856ed21a4fd Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 8 Nov 2012 16:39:41 -0500 Subject: clean up stdio_impl.h this header evolved to facilitate the extremely lazy practice of omitting explicit includes of the necessary headers in individual stdio source files; not only was this sloppy, but it also increased build time. now, stdio_impl.h is only including the headers it needs for its own use; any further headers needed by source files are included directly where needed. --- src/internal/floatscan.c | 1 + src/internal/intscan.c | 1 + src/internal/stdio_impl.h | 17 ----------------- src/stdio/__fdopen.c | 6 ++++++ src/stdio/__fopen_rb_ca.c | 2 ++ src/stdio/__stdio_read.c | 1 + src/stdio/__stdio_write.c | 1 + src/stdio/__stdout_write.c | 2 ++ src/stdio/__string_read.c | 1 + src/stdio/fgetln.c | 1 + src/stdio/fgets.c | 1 + src/stdio/fgetwc.c | 2 ++ src/stdio/fgetws.c | 1 + src/stdio/fmemopen.c | 3 +++ src/stdio/fopen.c | 3 +++ src/stdio/fputs.c | 1 + src/stdio/fputwc.c | 3 +++ src/stdio/fputws.c | 1 + src/stdio/fread.c | 1 + src/stdio/freopen.c | 1 + src/stdio/ftell.c | 2 ++ src/stdio/fwrite.c | 1 + src/stdio/getdelim.c | 3 +++ src/stdio/gets.c | 2 ++ src/stdio/getwc.c | 1 + src/stdio/getwchar.c | 1 + src/stdio/open_memstream.c | 3 +++ src/stdio/open_wmemstream.c | 4 ++++ src/stdio/pclose.c | 3 ++- src/stdio/putwc.c | 1 + src/stdio/putwchar.c | 1 + src/stdio/ungetwc.c | 4 ++++ src/stdio/vfprintf.c | 9 +++++++++ src/stdio/vfscanf.c | 2 +- src/stdio/vfwprintf.c | 7 +++++++ src/stdio/vsnprintf.c | 4 ++++ src/stdio/vswprintf.c | 5 +++++ src/stdio/vswscanf.c | 1 + src/stdlib/strtol.c | 3 +++ src/stdlib/wcstod.c | 1 + src/stdlib/wcstol.c | 4 ++++ 41 files changed, 93 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/internal/floatscan.c b/src/internal/floatscan.c index 08251213..f6e331d4 100644 --- a/src/internal/floatscan.c +++ b/src/internal/floatscan.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "shgetc.h" #include "floatscan.h" diff --git a/src/internal/intscan.c b/src/internal/intscan.c index 178cdf0d..69350efa 100644 --- a/src/internal/intscan.c +++ b/src/internal/intscan.c @@ -1,5 +1,6 @@ #include #include +#include #include "shgetc.h" /* Lookup table for digit values. -1==255>=36 -> invalid */ diff --git a/src/internal/stdio_impl.h b/src/internal/stdio_impl.h index e9045f27..c9d20fac 100644 --- a/src/internal/stdio_impl.h +++ b/src/internal/stdio_impl.h @@ -2,23 +2,6 @@ #define _STDIO_IMPL_H #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "syscall.h" #include "libc.h" diff --git a/src/stdio/__fdopen.c b/src/stdio/__fdopen.c index df6ed71d..59690f6d 100644 --- a/src/stdio/__fdopen.c +++ b/src/stdio/__fdopen.c @@ -1,4 +1,10 @@ #include "stdio_impl.h" +#include +#include +#include +#include +#include +#include FILE *__fdopen(int fd, const char *mode) { diff --git a/src/stdio/__fopen_rb_ca.c b/src/stdio/__fopen_rb_ca.c index a1b1b3b6..9202c8ce 100644 --- a/src/stdio/__fopen_rb_ca.c +++ b/src/stdio/__fopen_rb_ca.c @@ -1,4 +1,6 @@ #include "stdio_impl.h" +#include +#include FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t len) { diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c index c99ca9a9..05e56f92 100644 --- a/src/stdio/__stdio_read.c +++ b/src/stdio/__stdio_read.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include #include static void cleanup(void *p) diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c index cef7bbdc..e52e91ae 100644 --- a/src/stdio/__stdio_write.c +++ b/src/stdio/__stdio_write.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include #include static void cleanup(void *p) diff --git a/src/stdio/__stdout_write.c b/src/stdio/__stdout_write.c index 0cf71236..200fe2c9 100644 --- a/src/stdio/__stdout_write.c +++ b/src/stdio/__stdout_write.c @@ -1,4 +1,6 @@ #include "stdio_impl.h" +#include +#include size_t __stdout_write(FILE *f, const unsigned char *buf, size_t len) { diff --git a/src/stdio/__string_read.c b/src/stdio/__string_read.c index de002fc1..7b50a7e1 100644 --- a/src/stdio/__string_read.c +++ b/src/stdio/__string_read.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include size_t __string_read(FILE *f, unsigned char *buf, size_t len) { diff --git a/src/stdio/fgetln.c b/src/stdio/fgetln.c index 06b88837..a2e4bd3c 100644 --- a/src/stdio/fgetln.c +++ b/src/stdio/fgetln.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include char *fgetln(FILE *f, size_t *plen) { diff --git a/src/stdio/fgets.c b/src/stdio/fgets.c index ee0ac30e..b01a4187 100644 --- a/src/stdio/fgets.c +++ b/src/stdio/fgets.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include #define MIN(a,b) ((a)<(b) ? (a) : (b)) diff --git a/src/stdio/fgetwc.c b/src/stdio/fgetwc.c index 6f9f9ec2..8626d54c 100644 --- a/src/stdio/fgetwc.c +++ b/src/stdio/fgetwc.c @@ -1,4 +1,6 @@ #include "stdio_impl.h" +#include +#include wint_t __fgetwc_unlocked(FILE *f) { diff --git a/src/stdio/fgetws.c b/src/stdio/fgetws.c index fab9bd0f..195cb435 100644 --- a/src/stdio/fgetws.c +++ b/src/stdio/fgetws.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include wint_t __fgetwc_unlocked(FILE *); diff --git a/src/stdio/fmemopen.c b/src/stdio/fmemopen.c index 770fd995..91d52bc1 100644 --- a/src/stdio/fmemopen.c +++ b/src/stdio/fmemopen.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include struct cookie { size_t pos, len, size; diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c index c741aede..da17ce8b 100644 --- a/src/stdio/fopen.c +++ b/src/stdio/fopen.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include FILE *fopen(const char *restrict filename, const char *restrict mode) { diff --git a/src/stdio/fputs.c b/src/stdio/fputs.c index b41bc8c7..1112b192 100644 --- a/src/stdio/fputs.c +++ b/src/stdio/fputs.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include int fputs(const char *restrict s, FILE *restrict f) { diff --git a/src/stdio/fputwc.c b/src/stdio/fputwc.c index 45ea8c23..7b621dd2 100644 --- a/src/stdio/fputwc.c +++ b/src/stdio/fputwc.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include wint_t __fputwc_unlocked(wchar_t c, FILE *f) { diff --git a/src/stdio/fputws.c b/src/stdio/fputws.c index 0b593c08..5723cbcd 100644 --- a/src/stdio/fputws.c +++ b/src/stdio/fputws.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include int fputws(const wchar_t *restrict ws, FILE *restrict f) { diff --git a/src/stdio/fread.c b/src/stdio/fread.c index 3f31af8a..c461256c 100644 --- a/src/stdio/fread.c +++ b/src/stdio/fread.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include #define MIN(a,b) ((a)<(b) ? (a) : (b)) diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c index 7ae116d8..6c1b575f 100644 --- a/src/stdio/freopen.c +++ b/src/stdio/freopen.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include /* The basic idea of this implementation is to open a new FILE, * hack the necessary parts of the new FILE into the old one, then diff --git a/src/stdio/ftell.c b/src/stdio/ftell.c index 3904a1d8..82371e37 100644 --- a/src/stdio/ftell.c +++ b/src/stdio/ftell.c @@ -1,4 +1,6 @@ #include "stdio_impl.h" +#include +#include off_t __ftello_unlocked(FILE *f) { diff --git a/src/stdio/fwrite.c b/src/stdio/fwrite.c index 8027b306..d5f6542d 100644 --- a/src/stdio/fwrite.c +++ b/src/stdio/fwrite.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f) { diff --git a/src/stdio/getdelim.c b/src/stdio/getdelim.c index 5015c3a6..26093a6c 100644 --- a/src/stdio/getdelim.c +++ b/src/stdio/getdelim.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include #define MIN(a,b) ((a)<(b) ? (a) : (b)) diff --git a/src/stdio/gets.c b/src/stdio/gets.c index 24319eb2..6c4645e5 100644 --- a/src/stdio/gets.c +++ b/src/stdio/gets.c @@ -1,4 +1,6 @@ #include "stdio_impl.h" +#include +#include char *gets(char *s) { diff --git a/src/stdio/getwc.c b/src/stdio/getwc.c index a2818bc4..a5008f0e 100644 --- a/src/stdio/getwc.c +++ b/src/stdio/getwc.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include wint_t getwc(FILE *f) { diff --git a/src/stdio/getwchar.c b/src/stdio/getwchar.c index 2295bd40..bd89e0ec 100644 --- a/src/stdio/getwchar.c +++ b/src/stdio/getwchar.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include wint_t getwchar(void) { diff --git a/src/stdio/open_memstream.c b/src/stdio/open_memstream.c index 687e818d..c7330abe 100644 --- a/src/stdio/open_memstream.c +++ b/src/stdio/open_memstream.c @@ -1,4 +1,7 @@ #include "stdio_impl.h" +#include +#include +#include struct cookie { char **bufp; diff --git a/src/stdio/open_wmemstream.c b/src/stdio/open_wmemstream.c index a830b143..2fe504c7 100644 --- a/src/stdio/open_wmemstream.c +++ b/src/stdio/open_wmemstream.c @@ -1,4 +1,8 @@ #include "stdio_impl.h" +#include +#include +#include +#include struct cookie { wchar_t **bufp; diff --git a/src/stdio/pclose.c b/src/stdio/pclose.c index 7fb76ed4..080a4262 100644 --- a/src/stdio/pclose.c +++ b/src/stdio/pclose.c @@ -1,5 +1,6 @@ #include "stdio_impl.h" -#include "syscall.h" +#include +#include int pclose(FILE *f) { diff --git a/src/stdio/putwc.c b/src/stdio/putwc.c index 80b54a47..4bb74733 100644 --- a/src/stdio/putwc.c +++ b/src/stdio/putwc.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include wint_t putwc(wchar_t c, FILE *f) { diff --git a/src/stdio/putwchar.c b/src/stdio/putwchar.c index 3aacc1cf..b249c4ac 100644 --- a/src/stdio/putwchar.c +++ b/src/stdio/putwchar.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include wint_t putwchar(wchar_t c) { diff --git a/src/stdio/ungetwc.c b/src/stdio/ungetwc.c index 5282fee1..8cc85a6b 100644 --- a/src/stdio/ungetwc.c +++ b/src/stdio/ungetwc.c @@ -1,4 +1,8 @@ #include "stdio_impl.h" +#include +#include +#include +#include wint_t ungetwc(wint_t c, FILE *f) { diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index 4a2752b2..1e7e6a47 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -1,4 +1,13 @@ #include "stdio_impl.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include /* Some useful macros */ diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c index 54d08495..fe071e95 100644 --- a/src/stdio/vfscanf.c +++ b/src/stdio/vfscanf.c @@ -1,4 +1,3 @@ -#include #include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include #include "stdio_impl.h" #include "shgetc.h" diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c index a42ba195..eb079312 100644 --- a/src/stdio/vfwprintf.c +++ b/src/stdio/vfwprintf.c @@ -1,4 +1,11 @@ #include "stdio_impl.h" +#include +#include +#include +#include +#include +#include +#include /* Convenient bit representation for modifier flags, which all fall * within 31 codepoints of the space character. */ diff --git a/src/stdio/vsnprintf.c b/src/stdio/vsnprintf.c index 6f19b028..be2c44eb 100644 --- a/src/stdio/vsnprintf.c +++ b/src/stdio/vsnprintf.c @@ -1,4 +1,8 @@ #include "stdio_impl.h" +#include +#include +#include +#include static size_t sn_write(FILE *f, const unsigned char *s, size_t l) { diff --git a/src/stdio/vswprintf.c b/src/stdio/vswprintf.c index f3d4fec1..7d237bae 100644 --- a/src/stdio/vswprintf.c +++ b/src/stdio/vswprintf.c @@ -1,4 +1,9 @@ #include "stdio_impl.h" +#include +#include +#include +#include +#include struct cookie { wchar_t *ws; diff --git a/src/stdio/vswscanf.c b/src/stdio/vswscanf.c index a205200a..7a2f7c7a 100644 --- a/src/stdio/vswscanf.c +++ b/src/stdio/vswscanf.c @@ -1,4 +1,5 @@ #include "stdio_impl.h" +#include static size_t wstring_read(FILE *f, unsigned char *buf, size_t len) { diff --git a/src/stdlib/strtol.c b/src/stdlib/strtol.c index 23a2f3b6..7ee88794 100644 --- a/src/stdlib/strtol.c +++ b/src/stdlib/strtol.c @@ -1,6 +1,9 @@ #include "stdio_impl.h" #include "intscan.h" #include "shgetc.h" +#include +#include +#include static unsigned long long strtox(const char *s, char **p, int base, unsigned long long lim) { diff --git a/src/stdlib/wcstod.c b/src/stdlib/wcstod.c index 03670b0b..83f308d3 100644 --- a/src/stdlib/wcstod.c +++ b/src/stdlib/wcstod.c @@ -1,6 +1,7 @@ #include "shgetc.h" #include "floatscan.h" #include "stdio_impl.h" +#include /* This read function heavily cheats. It knows: * (1) len will always be 1 diff --git a/src/stdlib/wcstol.c b/src/stdlib/wcstol.c index 3d7c97da..4443f577 100644 --- a/src/stdlib/wcstol.c +++ b/src/stdlib/wcstol.c @@ -1,6 +1,10 @@ #include "stdio_impl.h" #include "intscan.h" #include "shgetc.h" +#include +#include +#include +#include /* This read function heavily cheats. It knows: * (1) len will always be 1 -- cgit v1.2.1