Fixed incorrect const values
This commit is contained in:
@ -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)
|
||||
}
|
Reference in New Issue
Block a user