scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 3cc5a49bf9108eb49ed5032e587221286ea11357
parent 03366a5e0bd53febbcf2eee2344871d1a019e40a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sat, 18 Feb 2017 21:15:46 +0100

[libc] Add definition of stdin, stderr and stdout to stdio.h

Diffstat:
Mlibc/include/bits/amd64-sysv/arch/stdio.h | 1-
Mlibc/include/bits/i386-sysv/arch/stdio.h | 1-
Mlibc/include/bits/z80/arch/stdio.h | 1-
Mlibc/include/stdio.h | 18++++++++++++++++++
4 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/libc/include/bits/amd64-sysv/arch/stdio.h b/libc/include/bits/amd64-sysv/arch/stdio.h @@ -15,5 +15,4 @@ typedef unsigned long size_t; #define TMP_MAX 25 #define L_tmpnam 256 -typedef struct _FILE FILE; typedef int fpos_t; diff --git a/libc/include/bits/i386-sysv/arch/stdio.h b/libc/include/bits/i386-sysv/arch/stdio.h @@ -15,5 +15,4 @@ typedef unsigned long size_t; #define TMP_MAX 25 #define L_tmpnam 256 -typedef struct _FILE FILE; typedef long fpos_t; diff --git a/libc/include/bits/z80/arch/stdio.h b/libc/include/bits/z80/arch/stdio.h @@ -15,5 +15,4 @@ typedef unsigned size_t; #define TMP_MAX 25 #define L_tmpnam 256 -typedef struct _FILE FILE; typedef long fpos_t; diff --git 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);