mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 05:08:14 +00:00
Use contextless where possible
This commit is contained in:
@@ -58,7 +58,7 @@ madvise :: proc "contextless" (addr: rawptr, length: uint, advice: c.int) -> c.i
|
||||
}
|
||||
|
||||
|
||||
_reserve :: proc(size: uint) -> (data: []byte, err: Allocator_Error) {
|
||||
_reserve :: proc "contextless" (size: uint) -> (data: []byte, err: Allocator_Error) {
|
||||
MAP_FAILED := rawptr(~uintptr(0))
|
||||
result := mmap(nil, size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
|
||||
if result == MAP_FAILED {
|
||||
@@ -67,7 +67,7 @@ _reserve :: proc(size: uint) -> (data: []byte, err: Allocator_Error) {
|
||||
return ([^]byte)(result)[:size], nil
|
||||
}
|
||||
|
||||
_commit :: proc(data: rawptr, size: uint) -> Allocator_Error {
|
||||
_commit :: proc "contextless" (data: rawptr, size: uint) -> Allocator_Error {
|
||||
result := mprotect(data, size, PROT_READ|PROT_WRITE)
|
||||
if result != 0 {
|
||||
// TODO(bill): Handle error value correctly
|
||||
@@ -75,14 +75,14 @@ _commit :: proc(data: rawptr, size: uint) -> Allocator_Error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
_decommit :: proc(data: rawptr, size: uint) {
|
||||
_decommit :: proc "contextless" (data: rawptr, size: uint) {
|
||||
mprotect(data, size, PROT_NONE)
|
||||
madvise(data, size, MADV_FREE)
|
||||
}
|
||||
_release :: proc(data: rawptr, size: uint) {
|
||||
_release :: proc "contextless" (data: rawptr, size: uint) {
|
||||
munmap(data, size)
|
||||
}
|
||||
_protect :: proc(data: rawptr, size: uint, flags: Protect_Flags) -> bool {
|
||||
_protect :: proc "contextless" (data: rawptr, size: uint, flags: Protect_Flags) -> bool {
|
||||
pflags: c.int
|
||||
pflags = PROT_NONE
|
||||
if .Read in flags { pflags |= PROT_READ }
|
||||
|
||||
Reference in New Issue
Block a user