Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sio_printf broken since newlib #161

Open
rickgaiser opened this issue Jan 8, 2021 · 0 comments
Open

sio_printf broken since newlib #161

rickgaiser opened this issue Jan 8, 2021 · 0 comments

Comments

@rickgaiser
Copy link
Member

The old sio_printf function depends on vsnprintf from libc/newlib, making it too big to use for ELF's that need to be small. For this reason, sio_printf has been removed in a744144.

A more flexible solution would be to redirect the output of printf to different 'write' functions, to be called from here:

int _write(int fd, const void *buf, size_t nbytes) {
// HACK: stdout and strerr to serial
//if ((fd==1) || (fd==2))
// return sio_write((void *)buf, nbytes);
return _ps2sdk_write(fd, buf, nbytes);
}

An interface could look like:

libc_set_stdout(sio_write); // output redirected to EE SIO
libc_set_stdout(_ps2sdk_write); // output redirected to IOP (default)
libc_set_stdout(custom_stdout); // custom function that redirects to a file, or something else...

The idea is to give an application control over where the stdout will go to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant