libc: Implement perror()
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-01-13 21:08:10 +01:00
parent e676fb8299
commit 28bde216c4
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 11 additions and 0 deletions

View File

@ -58,6 +58,9 @@ extern "C"
/* Output a message to the console. */
int console_write(const char* msg, size_t size);
/* Write an error message to standard error. */
void perror(const char* s);
#ifdef __cplusplus
}
#endif

View File

@ -70,6 +70,14 @@ extern "C"
return 0;
}
void perror(const char* s)
{
// FIXME: Output to stderr when available.
int err = errno;
if (s && *s) printf("%s: ", s);
printf("%s\n", strerror(err));
}
}
void debug_log_impl(const char* format, va_list ap)