From 1a90adfb5ea380820f8dd7d6331b2c2f787ea34d Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Mon, 11 Oct 2021 22:26:52 +0000 Subject: [PATCH] vm_native: unbreak runtime on FreeBSD after 63104af8e9ee shm_open() returns a file descriptor on success, not zero. As SHM_ANON only exists on FreeBSD which also has memfd_create use the same code as on Linux. $ rpcs3 [...] Verification failed (in file rpcs3/util/vm_native.cpp:478[:4], in function shm) (errno=2) Segmentation fault --- rpcs3/util/vm_native.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rpcs3/util/vm_native.cpp b/rpcs3/util/vm_native.cpp index e67c28c7c5..36c6d08944 100644 --- a/rpcs3/util/vm_native.cpp +++ b/rpcs3/util/vm_native.cpp @@ -474,8 +474,9 @@ namespace utils if ((vm_overcommit & 3) == 0) { -#ifdef SHM_ANON - ensure(::shm_open(SHM_ANON, O_RDWR, S_IWUSR | S_IRUSR) == 0); +#if defined(__FreeBSD__) + m_file = ::memfd_create_("", 0); + ensure(m_file >= 0); #else const std::string name = "/rpcs3-mem2-" + std::to_string(reinterpret_cast(this));