Files
danos/library/kernel/system.zig
T
Daniel Samson 60f32ee9ff reorg: split the runtime into library/kernel concern modules (C1)
The one giant `runtime` module (with a `system.zig` that was itself a dumping
ground of unrelated syscalls) is split into directly-importable, flat concern
modules under library/kernel/:

  system-call  ipc  memory  process  thread  time  logging  file-system  service  start
  (+ the device/service clients: device, device-manager, block, display, input)

system.zig is dissolved — its functions moved to their concern home (mmap ->
memory, spawn/kill/exit -> process, sleep/clock -> time, write/klog -> logging,
fs* -> file-system). `memory` merges heap+dma+shared-memory behind one flat API
(memory.allocator/dmaAlloc/sharedCreate/mmap), keeping heap's state and malloc
export single. The memory<->thread dependency cycle (heap needs Thread.Mutex,
thread needs mmap) is broken by having thread allocate its own stack via the raw
mmap syscall, so the module graph is a DAG.

This is the atomic step: all 42 internal cross-imports flip from relative to
module imports at once. `runtime.zig` and `system.zig` become thin re-export
SHIMS so the ~38 consumers keep compiling on `runtime.*` untouched; they migrate
to direct imports in C2, after which the shims are deleted (C5).

zig build + zig build test green; 14 QEMU cases pass (smoke, process,
process-kill, thread-spawn/join, logger, vfs, fat-mount, display-native,
usb-storage, virtio-gpu, device-manager, input, power-button).
2026-07-22 22:53:13 +01:00

67 lines
2.7 KiB
Zig

//! system.zig — a **compatibility shim**, not the real home of anything anymore.
//!
//! The runtime's syscall surface used to be dumped here in one file. It has been split by
//! concern into `time` / `logging` / `process` / `file-system` / `memory`. This re-exports
//! the old flat `system.*` names from those homes so consumers that still write
//! `runtime.system.write` (etc.) keep compiling until they migrate to the concern modules.
//! Deleted once nothing references `runtime.system` (reorg step C5).
const memory = @import("memory");
const process = @import("process");
const time = @import("time");
const logging = @import("logging");
const file_system = @import("file-system");
// memory
pub const PROT_READ = memory.PROT_READ;
pub const PROT_WRITE = memory.PROT_WRITE;
pub const PROT_EXEC = memory.PROT_EXEC;
pub const mmap = memory.mmap;
pub const munmap = memory.munmap;
pub const mmapFailed = memory.mmapFailed;
// process
pub const ProcessDescriptor = process.ProcessDescriptor;
pub const yield = process.yield;
pub const exit = process.exit;
pub const spawn = process.spawn;
pub const spawnWithArguments = process.spawnWithArguments;
pub const spawnSupervised = process.spawnSupervised;
pub const processes = process.processes;
pub const isProcessRunning = process.isProcessRunning;
pub const kill = process.kill;
// time
pub const clock = time.clock;
pub const wallClock = time.wallClock;
pub const sleep = time.sleepMillis;
pub const timerOnce = time.timerOnce;
// logging
pub const write = logging.write;
pub const writeRecord = logging.writeRecord;
pub const klogRead = logging.klogRead;
pub const klogStatus = logging.klogStatus;
pub const KlogLevel = logging.KlogLevel;
pub const KlogStatus = logging.KlogStatus;
pub const KlogRecordHeader = logging.KlogRecordHeader;
pub const klog_record_header_size = logging.klog_record_header_size;
pub const klog_record_alignment = logging.klog_record_alignment;
pub const klog_record_magic = logging.klog_record_magic;
pub const klog_flag_truncated = logging.klog_flag_truncated;
pub const klog_maximum_message = logging.klog_maximum_message;
pub const maximum_process_name = logging.maximum_process_name;
// file-system
pub const FsRoute = file_system.FsRoute;
pub const fsResolve = file_system.fsResolve;
pub const fsNodeRead = file_system.fsNodeRead;
pub const fsNodeStatus = file_system.fsNodeStatus;
pub const fsNodeReaddir = file_system.fsNodeReaddir;
pub const fsMount = file_system.fsMount;
pub const fsUnmount = file_system.fsUnmount;
pub const FileAttributes = file_system.FileAttributes;
pub const DirectoryEntryHeader = file_system.DirectoryEntryHeader;
pub const file_kind_regular = file_system.file_kind_regular;
pub const file_kind_directory = file_system.file_kind_directory;