Implemented basic support for function pointers
This commit is contained in:
23
examples/thread/thread.q
Normal file
23
examples/thread/thread.q
Normal file
@ -0,0 +1,23 @@
|
||||
import mem
|
||||
import sys
|
||||
|
||||
main() {
|
||||
start()
|
||||
start()
|
||||
start()
|
||||
thread()
|
||||
}
|
||||
|
||||
start() {
|
||||
size := 4096
|
||||
stack := mem.alloc(size)
|
||||
pointer := stack + size - 8
|
||||
store(pointer, 8, thread)
|
||||
sys.clone(0x100 | 0x200 | 0x400 | 0x800 | 0x8000 | 0x10000 | 0x80000000, pointer)
|
||||
}
|
||||
|
||||
thread() {
|
||||
sys.write(1, "[ ] start\n", 10)
|
||||
sys.write(1, "[x] end\n", 8)
|
||||
sys.exit(0)
|
||||
}
|
Reference in New Issue
Block a user