diff options
author | H. Peter Anvin <hpa@zytor.com> | 2012-05-08 18:22:40 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2012-05-08 19:23:38 -0700 |
commit | 54e5e8ff848b84ea3837cd34eea352c1c2cecc5b (patch) | |
tree | 10e58f383a45b2dbbf268d010075bfb024182775 | |
parent | ed1ea8c37175af969372a0f1dbb0afdceee8e6d8 (diff) | |
download | klibc-54e5e8ff848b84ea3837cd34eea352c1c2cecc5b.tar.gz |
[klibc] Remove stdio internals from <stdio.h>
Remove the internals of the FILE structure from <stdio.h>. This means
removing the handful of inlines we already had there and replacing
them with out-of-line functions.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | usr/include/stdio.h | 26 | ||||
-rw-r--r-- | usr/klibc/Kbuild | 3 | ||||
-rw-r--r-- | usr/klibc/stdio/feof.c | 4 | ||||
-rw-r--r-- | usr/klibc/stdio/ferror.c | 4 | ||||
-rw-r--r-- | usr/klibc/stdio/fileno.c | 6 | ||||
-rw-r--r-- | usr/klibc/stdio/ftell.c | 6 | ||||
-rw-r--r-- | usr/klibc/stdio/stdioint.h | 12 |
7 files changed, 33 insertions, 28 deletions
diff --git a/usr/include/stdio.h b/usr/include/stdio.h index 8dc178e19e86f..1bddd31a53ff1 100644 --- a/usr/include/stdio.h +++ b/usr/include/stdio.h @@ -11,17 +11,7 @@ #include <stddef.h> #include <unistd.h> -/* Actual FILE structure */ -struct _IO_file { - struct _IO_file *prev, *next; - off_t filepos; /* File position */ - char *buf; /* Buffer */ - char *data; /* Data in buffer */ - int bytes; /* Data bytes in buffer */ - int bufsiz; /* Total size of buffer */ - int fd; /* Underlying file descriptor */ - int flags; /* Error, end of file */ -}; +struct _IO_file; typedef struct _IO_file FILE; enum _IO_file_flags { @@ -48,24 +38,14 @@ enum _IO_file_flags { /* * Convert between a FILE * and a file descriptor. */ -__extern int fileno(FILE *); - -__extern_inline int fileno(FILE * __f) -{ - return __f->fd; -} - __extern FILE *stdin, *stdout, *stderr; +__extern int fileno(FILE *); __extern FILE *fopen(const char *, const char *); __extern FILE *fdopen(int, const char *); __extern int fclose(FILE *); __extern int fseek(FILE *, off_t, int); -__static_inline off_t ftell(FILE * __f) -{ - return __f->filepos; -} - +__extern off_t ftell(FILE * __f); __extern int fputs(const char *, FILE *); __extern int puts(const char *); __extern int fputc(int, FILE *); diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild index 753ab85162356..ac1ce9e149031 100644 --- a/usr/klibc/Kbuild +++ b/usr/klibc/Kbuild @@ -60,7 +60,8 @@ klib-y := vsnprintf.o snprintf.o vsprintf.o sprintf.o \ setmntent.o endmntent.o getmntent.o \ stdio/fclose.o stdio/fopen.o stdio/fdopen.o stdio/fxopen.o \ stdio/fread.o stdio/fwrite.o stdio/fflush.o \ - stdio/fseek.o stdio/ungetc.o stdio/feof.o stdio/ferror.o + stdio/fseek.o stdio/ftell.o stdio/fileno.o \ + stdio/ungetc.o stdio/feof.o stdio/ferror.o klib-$(CONFIG_KLIBC_ERRLIST) += errlist.o diff --git a/usr/klibc/stdio/feof.c b/usr/klibc/stdio/feof.c index 01c26e162ef8a..23bf29fe3bdb1 100644 --- a/usr/klibc/stdio/feof.c +++ b/usr/klibc/stdio/feof.c @@ -1,6 +1,6 @@ -#include <stdio.h> +#include "stdioint.h" int feof(FILE *f) { - return f->flags & _IO_FILE_FLAG_EOF; + return !!(f->flags & _IO_FILE_FLAG_EOF); } diff --git a/usr/klibc/stdio/ferror.c b/usr/klibc/stdio/ferror.c index ab5322f8a825b..8fc6bb01e29aa 100644 --- a/usr/klibc/stdio/ferror.c +++ b/usr/klibc/stdio/ferror.c @@ -1,6 +1,6 @@ -#include <stdio.h> +#include "stdioint.h" int ferror(FILE *f) { - return f->flags & _IO_FILE_FLAG_ERR; + return !!(f->flags & _IO_FILE_FLAG_ERR); } diff --git a/usr/klibc/stdio/fileno.c b/usr/klibc/stdio/fileno.c new file mode 100644 index 0000000000000..f44ecf463c2e8 --- /dev/null +++ b/usr/klibc/stdio/fileno.c @@ -0,0 +1,6 @@ +#include "stdioint.h" + +int fileno(FILE *f) +{ + return f->fd; +} diff --git a/usr/klibc/stdio/ftell.c b/usr/klibc/stdio/ftell.c new file mode 100644 index 0000000000000..72cb5690e93ff --- /dev/null +++ b/usr/klibc/stdio/ftell.c @@ -0,0 +1,6 @@ +#include "stdioint.h" + +off_t ftell(FILE *f) +{ + return f->filepos; +} diff --git a/usr/klibc/stdio/stdioint.h b/usr/klibc/stdio/stdioint.h index ad2458924f2da..da9e27c83d838 100644 --- a/usr/klibc/stdio/stdioint.h +++ b/usr/klibc/stdio/stdioint.h @@ -13,6 +13,18 @@ #include <unistd.h> #include <fcntl.h> +/* Actual FILE structure */ +struct _IO_file { + struct _IO_file *prev, *next; + off_t filepos; /* File position */ + char *buf; /* Buffer */ + char *data; /* Data in buffer */ + int bytes; /* Data bytes in buffer */ + int bufsiz; /* Total size of buffer */ + int fd; /* Underlying file descriptor */ + int flags; /* Error, end of file */ +}; + /* Assign this much extra to the input buffer in case of ungetc() */ #define _IO_UNGET_SLOP 32 |