Cleanup stdout write redirection.

- comments, naming, missing include
This commit is contained in:
Oto Petřík 2016-12-16 00:53:23 +01:00
parent 194b8e420a
commit 70a30a79d7
2 changed files with 26 additions and 5 deletions

View file

@ -55,20 +55,20 @@ __attribute__((weak)) long _write_stdout_r(struct _reent *r, int fd, const char
return len;
}
_WriteFunction *_current_stdout_write_r = &_write_stdout_r;
static _WriteFunction *current_stdout_write_r = &_write_stdout_r;
void set_write_stdout(_WriteFunction *f)
{
if (f != NULL) {
_current_stdout_write_r = f;
current_stdout_write_r = f;
} else {
_current_stdout_write_r = &_write_stdout_r;
current_stdout_write_r = &_write_stdout_r;
}
}
_WriteFunction *get_write_stdout()
{
return _current_stdout_write_r;
return current_stdout_write_r;
}
/* default implementation, replace in a filesystem */
@ -83,7 +83,7 @@ __attribute__((weak)) long _write_r(struct _reent *r, int fd, const char *ptr, i
if(fd != r->_stdout->_file) {
return _write_filesystem_r(r, fd, ptr, len);
}
return _current_stdout_write_r(r, fd, ptr, len);
return current_stdout_write_r(r, fd, ptr, len);
}
/* syscall implementation for stdio read from UART */