os

An operating system
git clone https://erai.gay/code/os/
Log | Files | Refs | README | LICENSE

commit 82543c91aae01d0798fe0cff438a9e8904037eb0
parent 09b26a0a50456b5eaf779fcc1d1322eef10732ab
Author: erai <erai@omiltem.net>
Date:   Sat, 15 Feb 2025 20:53:01 +0000

fewer magic numbers in alloc.om

Diffstat:
Malloc.om | 6+++++-
Msyscall.om | 8++++++++
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/alloc.om b/alloc.om @@ -22,10 +22,14 @@ func alloc(c: *alloc, size: int): *byte { die("invalid alloc"); } + if size == 0 { + return nil; + } + if (size >= 2048) { size = size + 4095; size = size & ~4095; - mret = mmap(0, size, 3, 0x22, -1, 0); + mret = mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0); if (mret == -1) { die("out of memory"); } diff --git a/syscall.om b/syscall.om @@ -22,6 +22,14 @@ enum { POLLHUP = 0x10, POLLNVAL = 0x20, + PROT_NONE = 0x0, + PROT_READ = 0x1, + PROT_WRITE = 0x2, + PROT_EXEC = 0x4, + + MAP_PRIVATE = 0x02, + MAP_ANON = 0x20, + WNOHANG = 1, SIG_DFL = 0,