Skip to content

Commit

Permalink
cpu/native: don't implement stdout functions with stdio_null
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Oct 1, 2024
1 parent 2d8d952 commit 55aedc0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cpu/native/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,25 +289,27 @@ ssize_t _native_writev(int fd, const struct iovec *iov, int iovcnt)
#if defined(__FreeBSD__)
#undef putchar
#endif
#ifndef MODULE_STDIO_NULL
int putchar(int c)
{
char tmp = c;
return _native_write(STDOUT_FILENO, &tmp, sizeof(tmp));
}

int putc(int c, FILE *fp)
{
char tmp = c;
return _native_write(fileno(fp), &tmp, sizeof(tmp));
}

int puts(const char *s)
{
int r;
r = _native_write(STDOUT_FILENO, (char*)s, strlen(s));
putchar('\n');
return r;
}
#endif

int putc(int c, FILE *fp)
{
char tmp = c;
return _native_write(fileno(fp), &tmp, sizeof(tmp));
}

int fgetc(FILE *fp)
{
Expand Down Expand Up @@ -371,6 +373,7 @@ char *make_message(const char *format, va_list argp)
}
}

#ifndef MODULE_STDIO_NULL
int printf(const char *format, ...)
{
int r;
Expand All @@ -387,6 +390,7 @@ int vprintf(const char *format, va_list argp)
{
return vfprintf(stdout, format, argp);
}
#endif

int fprintf(FILE *fp, const char *format, ...)
{
Expand Down

0 comments on commit 55aedc0

Please sign in to comment.