Reduced number of packages
This commit is contained in:
parent
e04598da3e
commit
dfc39f1f04
12 changed files with 36 additions and 69 deletions
7
src/compiler/Linux.go
Normal file
7
src/compiler/Linux.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
package compiler
|
||||
|
||||
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/x86/entry/syscalls/syscall_64.tbl
|
||||
const (
|
||||
LinuxWrite = 1
|
||||
LinuxExit = 60
|
||||
)
|
10
src/compiler/Mac.go
Normal file
10
src/compiler/Mac.go
Normal file
|
@ -0,0 +1,10 @@
|
|||
package compiler
|
||||
|
||||
// Syscall numbers are divided into classes, here we need the BSD inherited syscalls.
|
||||
const classUnix = 0x2000000
|
||||
|
||||
// https://github.com/apple-oss-distributions/xnu/blob/main/bsd/kern/syscalls.master
|
||||
const (
|
||||
MacExit = 1 | classUnix
|
||||
MacWrite = 4 | classUnix
|
||||
)
|
|
@ -11,11 +11,8 @@ import (
|
|||
"git.akyoto.dev/cli/q/src/core"
|
||||
"git.akyoto.dev/cli/q/src/dll"
|
||||
"git.akyoto.dev/cli/q/src/elf"
|
||||
"git.akyoto.dev/cli/q/src/linux"
|
||||
"git.akyoto.dev/cli/q/src/mac"
|
||||
"git.akyoto.dev/cli/q/src/macho"
|
||||
"git.akyoto.dev/cli/q/src/pe"
|
||||
"git.akyoto.dev/cli/q/src/windows"
|
||||
"git.akyoto.dev/cli/q/src/x64"
|
||||
)
|
||||
|
||||
|
@ -42,15 +39,15 @@ func (r *Result) finalize() ([]byte, []byte, dll.List) {
|
|||
|
||||
switch config.TargetOS {
|
||||
case "linux":
|
||||
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[0], linux.Exit)
|
||||
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[0], LinuxExit)
|
||||
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[1], 0)
|
||||
final.Syscall()
|
||||
case "mac":
|
||||
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[0], mac.Exit)
|
||||
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[0], MacExit)
|
||||
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[1], 0)
|
||||
final.Syscall()
|
||||
case "windows":
|
||||
final.RegisterNumber(asm.MOVE, windows.X64InputRegisters[0], 0)
|
||||
final.RegisterNumber(asm.MOVE, x64.WindowsInputRegisters[0], 0)
|
||||
final.DLLCall("kernel32.ExitProcess")
|
||||
}
|
||||
|
||||
|
@ -74,15 +71,15 @@ func (r *Result) finalize() ([]byte, []byte, dll.List) {
|
|||
|
||||
switch config.TargetOS {
|
||||
case "linux":
|
||||
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[0], linux.Exit)
|
||||
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[0], LinuxExit)
|
||||
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[1], 1)
|
||||
final.Syscall()
|
||||
case "mac":
|
||||
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[0], mac.Exit)
|
||||
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[0], MacExit)
|
||||
final.RegisterNumber(asm.MOVE, x64.SyscallInputRegisters[1], 1)
|
||||
final.Syscall()
|
||||
case "windows":
|
||||
final.RegisterNumber(asm.MOVE, windows.X64InputRegisters[0], 1)
|
||||
final.RegisterNumber(asm.MOVE, x64.WindowsInputRegisters[0], 1)
|
||||
final.DLLCall("kernel32.ExitProcess")
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue