Initial Commit

This commit is contained in:
SoraKatadzuma committed 2026-11-19 04:54:17 -06:00
commit f086abcea6
789 files changed
+149185

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
#! @file linux.sakura
#! @author John Christman (sorakatadzuma@gmail.com)
#! @copyright Malunal Studios, LLC.
#! @license MIT
#!
#! Contains `system::linux`: what Linux gives a program, declared once for std
#! and anything else that reaches the system itself. A program reaches Linux by
#! system calls, whose numbers and the layouts of what they read and write
#! differ by processor, so each processor's are in a file of its own, as
#! `x86_64.sakura`.
module system::linux when os == linux;
#! Makes a system call, as the operations here do. Its numbers, and what it
#! reads and writes, are the system's, and differ by processor.
#! @param n The number of the call.
#! @param a Its first argument.
#! @param b Its second.
#! @param c Its third.
#! @param d Its fourth.
#! @param e Its fifth.
#! @param f Its sixth.
#! @returns What the call gives, or the negated error number where it fails.
@intrinsic
pub def syscall(n: i64, a: u64, b: u64, c: u64, d: u64, e: u64, f: u64): i64;
+71
View File
@@ -0,0 +1,71 @@
#! @file x86_64.sakura
#! @author John Christman (sorakatadzuma@gmail.com)
#! @copyright Malunal Studios, LLC.
#! @license MIT
#!
#! Contains what `system::linux` gives of Linux on x86-64.
#!
#! What a program needs to know of Linux on x86-64: the numbers of the system
#! calls it makes, the flags that differ by processor, and
#! where `stat` writes what `file_info` is read from.
module system::linux when os == linux && arch == x86_64;
pub val call_read: i64 = 0;
pub val call_write: i64 = 1;
pub val call_open: i64 = 2;
pub val call_close: i64 = 3;
pub val call_stat: i64 = 4;
pub val call_fstat: i64 = 5;
pub val call_lstat: i64 = 6;
pub val call_poll: i64 = 7;
pub val call_lseek: i64 = 8;
pub val call_mmap: i64 = 9;
pub val call_munmap: i64 = 11;
pub val call_rt_sigaction: i64 = 13;
pub val call_rt_sigprocmask: i64 = 14;
pub val call_dup2: i64 = 33;
pub val call_nanosleep: i64 = 35;
pub val call_getpid: i64 = 39;
pub val call_fork: i64 = 57;
pub val call_execve: i64 = 59;
pub val call_wait4: i64 = 61;
pub val call_kill: i64 = 62;
pub val call_fcntl: i64 = 72;
pub val call_getcwd: i64 = 79;
pub val call_chdir: i64 = 80;
pub val call_rename: i64 = 82;
pub val call_mkdir: i64 = 83;
pub val call_rmdir: i64 = 84;
pub val call_unlink: i64 = 87;
pub val call_chmod: i64 = 90;
pub val call_fchmod: i64 = 91;
pub val call_sched_yield: i64 = 24;
pub val call_rt_sigsuspend: i64 = 130;
pub val call_gettid: i64 = 186;
pub val call_futex: i64 = 202;
pub val call_sched_getaffinity: i64 = 204;
pub val call_getdents64: i64 = 217;
pub val call_clock_gettime: i64 = 228;
pub val call_exit_group: i64 = 231;
pub val call_newfstatat: i64 = 262;
pub val call_pipe2: i64 = 293;
pub val open_directory := 0x10000u;
pub const stat_bytes: u64 = 144;
pub val stat_mode := 24u;
pub val stat_size := 48u;
pub val stat_accessed := 72u; # Seconds, then nanoseconds.
pub val stat_modified := 88u; # Seconds, then nanoseconds.
# What `fcntl` is asked: a copy of a handle at the lowest free number from
# another up, or the handle's flags, of which only close-on-exec is set.
pub val f_dupfd := 0u;
pub val f_setfd := 2u;
# How `rt_sigprocmask` changes the signals held off: adding some, or setting
# all of them.
pub val sig_block := 0u;
pub val sig_setmask := 2u;