Fix Android again maybe pt 2

This commit is contained in:
wheremyfoodat 2024-11-30 18:00:28 +02:00
parent f422825427
commit a576467a84
2 changed files with 13 additions and 6 deletions

View file

@ -630,7 +630,7 @@ if(ENABLE_HTTP_SERVER)
target_compile_definitions(AlberCore PRIVATE PANDA3DS_ENABLE_HTTP_SERVER=1)
endif()
if(ENABLE_FASTMEM AND NOT ANDROID)
if(ENABLE_FASTMEM)
target_compile_definitions(AlberCore PRIVATE PANDA3DS_HARDWARE_FASTMEM=1)
endif()

View file

@ -5,6 +5,10 @@
#define ARCHITECTURE_arm64
#endif
#ifndef __ANDROID__
#define USING_FD
#endif
#ifdef _WIN32
#include <windows.h>
@ -34,12 +38,15 @@
#define MAP_NORESERVE 0
#endif
#endif // ^^^ Linux ^^^
#ifndef __ANDROID__
#define USING_FD
#ifdef USING_FD
#define MAYBE_ANONYMOUS(flags) (flags)
#else
#define MAYBE_ANONYMOUS(flags) (flags) | MAP_ANONYMOUS
#endif
#endif // ^^^ Linux ^^^
#include <cstring>
#include <mutex>
#include <random>
@ -460,7 +467,7 @@ namespace Common {
throw std::bad_alloc{};
}
#endif
backing_base = static_cast<u8*>(mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0));
backing_base = static_cast<u8*>(mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAYBE_ANONYMOUS(MAP_SHARED), fd, 0));
if (backing_base == MAP_FAILED) {
Helpers::warn("mmap failed: {}", strerror(errno));
@ -504,7 +511,7 @@ namespace Common {
}
#endif
void* ret = mmap(virtual_base + virtual_offset, length, flags, MAP_SHARED | MAP_FIXED, fd, host_offset);
void* ret = mmap(virtual_base + virtual_offset, length, flags, MAYBE_ANONYMOUS(MAP_SHARED | MAP_FIXED), fd, host_offset);
ASSERT_MSG(ret != MAP_FAILED, "mmap failed: {}", strerror(errno));
}