aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaranBr <maranbr@outlook.com>2025-08-29 14:20:22 +0200
committercrueter <crueter@eden-emu.dev>2025-08-29 14:20:22 +0200
commit57fbdd516ee03ef7a52b9a1ba54bf866f24da53a (patch)
treef02f120f837083ee8cd84f8d87ee5ba30a752425
parentf07309afd2a360d555938d458c4430e02b9e9987 (diff)
[host_memory] Fix a bunch of memory errors on Windows (#303)
This fixes a bunch of memory errors that could happen on Windows. Possibly regression introduced on PR 187. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/303 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: MaranBr <maranbr@outlook.com> Co-committed-by: MaranBr <maranbr@outlook.com>
-rw-r--r--src/common/host_memory.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp
index f847ea2a62..edb64de8ec 100644
--- a/src/common/host_memory.cpp
+++ b/src/common/host_memory.cpp
@@ -417,11 +417,15 @@ static void* ChooseVirtualBase(size_t virtual_size) {
#else
static void* ChooseVirtualBase(size_t virtual_size) {
+#if defined(__OpenBSD__) || defined(__sun__) || defined(__HAIKU__) || defined(__managarm__)
void* virtual_base = mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_ALIGNED_SUPER, -1, 0);
- if (virtual_base != MAP_FAILED)
+
+ if (virtual_base != MAP_FAILED) {
return virtual_base;
- return mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
+ }
+#endif
+
+ return mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0);
}
#endif