fix freebsd SIGBUS

This commit is contained in:
lizzie 2026-02-25 17:24:14 +00:00
parent 9b1796a790
commit dd33069420
2 changed files with 5 additions and 2 deletions

View File

@ -632,7 +632,7 @@ struct AddressSpace::Impl {
mmap(reinterpret_cast<void*>(USER_MIN), user_size, protection_flags, map_flags, -1, 0));
#else
const auto virtual_size = system_managed_size + system_reserved_size + user_size;
#if defined(ARCH_X86_64)
#if defined(ARCH_X86_64) && !defined(__FreeBSD__)
const auto virtual_base =
reinterpret_cast<u8*>(mmap(reinterpret_cast<void*>(SYSTEM_MANAGED_MIN), virtual_size,
protection_flags, map_flags, -1, 0));
@ -640,8 +640,10 @@ struct AddressSpace::Impl {
system_reserved_base = reinterpret_cast<u8*>(SYSTEM_RESERVED_MIN);
user_base = reinterpret_cast<u8*>(USER_MIN);
#else
// FreeBSD can't stand MAP_FIXED or it may overwrite mmap() itself!
// Map memory wherever possible and instruction translation can handle offsetting to the
// base.
map_flags &= ~MAP_FIXED;
const auto virtual_base =
reinterpret_cast<u8*>(mmap(nullptr, virtual_size, protection_flags, map_flags, -1, 0));
system_managed_base = virtual_base;

View File

@ -141,7 +141,8 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameControllers* controller
window_info.type = WindowSystemType::Windows;
window_info.render_surface = SDL_GetPointerProperty(SDL_GetWindowProperties(window),
SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
#elif defined(SDL_PLATFORM_LINUX)
#elif defined(SDL_PLATFORM_LINUX) || defined(__FreeBSD__)
// SDL doesn't have a platform define for FreeBSD AAAAAAAAAA
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) {
window_info.type = WindowSystemType::X11;
window_info.display_connection = SDL_GetPointerProperty(