Fixed incorrect const values

This commit is contained in:
2025-02-21 13:47:56 +01:00
parent 04ece57b27
commit 1ca61190eb
22 changed files with 93 additions and 92 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
View 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
View 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
View 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
View 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)
}