From: John Hodge (sonata) Date: Mon, 27 May 2013 11:50:17 +0000 (+0800) Subject: Usermode/libc - Moved perror to errno.c and implimented it properly X-Git-Tag: rel0.15~292^2~8 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;ds=sidebyside;h=cff93fad3a4fc50cae99938d869356af2ab8a2e9;p=tpg%2Facess2.git Usermode/libc - Moved perror to errno.c and implimented it properly --- diff --git a/Usermode/Libraries/libc.so_src/Makefile b/Usermode/Libraries/libc.so_src/Makefile index b7cb1d22..2c2e62d6 100644 --- a/Usermode/Libraries/libc.so_src/Makefile +++ b/Usermode/Libraries/libc.so_src/Makefile @@ -11,7 +11,7 @@ LDFLAGS += -Map map.txt INCFILES := stdio.h stdlib.h OBJ = stub.o heap.o stdlib.o env.o stdio.o string.o rand.o -OBJ += perror.o scanf.o signals.o strtoi.o strtof.o +OBJ += scanf.o signals.o strtoi.o strtof.o OBJ += printf.o time.o errno.o OBJ += arch/$(ARCHDIR).ao # signals.o diff --git a/Usermode/Libraries/libc.so_src/errno.c b/Usermode/Libraries/libc.so_src/errno.c index 98773282..b4a4f019 100644 --- a/Usermode/Libraries/libc.so_src/errno.c +++ b/Usermode/Libraries/libc.so_src/errno.c @@ -6,6 +6,7 @@ * - errno and strerror */ #include "lib.h" +#include #include #include @@ -28,3 +29,16 @@ EXPORT const char *strerror(int errnum) } } +// stdio.h +EXPORT void perror(const char *s) +{ + int err = errno; + if( s && s[0] ) { + fprintf(stderr, "%s: (%i) %s\n", s, err, strerror(err)); + } + else { + fprintf(stderr, "(%i) %s\n", err, strerror(err)); + } + _SysDebug("perror('%s'): %s (%i)", s, strerror(err), err); +} + diff --git a/Usermode/Libraries/libc.so_src/perror.c b/Usermode/Libraries/libc.so_src/perror.c deleted file mode 100644 index 0431635d..00000000 --- a/Usermode/Libraries/libc.so_src/perror.c +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Acess2 C Library - * - By John Hodge (thePowersGang) - * - * perror.c - * - perror() and friends - */ -#include -#include - -void perror(const char *s) -{ - fprintf(stderr, "%s: Error (%i)\n", s, errno); -}