Repository Guidelines
Project Structure & Module Organization
- Core C sources live at the repo root (
main.c,lib.c,malloc.c) with headers alongside. Keep public interfaces in*.hand implementations in matching*.c/*.cpp. - Assembly entry points and syscall shims are in
entry.asm,syscalls.asm, andutils.asm. Prefer adding new low-level routines there rather than inlined asm. - The C++ launcher is
writer.cppcallingc_mainfrommain.h. - Build artifacts collect under
build/, while the linked outputssyscalls(ELF) andsyscalls.binstay in the root. Avoid checking in anything underbuild/or*.bin.
Build, Test, and Development Commands
make: compile C, C++, and NASM sources intobuild/, linksyscalls, and emitsyscalls.binviaobjcopy.make clean: removebuild/,syscalls, andsyscalls.bin../syscalls: run the built ELF to sanity-check argv/env printing and hostname readout.- Toolchain expectations:
gcc,g++,nasm, andldavailable for x86_64 Linux; no external libs beyond glibc headers used for type definitions.
Coding Style & Naming Conventions
- C/C++: use 4-space indentation, no tabs; keep functions small and syscall-oriented. Avoid pulling in the standard library at runtime—use the syscall wrappers in
syscalls.hand helpers inlib.c. - Assembly: NASM syntax with
default rel; keep labels lowercase with underscores. - Names: match header/impl pairs (
foo.h/foo.c), keep globals prefixed clearly (e.g.,sys_,mem_), and avoid anonymous magic numbers—prefer small#defines near use.
Testing Guidelines
- No formal test harness is present; lean on
./syscallsfor manual sanity checks. - When adding functionality, create minimal repro code in
main.cor a temporary helper underbuild/to validate new syscalls or allocator changes before integrating. - If adding scripts or tests, keep them self-contained and runnable via
make test-style phony targets.
Commit & Pull Request Guidelines
- Commit messages follow short, imperative phrasing seen in history (e.g.,
add default rel,change main to return). Keep scope narrow and commits small. - Pull requests should state intent, list key changes, and mention how you validated (commands run, manual checks). Link any relevant issues and note ABI or syscall-surface changes explicitly.
- Include screenshots or logs only when they clarify runtime behavior (e.g., sample
./syscallsoutput after new features).