Skip to content
Snippets Groups Projects
Commit 6846b4eb authored by Iván Briano's avatar Iván Briano
Browse files

cpu: native: Add [v]fprintf to syscalls

External packages that may use fprintf(stderr, ...) for logging will
link directly to the libc version of it, and for some reason that
results in the application crashing.
parent 98949f5c
No related branches found
No related tags found
No related merge requests found
...@@ -289,21 +289,33 @@ int printf(const char *format, ...) ...@@ -289,21 +289,33 @@ int printf(const char *format, ...)
{ {
int r; int r;
va_list argp; va_list argp;
char *m;
va_start(argp, format); va_start(argp, format);
if ((m = make_message(format, argp)) == NULL) { r = vfprintf(stdout, format, argp);
err(EXIT_FAILURE, "malloc");
}
r = _native_write(STDOUT_FILENO, m, strlen(m));
va_end(argp); va_end(argp);
free(m);
return r; return r;
} }
int vprintf(const char *format, va_list argp) int vprintf(const char *format, va_list argp)
{
return vfprintf(stdout, format, argp);
}
int fprintf(FILE *fp, const char *format, ...)
{
int r;
va_list argp;
va_start(argp, format);
r = vfprintf(fp, format, argp);
va_end(argp);
return r;
}
int vfprintf(FILE *fp, const char *format, va_list argp)
{ {
int r; int r;
char *m; char *m;
...@@ -311,7 +323,7 @@ int vprintf(const char *format, va_list argp) ...@@ -311,7 +323,7 @@ int vprintf(const char *format, va_list argp)
if ((m = make_message(format, argp)) == NULL) { if ((m = make_message(format, argp)) == NULL) {
err(EXIT_FAILURE, "malloc"); err(EXIT_FAILURE, "malloc");
} }
r = _native_write(STDOUT_FILENO, m, strlen(m)); r = _native_write(fileno(fp), m, strlen(m));
free(m); free(m);
return r; return r;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment