On Thursday, 30 April 2015 at 21:35:44 UTC, Mike wrote:
On Thursday, 30 April 2015 at 21:08:22 UTC, Jens Bauer wrote:
Thus I would expect the hook to be somewhere in vfprintf ?
As Timo said, eventually, what printf needs is the `write`
syscall. The C library needs to be ported to the hardware in
question. That requires implementing all the syscalls the the
C library needs: `write` for printf, `sbrk` for malloc, etc...
(http://wiki.osdev.org/Porting_Newlib#newlib.2Flibc.2Fsys.2Fmyos.2Fsyscalls.c)
Sometimes the toolchain vendors provide this, sometimes the
programmer has to do it.
Uhm, in that case, why not supply a weakref dummy, eg. functions
that can be overridden.
Thus stat, open, fstat, lseek, read, write, isatty, close, link
and unlink just do nothing at all.
If the MCU has a file-system, then it can implement those as
strong refs.
Same about gettimeofday, getpid, execve, fork, kill - Often
there's only a single thread and no possibility for loading and
executing a named program.
-So it should be fairly easy to change newlib 'requirements' to
'optional'. :)
I feel like trying this out, perhaps when the new light comes. ;)