57 lines
2.0 KiB
Markdown
57 lines
2.0 KiB
Markdown
# elibc — Standard C Library for Elyz
|
|
|
|
Minimal C library for the Elyz OS, based on musl's organisational principles
|
|
but adapted to Elyz's capability-based, syscall-less architecture.
|
|
|
|
## Structure
|
|
|
|
```
|
|
elibc/
|
|
├── arch/ # Architecture-specific code
|
|
│ ├── generic/ # Fallback implementation & abstract interfaces
|
|
│ │ ├── kcall.h # Kernel-call abstraction (no syscalls in Elyz)
|
|
│ │ ├── startup_info.h # Process-startup description
|
|
│ │ └── bits/ # Type-size definitions
|
|
│ └── x86_64/ # x86_64 port
|
|
│ ├── kcall.h # Kernel-call placeholder (ABI TBD)
|
|
│ ├── startup_info.h # x86_64 startup layout (ABI TBD)
|
|
│ ├── atomic_arch.h # Locked cmpxchg / atomic ops
|
|
│ └── bits/
|
|
├── include/ # Public headers (POSIX-like API)
|
|
├── src/ # Source implementations
|
|
│ ├── internal/ # Libc state, errno, bump allocator (temporary)
|
|
│ ├── string/ # Pure-C string ops (memcpy, strlen, etc.)
|
|
│ ├── stdio/ # (reserved)
|
|
│ └── stdlib/ # atoi, etc.
|
|
├── crt/ # C runtime entry point
|
|
├── Makefile
|
|
└── configure
|
|
```
|
|
|
|
## Key differences from a traditional libc (glibc/musl)
|
|
|
|
| Traditional (Linux) | Elyz / elibc |
|
|
|---|---|
|
|
| `syscall`/`int 0x80` | Capability invocation → PM Actor messaging |
|
|
| `brk`/`sbrk` | `ELYZ_OP_ALLOCATE` via `elyz_kcall` |
|
|
| `_exit` syscall | `ELYZ_OP_EXIT` via kcall |
|
|
| `errno` via TLS | `__errno_location` (plain global for now) |
|
|
|
|
## Porting to a new arch
|
|
|
|
1. Create `arch/<name>/` with:
|
|
- `kcall.h` — kernel-call mechanism
|
|
- `startup_info.h` — process-startup layout
|
|
- `arch.mak` — arch-specific compiler/linker flags
|
|
- `bits/alltypes.h.in` — type sizes
|
|
- `atomic_arch.h` — atomic ops (optional, fallback exists)
|
|
2. Add detection in `configure`
|
|
3. Build: `./configure && make`
|
|
|
|
## Building
|
|
|
|
```
|
|
./configure
|
|
make
|
|
```
|