mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-27 07:21:18 +01:00
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.
This commit is contained in:
parent
98949f5cb4
commit
6846b4ebdd
@ -289,21 +289,33 @@ int printf(const char *format, ...)
|
||||
{
|
||||
int r;
|
||||
va_list argp;
|
||||
char *m;
|
||||
|
||||
va_start(argp, format);
|
||||
if ((m = make_message(format, argp)) == NULL) {
|
||||
err(EXIT_FAILURE, "malloc");
|
||||
}
|
||||
r = _native_write(STDOUT_FILENO, m, strlen(m));
|
||||
r = vfprintf(stdout, format, argp);
|
||||
va_end(argp);
|
||||
free(m);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
char *m;
|
||||
@ -311,7 +323,7 @@ int vprintf(const char *format, va_list argp)
|
||||
if ((m = make_message(format, argp)) == NULL) {
|
||||
err(EXIT_FAILURE, "malloc");
|
||||
}
|
||||
r = _native_write(STDOUT_FILENO, m, strlen(m));
|
||||
r = _native_write(fileno(fp), m, strlen(m));
|
||||
free(m);
|
||||
|
||||
return r;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user