libc - Freestanding standard library
Makar ships a minimal freestanding C library (libc/) that provides just
enough of the standard C interface for the kernel to compile against. It is
not a full POSIX libc - it exists solely to satisfy the #include
dependencies of the kernel and its subdirectories.
Modules
| Header | Source(s) | Description |
|---|---|---|
stdio.h |
stdio/printf.c, putchar.c, puts.c |
Formatted and character output. |
stdlib.h |
stdlib/abort.c |
Abnormal termination. |
string.h |
string/mem*.c, strlen.c |
Memory and string utilities. |
sys/cdefs.h |
- | Compiler/libc identification macros. |
sys/cdefs.h
#define __makar_libc 1
Identifies this as the Makar freestanding libc. Code that needs to detect
the Makar environment at compile time can test #ifdef __makar_libc.
Design notes
- All sources are compiled with
-ffreestanding- no hosted runtime is available. putcharis the single output primitive;printfandputsare built on top of it. The kernel’stty.csupplies the concreteputcharimplementation via the linker.- No dynamic memory allocation (
malloc/free) is provided here; the kernel’s ownkmalloc/kfreeheap is used instead. - No floating-point, no locale, no signal handling, no file I/O beyond the terminal.
Future work
- Add
<stdarg.h>-compatiblevprintf/snprintffor safer formatted output in kernel subsystems. - Extend
printfto support%d,%u,%x,%pformat specifiers fully. - Consider a kernel-space
<errno.h>for richer error reporting from syscall stubs.