remove enums

This commit is contained in:
2026-06-26 17:38:55 +02:00
parent 6fe971c615
commit 43a20c99f6
8 changed files with 37 additions and 76 deletions

View File

@@ -1,28 +1,4 @@
const STDIN = 0
const STDOUT = 1
const SIGABRT = 6
const AT_FDCWD = -100
const S_IFDIR = 16384
const S_IFMT = 61440
const PROT_READ = 1
const PROT_WRITE = 2
const MAP_PRIVATE = 2
const MAP_ANONYMOUS = 32
const O_RDONLY = 0
const O_WRONLY = 1
const O_CREAT = 64
const O_TRUNC = 512
const SEEK_SET = 0
const SEEK_END = 2
const F_OK = 0
include "std/posix.zr"
const SYS_read = 0
const SYS_write = 1

27
std/posix.zr Normal file
View File

@@ -0,0 +1,27 @@
const STDIN_FILENO = 0
const STDOUT_FILENO = 1
const SIGABRT = 6
const AT_FDCWD = -100
const S_IFDIR = 16384
const S_IFMT = 61440
const PROT_READ = 1
const PROT_WRITE = 2
const MAP_PRIVATE = 2
const MAP_ANONYMOUS = 32
const O_RDONLY = 0
const O_WRONLY = 1
const O_CREAT = 64
const O_TRUNC = 512
const SEEK_SET = 0
const SEEK_END = 2
const F_OK = 0
const CLOCK_REALTIME = 0

View File

@@ -1,4 +1,4 @@
include "std/linux_constants.zr"
include "std/linux.zr"
func panic[msg: str] : void
io.print("PANIC: ")
@@ -265,7 +265,7 @@ func io.printf[..] : void
s += 1
func io.print_sized[x: ptr, size: i64] : void
_builtin_syscall(SYS_write, STDOUT, x, size)
_builtin_syscall(SYS_write, STDOUT_FILENO, x, size)
func io.print[x: str] : void
io.print_sized(x as ptr, x->len())
@@ -381,7 +381,7 @@ func f64.to_str_buf[x: i64, buf: ptr] : void
func io.read_char[] : u8
c := 0 as u8
_builtin_syscall(SYS_read, STDIN, ^c, 1)
_builtin_syscall(SYS_read, STDIN_FILENO, ^c, 1)
return c
func io.read_line[] : str
@@ -1157,6 +1157,12 @@ func os.sleep[ms: i64] : void
req->tv_nsec = (ms % 1000) * 1000000
_builtin_syscall(SYS_nanosleep, req, 0)
func os.time[] : i64
ts := new os.Timespec
_builtin_syscall(SYS_clock_gettime, CLOCK_REALTIME, ts)
out := ts->tv_sec * 1000 + ts->tv_nsec / 1000000
return out
func os.urandom_buf[buf: ptr, n: i64] : void
pos := 0
while pos < n
@@ -1175,16 +1181,6 @@ func os.urandom_i64[] : i64
os.urandom_buf(^n, 8)
return n
struct os.Timeval
tv_sec: i64
tv_usec: i64
func os.time[] : i64
tv := new os.Timeval
_builtin_syscall(SYS_gettimeofday, tv, 0)
out := tv->tv_sec * 1000 + tv->tv_usec / 1000
return out
func os.run_shell_command[command: str] : i64, bool
pid := _builtin_syscall(SYS_fork)
if pid < 0