diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2024-08-29 14:36:32 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2024-08-29 14:36:32 +0200 |
| commit | fd2ad20cd4b24fa0260f5efaf8211fb035dc102c (patch) | |
| tree | 25ca9be1998ca2c9637f64a13f1a336d7bf43673 | |
| parent | 1e6419b5b7bdafe3f1d1a2b4321238b6257c44e6 (diff) | |
mem/virtual: use `sysconf` for retrieving page size and actually use these init procs
| -rw-r--r-- | core/mem/virtual/virtual.odin | 5 | ||||
| -rw-r--r-- | core/mem/virtual/virtual_posix.odin | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/core/mem/virtual/virtual.odin b/core/mem/virtual/virtual.odin index 4e53aba66..4afc33813 100644 --- a/core/mem/virtual/virtual.odin +++ b/core/mem/virtual/virtual.odin @@ -7,6 +7,11 @@ _ :: runtime DEFAULT_PAGE_SIZE := uint(4096) +@(init, private) +platform_memory_init :: proc() { + _platform_memory_init() +} + Allocator_Error :: mem.Allocator_Error @(require_results) diff --git a/core/mem/virtual/virtual_posix.odin b/core/mem/virtual/virtual_posix.odin index fbe89abfa..035763466 100644 --- a/core/mem/virtual/virtual_posix.odin +++ b/core/mem/virtual/virtual_posix.odin @@ -51,8 +51,10 @@ _protect :: proc "contextless" (data: rawptr, size: uint, flags: Protect_Flags) } _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 assert(DEFAULT_PAGE_SIZE != 0 && (DEFAULT_PAGE_SIZE & (DEFAULT_PAGE_SIZE-1)) == 0) } |