Implemented basic support for function pointers
This commit is contained in:
parent
47f2bc7947
commit
860795c1ec
8 changed files with 166 additions and 15 deletions
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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue