Fixed incorrect const values
This commit is contained in:
@ -8,7 +8,7 @@ number(x int) {
|
||||
mem.free(buffer)
|
||||
}
|
||||
|
||||
itoa(x int, buffer []byte) -> (*any, int) {
|
||||
itoa(x int, buffer []byte) -> (*byte, int) {
|
||||
end := buffer + len(buffer)
|
||||
tmp := end
|
||||
digit := 0
|
||||
|
@ -1,22 +0,0 @@
|
||||
import sys
|
||||
|
||||
alloc(length int) -> []byte {
|
||||
x := sys.mmap(0, length+8, prot.read|prot.write, map.private|map.anonymous)
|
||||
|
||||
if x < 0x1000 {
|
||||
return x
|
||||
}
|
||||
|
||||
store(x, 8, length)
|
||||
return x + 8
|
||||
}
|
||||
|
||||
const prot {
|
||||
read 0x1
|
||||
write 0x2
|
||||
}
|
||||
|
||||
const map {
|
||||
private 0x02
|
||||
anonymous 0x1000
|
||||
}
|
@ -9,14 +9,4 @@ alloc(length int) -> []byte {
|
||||
|
||||
store(x, 8, length)
|
||||
return x + 8
|
||||
}
|
||||
|
||||
const prot {
|
||||
read 0x1
|
||||
write 0x2
|
||||
}
|
||||
|
||||
const map {
|
||||
private 0x02
|
||||
anonymous 0x20
|
||||
}
|
@ -1,7 +1,9 @@
|
||||
import sys
|
||||
extern kernel32 {
|
||||
VirtualAlloc(address int, size uint, flags uint32, protection uint32) -> *any
|
||||
}
|
||||
|
||||
alloc(length int) -> []byte {
|
||||
x := sys.mmap(0, length+8, page.readwrite, mem.commit|mem.reserve)
|
||||
x := kernel32.VirtualAlloc(0, length+8, mem.commit|mem.reserve, page.readwrite)
|
||||
|
||||
if x < 0x1000 {
|
||||
return x
|
||||
@ -9,13 +11,4 @@ alloc(length int) -> []byte {
|
||||
|
||||
store(x, 8, length)
|
||||
return x + 8
|
||||
}
|
||||
|
||||
const page {
|
||||
readwrite 0x0004
|
||||
}
|
||||
|
||||
const mem {
|
||||
commit 0x1000
|
||||
reserve 0x2000
|
||||
}
|
9
lib/mem/const_linux.q
Normal file
9
lib/mem/const_linux.q
Normal file
@ -0,0 +1,9 @@
|
||||
const prot {
|
||||
read 0x1
|
||||
write 0x2
|
||||
}
|
||||
|
||||
const map {
|
||||
private 0x02
|
||||
anonymous 0x20
|
||||
}
|
9
lib/mem/const_mac.q
Normal file
9
lib/mem/const_mac.q
Normal file
@ -0,0 +1,9 @@
|
||||
const prot {
|
||||
read 0x1
|
||||
write 0x2
|
||||
}
|
||||
|
||||
const map {
|
||||
private 0x02
|
||||
anonymous 0x1000
|
||||
}
|
9
lib/mem/const_windows.q
Normal file
9
lib/mem/const_windows.q
Normal file
@ -0,0 +1,9 @@
|
||||
const page {
|
||||
readwrite 0x0004
|
||||
}
|
||||
|
||||
const mem {
|
||||
commit 0x1000
|
||||
reserve 0x2000
|
||||
decommit 0x4000
|
||||
}
|
7
lib/mem/free_windows.q
Normal file
7
lib/mem/free_windows.q
Normal file
@ -0,0 +1,7 @@
|
||||
extern kernel32 {
|
||||
VirtualFree(address *any, size uint, type uint32) -> bool
|
||||
}
|
||||
|
||||
free(address []any) -> int {
|
||||
return kernel32.VirtualFree(address-8, len(address)+8, mem.decommit)
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
read(fd int, buffer *any, length int) -> int {
|
||||
read(fd int, buffer *byte, length int) -> int {
|
||||
return syscall(0, fd, buffer, length)
|
||||
}
|
||||
|
||||
write(fd int, buffer *any, length int) -> int {
|
||||
write(fd int, buffer *byte, length int) -> int {
|
||||
return syscall(1, fd, buffer, length)
|
||||
}
|
||||
|
||||
@ -14,16 +14,16 @@ close(fd int) -> int {
|
||||
return syscall(3, fd)
|
||||
}
|
||||
|
||||
mmap(address int, length int, protection int, flags int) -> *any {
|
||||
mmap(address int, length uint, protection int, flags int) -> *any {
|
||||
return syscall(9, address, length, protection, flags)
|
||||
}
|
||||
|
||||
munmap(address *any, length int) -> int {
|
||||
munmap(address *any, length uint) -> int {
|
||||
return syscall(11, address, length)
|
||||
}
|
||||
|
||||
clone(flags int, stack *any) -> int {
|
||||
return syscall(56, flags, stack)
|
||||
clone(flags uint, stack *any, parent *int, child *int, tls uint) -> int {
|
||||
return syscall(56, flags, stack, parent, child, tls)
|
||||
}
|
||||
|
||||
fork() -> int {
|
||||
|
@ -1,8 +1,8 @@
|
||||
read(fd int, buffer *any, length int) -> int {
|
||||
read(fd int, buffer *byte, length int) -> int {
|
||||
return syscall(0x2000003, fd, buffer, length)
|
||||
}
|
||||
|
||||
write(fd int, buffer *any, length int) -> int {
|
||||
write(fd int, buffer *byte, length int) -> int {
|
||||
return syscall(0x2000004, fd, buffer, length)
|
||||
}
|
||||
|
||||
|
@ -1,31 +1,17 @@
|
||||
read(fd int64, buffer *any, length int64) -> int64 {
|
||||
read(fd int64, buffer *byte, length int64) -> int64 {
|
||||
fd = kernel32.GetStdHandle(-10 - fd)
|
||||
kernel32.ReadConsole(fd, buffer, length, 0)
|
||||
return length
|
||||
}
|
||||
|
||||
write(fd int64, buffer *any, length int64) -> int64 {
|
||||
write(fd int64, buffer *byte, length int64) -> int64 {
|
||||
fd = kernel32.GetStdHandle(-10 - fd)
|
||||
kernel32.WriteConsoleA(fd, buffer, length, 0)
|
||||
return length
|
||||
}
|
||||
|
||||
mmap(address int, length int, protection int, flags int) -> *any {
|
||||
return kernel32.VirtualAlloc(address, length, flags, protection)
|
||||
}
|
||||
|
||||
munmap(address *any, length int) -> int {
|
||||
return kernel32.VirtualFree(address, length, mem.decommit)
|
||||
}
|
||||
|
||||
const mem {
|
||||
decommit 0x4000
|
||||
}
|
||||
|
||||
extern kernel32 {
|
||||
GetStdHandle(handle int64) -> int64
|
||||
ReadConsole(fd int64, buffer *any, length uint32, written *uint32) -> bool
|
||||
VirtualAlloc(address int, length int, flags int, protection int)
|
||||
VirtualFree(address *any, length int, type int) -> bool
|
||||
WriteConsoleA(fd int64, buffer *any, length uint32, written *uint32) -> bool
|
||||
ReadConsole(fd int64, buffer *byte, length uint32, written *uint32) -> bool
|
||||
WriteConsoleA(fd int64, buffer *byte, length uint32, written *uint32) -> bool
|
||||
}
|
@ -19,5 +19,5 @@ create(func *any) -> int {
|
||||
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)
|
||||
return sys.clone(clone.vm|clone.fs|clone.files|clone.sighand|clone.parent|clone.thread|clone.io, stack, 0, 0, 0)
|
||||
}
|
Reference in New Issue
Block a user