mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 05:08:14 +00:00
mem/virtual: use sysconf for retrieving page size and actually use these init procs
This commit is contained in:
@@ -7,6 +7,11 @@ _ :: runtime
|
|||||||
|
|
||||||
DEFAULT_PAGE_SIZE := uint(4096)
|
DEFAULT_PAGE_SIZE := uint(4096)
|
||||||
|
|
||||||
|
@(init, private)
|
||||||
|
platform_memory_init :: proc() {
|
||||||
|
_platform_memory_init()
|
||||||
|
}
|
||||||
|
|
||||||
Allocator_Error :: mem.Allocator_Error
|
Allocator_Error :: mem.Allocator_Error
|
||||||
|
|
||||||
@(require_results)
|
@(require_results)
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ _protect :: proc "contextless" (data: rawptr, size: uint, flags: Protect_Flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_platform_memory_init :: proc() {
|
_platform_memory_init :: proc() {
|
||||||
DEFAULT_PAGE_SIZE = posix.PAGE_SIZE
|
// NOTE: `posix.PAGESIZE` due to legacy reasons could be wrong so we use `sysconf`.
|
||||||
|
size := posix.sysconf(._PAGESIZE)
|
||||||
|
DEFAULT_PAGE_SIZE = uint(max(size, posix.PAGESIZE))
|
||||||
|
|
||||||
// is power of two
|
// is power of two
|
||||||
assert(DEFAULT_PAGE_SIZE != 0 && (DEFAULT_PAGE_SIZE & (DEFAULT_PAGE_SIZE-1)) == 0)
|
assert(DEFAULT_PAGE_SIZE != 0 && (DEFAULT_PAGE_SIZE & (DEFAULT_PAGE_SIZE-1)) == 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user