Memory Allocation with mmap
# SYS_MMAP, PROT_*, MAP_* constants are provided by the x86_64 backend
let alloc = (size:int):>int => {
return __syscall6__(SYS_MMAP 0 size (PROT_READ or PROT_WRITE) (MAP_PRIVATE or MAP_ANONYMOUS) (0 - 1) 0)
}
let main = ():>int => {
let buffer:int = alloc(4096)
__store__(42 buffer)
return __load__(buffer) # returns 42
}