ref: 8bee0cb1862bc8c92ac43a8cee1ee21afad070b4
parent: faece1aea4d1b6c59024ae154077486d6f3d445a
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Feb 18 16:15:46 EST 2017
[libc] Add definition of stdin, stderr and stdout to stdio.h
--- a/libc/include/bits/amd64-sysv/arch/stdio.h
+++ b/libc/include/bits/amd64-sysv/arch/stdio.h
@@ -15,5 +15,4 @@
#define TMP_MAX 25
#define L_tmpnam 256
-typedef struct _FILE FILE;
typedef int fpos_t;
--- a/libc/include/bits/i386-sysv/arch/stdio.h
+++ b/libc/include/bits/i386-sysv/arch/stdio.h
@@ -15,5 +15,4 @@
#define TMP_MAX 25
#define L_tmpnam 256
-typedef struct _FILE FILE;
typedef long fpos_t;
--- a/libc/include/bits/z80/arch/stdio.h
+++ b/libc/include/bits/z80/arch/stdio.h
@@ -15,5 +15,4 @@
#define TMP_MAX 25
#define L_tmpnam 256
-typedef struct _FILE FILE;
typedef long fpos_t;
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -12,6 +12,24 @@
#define SEEK_END 1
#define SEEK_SET 2
+typedef struct {
+ int fd; /* file descriptor */
+ char flags; /* bits for must free buffer on close, line-buffered */
+ char state; /* last operation was read, write, position, error, eof */
+ char *buf; /* pointer to i/o buffer */
+ char *rp; /* read pointer (or write end-of-buffer) */
+ char *wp; /* write pointer (or read end-of-buffer) */
+ char *lp; /* actual write pointer used when line-buffering */
+ size_t len; /* actual length of buffer */
+ char unbuf[1]; /* tiny buffer for unbuffered io */
+} FILE;
+
+extern FILE _IO_stream[FOPEN_MAX];
+
+#define stderr (&_IO_stream[2])
+#define stdin (&_IO_stream[0])
+#define stdout (&_IO_stream[1])
+
extern int remove(const char *filename);
extern int rename(const char *old, const char *new);
extern FILE *tmpfile(void);