summaryrefslogtreecommitdiff
path: root/src/common/host_memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/host_memory.cpp')
-rw-r--r--src/common/host_memory.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp
index 2a5a7596c..6661244cf 100644
--- a/src/common/host_memory.cpp
+++ b/src/common/host_memory.cpp
@@ -6,7 +6,7 @@
6#include <windows.h> 6#include <windows.h>
7#include "common/dynamic_library.h" 7#include "common/dynamic_library.h"
8 8
9#elif defined(__linux__) // ^^^ Windows ^^^ vvv Linux vvv 9#elif defined(__linux__) || defined(__FreeBSD__) // ^^^ Windows ^^^ vvv Linux vvv
10 10
11#ifndef _GNU_SOURCE 11#ifndef _GNU_SOURCE
12#define _GNU_SOURCE 12#define _GNU_SOURCE
@@ -343,7 +343,7 @@ private:
343 std::unordered_map<size_t, size_t> placeholder_host_pointers; ///< Placeholder backing offset 343 std::unordered_map<size_t, size_t> placeholder_host_pointers; ///< Placeholder backing offset
344}; 344};
345 345
346#elif defined(__linux__) // ^^^ Windows ^^^ vvv Linux vvv 346#elif defined(__linux__) || defined(__FreeBSD__) // ^^^ Windows ^^^ vvv Linux vvv
347 347
348class HostMemory::Impl { 348class HostMemory::Impl {
349public: 349public:
@@ -357,7 +357,12 @@ public:
357 }); 357 });
358 358
359 // Backing memory initialization 359 // Backing memory initialization
360#if defined(__FreeBSD__) && __FreeBSD__ < 13
361 // XXX Drop after FreeBSD 12.* reaches EOL on 2024-06-30
362 fd = shm_open(SHM_ANON, O_RDWR, 0600);
363#else
360 fd = memfd_create("HostMemory", 0); 364 fd = memfd_create("HostMemory", 0);
365#endif
361 if (fd == -1) { 366 if (fd == -1) {
362 LOG_CRITICAL(HW_Memory, "memfd_create failed: {}", strerror(errno)); 367 LOG_CRITICAL(HW_Memory, "memfd_create failed: {}", strerror(errno));
363 throw std::bad_alloc{}; 368 throw std::bad_alloc{};