From a20c02c11f93722914d728ad6112af077c0a2ba4 Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 25 Apr 2015 19:49:26 -0700 Subject: [PATCH] Fix issue #40. Properly flush stdio's streams at exit. --- src/libc/stdio/Makefile | 2 +- src/libc/stdio/clnup.c | 8 ++++++++ src/libc/stdio/exit.c | 9 +-------- 3 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 src/libc/stdio/clnup.c diff --git a/src/libc/stdio/Makefile b/src/libc/stdio/Makefile index 4238c6d..884d5e4 100644 --- a/src/libc/stdio/Makefile +++ b/src/libc/stdio/Makefile @@ -13,7 +13,7 @@ SRCS = ${STDSRC} fgetc.c fgets.c fputc.c fputs.c gets.c puts.c \ OBJS = ${STDOBJ} fgetc.o fgets.o fputc.o fputs.o gets.o puts.o \ feof.o ferror.o fileno.o -STDSRC = clrerr.c doscan.c exit.c fdopen.c filbuf.c findiop.c \ +STDSRC = clrerr.c doscan.c exit.c clnup.c fdopen.c filbuf.c findiop.c \ flsbuf.c fopen.c fprintf.c fread.c freopen.c fseek.c \ ftell.c fwrite.c getchar.c getw.c printf.c putchar.c putw.c \ rew.c scanf.c setbuf.c setbuffer.c setvbuf.c snprintf.c sprintf.c \ diff --git a/src/libc/stdio/clnup.c b/src/libc/stdio/clnup.c new file mode 100644 index 0000000..6d8832e --- /dev/null +++ b/src/libc/stdio/clnup.c @@ -0,0 +1,8 @@ +/* + * This stub is linked in, when application uses no stdio calls. + */ +__attribute__((weak)) +void _cleanup() +{ + /* Nothing to do. */ +} diff --git a/src/libc/stdio/exit.c b/src/libc/stdio/exit.c index 4f7624b..eab715f 100644 --- a/src/libc/stdio/exit.c +++ b/src/libc/stdio/exit.c @@ -3,14 +3,7 @@ int errno; -/* - * This stub is linked in, when application uses no stdio calls. - */ -__attribute__((weak)) -void _cleanup() -{ - /* Nothing to do. */ -} +extern void _cleanup(); void exit (code)