Implemented structs

This commit is contained in:
2025-02-04 18:16:31 +01:00
parent 4609a814df
commit 03a3bd8f02
32 changed files with 267 additions and 63 deletions

View File

@ -22,8 +22,8 @@ munmap(address Pointer, length Int) -> Int {
return syscall(11, address, length)
}
nanosleep(timespec Pointer) -> Int {
return syscall(35, timespec, 0)
nanosleep(duration Pointer) -> Int {
return syscall(35, duration, 0)
}
clone(flags Int, stack Pointer) -> Int {

View File

@ -1,4 +1,3 @@
import mem
import sys
sleep(nanoseconds Int) {
@ -8,10 +7,9 @@ sleep(nanoseconds Int) {
seconds, nanoseconds = nanoseconds / 1000000000
}
timespec := mem.alloc(16)
store(timespec, 8, seconds)
offset := timespec + 8
store(offset, 8, nanoseconds)
sys.nanosleep(timespec)
mem.free(timespec, 16)
duration := new(timespec)
duration.seconds = seconds
duration.nanoseconds = nanoseconds
sys.nanosleep(duration)
delete(duration)
}