scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 03edfe03f5a09e129c84537ce44d030e974dd00c
parent 15d9bea9a00f9bc013e0a7954eb9a59fb3039549
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  8 Dec 2017 18:08:35 +0100

[lib/c] Add data definition of __iob array

Diffstat:
Mlib/c/include/stdio.h | 7+++----
Mlib/c/src/Makefile | 1+
Alib/c/src/stdio.c | 26++++++++++++++++++++++++++
3 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/lib/c/include/stdio.h b/lib/c/include/stdio.h @@ -16,9 +16,6 @@ #define SEEK_END 1 #define SEEK_SET 2 -#define _IOFBF 0 -#define _IOLBF 1 -#define _IONBF 2 #define _IOWRITE (1 << 0) #define _IOREAD (1 << 1) @@ -27,6 +24,9 @@ #define _IOERR (1 << 4) #define _IOSTRG (1 << 5) #define _IOTXT (1 << 6) +#define _IOFBF (1 << 7) +#define _IOLBF (1 << 8) +#define _IONBF (1 << 9) typedef struct { int fd; /* file descriptor */ @@ -35,7 +35,6 @@ typedef struct { unsigned char *wp; /* write pointer */ unsigned char *lp; /* write pointer used when line-buffering */ size_t len; /* actual length of buffer */ - unsigned char mode; unsigned char flags; unsigned char unbuf[1]; /* tiny buffer for unbuffered io */ } FILE; diff --git a/lib/c/src/Makefile b/lib/c/src/Makefile @@ -10,6 +10,7 @@ OBJ = bsearch.o qsort.o \ fputs.o puts.o fread.o fwrite.o \ getc.o putc.o __putc.o __getc.o \ rewind.o fseek.o ferror.o feof.o clearerr.o \ + stdio.o \ realloc.o calloc.o malloc.o \ assert.o strcpy.o strcmp.o strlen.o strchr.o \ strrchr.o strcat.o strncmp.o strncpy.o strncat.o strcoll.o \ diff --git a/lib/c/src/stdio.c b/lib/c/src/stdio.c @@ -0,0 +1,26 @@ + +#include <stdio.h> + +static unsigned char inbuf[BUFSIZ]; +static unsigned char outbuf[BUFSIZ]; + +FILE __iob[FOPEN_MAX] = { + { + .fd = 0, + .buf = inbuf, + .len = BUFSIZ, + .flags = _IOREAD + }, + { + .fd = 1, + .buf = outbuf, + .len = BUFSIZ, + .flags = _IOWRITE | _IOLBF + }, + { + .fd = 2, + .buf = stderr->unbuf, + .len = sizeof(stderr->unbuf), + .flags = _IOWRITE + }, +};