Added a program init function
This commit is contained in:
8
lib/core/core_linux.q
Normal file
8
lib/core/core_linux.q
Normal file
@ -0,0 +1,8 @@
|
||||
init() {
|
||||
main.main()
|
||||
exit()
|
||||
}
|
||||
|
||||
exit() {
|
||||
syscall(60, 0)
|
||||
}
|
8
lib/core/core_mac.q
Normal file
8
lib/core/core_mac.q
Normal file
@ -0,0 +1,8 @@
|
||||
init() {
|
||||
main.main()
|
||||
exit()
|
||||
}
|
||||
|
||||
exit() {
|
||||
syscall(0x2000001, 0)
|
||||
}
|
20
lib/core/core_windows.q
Normal file
20
lib/core/core_windows.q
Normal file
@ -0,0 +1,20 @@
|
||||
extern kernel32 {
|
||||
SetConsoleCP(cp UInt)
|
||||
SetConsoleOutputCP(cp UInt)
|
||||
ExitProcess(code UInt)
|
||||
}
|
||||
|
||||
const cp {
|
||||
utf8 65001
|
||||
}
|
||||
|
||||
init() {
|
||||
kernel32.SetConsoleCP(cp.utf8)
|
||||
kernel32.SetConsoleOutputCP(cp.utf8)
|
||||
main.main()
|
||||
exit()
|
||||
}
|
||||
|
||||
exit() {
|
||||
kernel32.ExitProcess(0)
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
import core
|
||||
import sys
|
||||
|
||||
const clone {
|
||||
@ -15,7 +16,7 @@ create(func *Any) -> Int {
|
||||
stack := sys.mmap(0, size, 0x1|0x2, 0x02|0x20|0x100|0x20000)
|
||||
stack += size
|
||||
stack -= 8
|
||||
store(stack, 8, _exit)
|
||||
store(stack, 8, core.exit)
|
||||
stack -= 8
|
||||
store(stack, 8, func)
|
||||
return sys.clone(clone.vm|clone.fs|clone.files|clone.sighand|clone.parent|clone.thread|clone.io, stack)
|
||||
|
Reference in New Issue
Block a user