summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2021-10-24 02:49:21 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2021-10-24 03:10:03 +0200
commiteaff9ccf1dfe8f9524a1f72d8c3ec9c57a6b8228 (patch)
tree0bed5969511299b1a2d6e1932ca188fa8b4f65d8
parent80beba98c7bb968e830d0fe2f737b4e7cf3640d3 (diff)
Provide implementation for perror(3)
-rw-r--r--libpsx/include/stdio.h1
-rw-r--r--libpsx/src/libc/error.c5
2 files changed, 6 insertions, 0 deletions
diff --git a/libpsx/include/stdio.h b/libpsx/include/stdio.h
index 0e093d9..c63e585 100644
--- a/libpsx/include/stdio.h
+++ b/libpsx/include/stdio.h
@@ -123,6 +123,7 @@ void clearerr(FILE *stream);
int feof(FILE *stream);
int ferror(FILE *stream);
int fileno(FILE *stream);
+void perror(const char *s);
#define getc(f) fgetc(f)
diff --git a/libpsx/src/libc/error.c b/libpsx/src/libc/error.c
index ab5fe5b..2cfd7e8 100644
--- a/libpsx/src/libc/error.c
+++ b/libpsx/src/libc/error.c
@@ -114,3 +114,8 @@ int strerror_r(int errnum, char *strerrbuf, size_t buflen)
snprintf(strerrbuf, buflen, "Unknown error %d", errnum);
return -1;
}
+
+void perror(const char *s)
+{
+ fprintf(stderr, "%s: %s\n", s, strerror(errno));
+}