3 ms·
> Meanwhile, it is trivial to stack-allocate a buffer for writing your log-line and flush it out with a single write(). Indeed! Writing freestanding C while u
by matheusmoreira 6y ago
> Meanwhile, it is trivial to stack-allocate a buffer for writing your log-line and flush it out with a single write().
Indeed! Writing freestanding C while usiing Linux system calls directly was a great experience. I had to rewrite a lot of functionality but everything was explicit and there was no need to worry about old C library stuff like FILE pointers, I/O buffers or thread-local errno.
Even the glibc system call stubs can be a lot more complex than they seem. Many of them have a lot of hidden functionality, something to do with system call cancellation. The kernel's own nolibc.h provides a much better way to make system calls:
https://github.com/torvalds/linux/blob/master/tools/include/nolibc/nolibc.h https://github.com/torvalds/linux/blob/master/tools/include/...