Something went wrong. Try again.
馃尡 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
12345678910111213141516171819202122232425import memimport processglobal { // Set by the linker to the size of the thread-local block. tlsSize uint64}create(func ()) -> (tid int) { stack := mem.mmap(0, STACK_SIZE, mem.read|mem.write, mem.private|mem.anonymous, -1, 0) tls := stack + STACK_SIZE - tlsSize args := tls - process.CLONE_ARGS_SIZE as *process.CloneArgs args.flags = CLONE_THREAD | CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_IO | CLONE_SIGHAND | CLONE_SETTLS args.stack = stack as uint64 args.stack_size = STACK_SIZE - tlsSize args.tls = tls as uint64 tid := syscall(process._clone3, args, process.CLONE_ARGS_SIZE) as int if tid == 0 { func() syscall(_exit, 0) } return tid}