Skip to content

Commit 3681080

Browse files
author
lizzie
committed
fix freebsd SIGBUS
1 parent 25cbc11 commit 3681080

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/core/address_space.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,16 +632,18 @@ struct AddressSpace::Impl {
632632
mmap(reinterpret_cast<void*>(USER_MIN), user_size, protection_flags, map_flags, -1, 0));
633633
#else
634634
const auto virtual_size = system_managed_size + system_reserved_size + user_size;
635-
#if defined(ARCH_X86_64)
635+
#if defined(ARCH_X86_64) && !defined(__FreeBSD__)
636636
const auto virtual_base =
637637
reinterpret_cast<u8*>(mmap(reinterpret_cast<void*>(SYSTEM_MANAGED_MIN), virtual_size,
638638
protection_flags, map_flags, -1, 0));
639639
system_managed_base = virtual_base;
640640
system_reserved_base = reinterpret_cast<u8*>(SYSTEM_RESERVED_MIN);
641641
user_base = reinterpret_cast<u8*>(USER_MIN);
642642
#else
643+
// FreeBSD can't stand MAP_FIXED or it may overwrite mmap() itself!
643644
// Map memory wherever possible and instruction translation can handle offsetting to the
644645
// base.
646+
map_flags &= ~MAP_FIXED;
645647
const auto virtual_base =
646648
reinterpret_cast<u8*>(mmap(nullptr, virtual_size, protection_flags, map_flags, -1, 0));
647649
system_managed_base = virtual_base;

src/sdl_window.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameController* controller_
331331
window_info.type = WindowSystemType::Windows;
332332
window_info.render_surface = SDL_GetPointerProperty(SDL_GetWindowProperties(window),
333333
SDL_PROP_WINDOW_WIN32_HWND_POINTER, NULL);
334-
#elif defined(SDL_PLATFORM_LINUX)
334+
#elif defined(SDL_PLATFORM_LINUX) || defined(__FreeBSD__)
335+
// SDL doesn't have a platform define for FreeBSD AAAAAAAAAA
335336
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) {
336337
window_info.type = WindowSystemType::X11;
337338
window_info.display_connection = SDL_GetPointerProperty(

0 commit comments

Comments
 (0)