diff --git a/libc/Makefile b/libc/Makefile
index 72aef646..5ed768f9 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -182,7 +182,7 @@ $(CPUDIR)/syscall.o \
dirent/fddir-sortix.o \
dirent/scandir.o \
dlfcn/dlfcn.o \
-error/errorprint.o \
+error/gnu_error.o \
fcntl/creat.o \
fcntl/fcntl.o \
fcntl/openat.o \
@@ -244,6 +244,7 @@ stdio/fpipe.o \
stdio/freopen.o \
stdio/fsetpos.o \
stdio/getc.o \
+stdio/perror.o \
stdio/popen.o \
stdio/print.o \
stdio/putc.o \
diff --git a/libc/error/errorprint.cpp b/libc/error/gnu_error.cpp
similarity index 90%
rename from libc/error/errorprint.cpp
rename to libc/error/gnu_error.cpp
index a071c2f4..ba5e4cac 100644
--- a/libc/error/errorprint.cpp
+++ b/libc/error/gnu_error.cpp
@@ -17,17 +17,17 @@
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see .
- error/errorprint.cpp
- Functions for printing error messages to the terminal.
+ error/gnu_error.cpp
+ Prints an error message to stderr and optionally exits the process.
*******************************************************************************/
-#include
-#include
-#include
-#include
#include
#include
+#include
+#include
+#include
+#include
extern "C" void gnu_error(int status, int errnum, const char *format, ...)
{
@@ -44,8 +44,3 @@ extern "C" void gnu_error(int status, int errnum, const char *format, ...)
if ( status )
exit(status);
}
-
-extern "C" void perror(const char* s)
-{
- error(0, errno, "%s", s);
-}
diff --git a/libc/include/error.h b/libc/include/error.h
index b7fe5f50..49713124 100644
--- a/libc/include/error.h
+++ b/libc/include/error.h
@@ -22,16 +22,16 @@
*******************************************************************************/
-#ifndef _ERROR_H
-#define _ERROR_H 1
+#ifndef INCLUDE_ERROR_H
+#define INCLUDE_ERROR_H
#include
__BEGIN_DECLS
-void gnu_error(int status, int errnum, const char *format, ...);
+void gnu_error(int status, int errnum, const char* format, ...);
#if __SORTIX_STDLIB_REDIRECTS
-void error(int status, int errnum, const char *format, ...) asm("gnu_error");
+void error(int status, int errnum, const char* format, ...) asm("gnu_error");
#endif
__END_DECLS
diff --git a/libc/stdio/perror.cpp b/libc/stdio/perror.cpp
new file mode 100644
index 00000000..d024241a
--- /dev/null
+++ b/libc/stdio/perror.cpp
@@ -0,0 +1,32 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
+
+ This file is part of the Sortix C Library.
+
+ The Sortix C Library is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or (at your
+ option) any later version.
+
+ The Sortix C Library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with the Sortix C Library. If not, see .
+
+ stdio/perror.cpp
+ Prints a error messages to the terminal.
+
+*******************************************************************************/
+
+#include
+#include
+#include
+
+extern "C" void perror(const char* s)
+{
+ error(0, errno, "%s", s);
+}