Files
2026-12-06 13:37:43 -06:00

2.4 KiB

system

The layer of the Sakura programming language beneath its standard library that talks to the operating system, and the only one that knows which system it runs on. std's std::io is written once over it, for every system, and is what programs use; this layer is for what std::io doesn't cover.

It reads core alone, which ships with the compiler, sakurac, and is versioned apart from both.

Module What it holds
system Files and directories, who may use them, processes, signals, clocks, threads, and io_error, why an operation failed: the same operations on every system
system::linux Linux's system calls, each declared once
system::windows The functions of kernel32.dll, each declared once

Using it

A program reading std reads system too, since std requires it: blossom gives it to sakurac as --lib system=DIR, as it gives any library. A project reading it directly requires it as any package and lists it in its deps:

requires:
- https://git.malunal.studio/sakura/system@v1.0.0

targets:
- name: tool
  type: program
  deps: [system]

Without blossom, sakurac is given it the same way, as --lib system=DIR, or finds it in the share/sakura folder nearest above itself, where blossom install puts it.

Supporting another system

Each system implements the same operations in a section of its own, as on_linux.sakura and on_windows.sakura do, with the numbers that differ by processor in another, as on_linux_x86_64.sakura. Another system is supported by writing those two, with the same names and signatures, and nothing above this layer changes. system.sakura lists the operations each system provides.

The compiler

The compiler relies on two things of system by name: system::handle, whose signals system::dispatch handles, which the compiler calls where nothing written does, and the system calls, whose memory the machine tracks as a checked program runs. A change to either is chosen by the compiler's version, as when compiler >= 1.2.0 { ... }, so each release of the compiler reads the system it understands.

Tests

blossom test

runs system.tests, the tests of signals, with std's repository beside this one. Each test runs in a copy of the program, so what one does with a signal is its own.