Files
ww/lib/c/libc/libc.ww
Hojun-Cho 1657bdeda3 ww: import toolchain — C bootstrap + ww-side self-host (phases 0-10)
C bootstrap (phases 0-9):
  cmd/wwc, cmd/6c, cmd/6a, cmd/6l, cmd/ww, rt, lib/*.

ww-side self-host (phase 10):
  selfhost/cmd/wwc — ww-cgen frontend; bootstrap fixed point.
  selfhost/cmd/6a  — assembler; byte-identical to C 6a (test 991).
  selfhost/cmd/6l  — linker w/ archive (.a) support; byte-identical
                     to C 6l (test 992).
  selfhost/cmd/ww  — driver (build/run/version); byte-identical to
                     C ww (test 993).

make test: 15/15. make bootstrap: ww2.s == ww3.s, ww2.o == ww3.o,
ww2 == ww3 byte-identical, with the full ww-tooled chain.
2026-05-11 02:17:47 +09:00

23 lines
969 B
Plaintext

// lib/c/libc — minimal libc bindings. Each declaration is body-less,
// imported from the C side at link time. The @symbol attribute pins
// the linker name; without it, the binding name itself is used.
//
// These declarations cover the small surface the bootstrap wants:
// process exit, three io syscalls, and the malloc/free pair. Higher
// ergonomics live in sibling pure-ww packages.
@symbol("malloc") fn malloc(n: u64) *void;
@symbol("free") fn free(p: *void) void;
@symbol("calloc") fn calloc(n: u64, sz: u64) *void;
@symbol("read") fn read(fd: i32, buf: *u8, n: u64) i64;
@symbol("write") fn write(fd: i32, buf: *u8, n: u64) i64;
@symbol("open") fn open(path: *u8, flags: i32, mode: i32) i32;
@symbol("close") fn close(fd: i32) i32;
@symbol("exit") fn exit(code: i32) void;
@symbol("strlen") fn strlen(s: *u8) u64;
@symbol("memcpy") fn memcpy(dst: *void, src: *void, n: u64) *void;
@symbol("memset") fn memset(p: *void, b: i32, n: u64) *void;