On Thursday, 30 April 2015 at 21:08:22 UTC, Jens Bauer wrote:
On Thursday, 30 April 2015 at 20:54:07 UTC, Martin Nowak wrote:
On 04/30/2015 08:43 AM, Timo Sintonen wrote:
Printf is a little tricky. It is actually a file operation to stdout and that is actually a syscall to kernel.

No, you usually have to implement some hook for outputting yourself, e.g. putc or write, printf solely takes care of the formatting.

My knowledge isn't really deep here, but doesn't printf call vfprintf(stdout, ...) and
vfprintf call vsnprintf followed by fwrite, etc. ?

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.

IMO, C library bindings are quite useful, and an important part of the microcontroller ecosystem, but I don't think it should be a prerequisite for druntime. I recommend keeping it as a separate project in Deimos, and leave it to the programmer to implement the syscalls if they choose to employ it.

Mike

Reply via email to