summaryrefslogtreecommitdiff
path: root/src/common/host_memory.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2023-06-05 21:43:43 -0700
committerGravatar GitHub2023-06-05 21:43:43 -0700
commitcb95d7fe1b6d81899fe6b279400da2c991e3132c (patch)
treea856ac45b1053009c4c11ee141c49d7faa4c8a19 /src/common/host_memory.cpp
parentMerge pull request #10611 from liamwhite/audio-deadlock (diff)
parentMerge pull request #10633 from t895/variable-surface-ratio (diff)
downloadyuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.tar.gz
yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.tar.xz
yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.zip
Merge pull request #10508 from yuzu-emu/lime
Project Lime - yuzu Android Port
Diffstat (limited to 'src/common/host_memory.cpp')
-rw-r--r--src/common/host_memory.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp
index 01457d8c6..ba22595e0 100644
--- a/src/common/host_memory.cpp
+++ b/src/common/host_memory.cpp
@@ -11,6 +11,10 @@
11 11
12#elif defined(__linux__) || defined(__FreeBSD__) // ^^^ Windows ^^^ vvv Linux vvv 12#elif defined(__linux__) || defined(__FreeBSD__) // ^^^ Windows ^^^ vvv Linux vvv
13 13
14#ifdef ANDROID
15#include <android/sharedmem.h>
16#endif
17
14#ifndef _GNU_SOURCE 18#ifndef _GNU_SOURCE
15#define _GNU_SOURCE 19#define _GNU_SOURCE
16#endif 20#endif
@@ -367,17 +371,20 @@ public:
367 } 371 }
368 372
369 // Backing memory initialization 373 // Backing memory initialization
370#if defined(__FreeBSD__) && __FreeBSD__ < 13 374#ifdef ANDROID
375 fd = ASharedMemory_create("HostMemory", backing_size);
376#elif defined(__FreeBSD__) && __FreeBSD__ < 13
371 // XXX Drop after FreeBSD 12.* reaches EOL on 2024-06-30 377 // XXX Drop after FreeBSD 12.* reaches EOL on 2024-06-30
372 fd = shm_open(SHM_ANON, O_RDWR, 0600); 378 fd = shm_open(SHM_ANON, O_RDWR, 0600);
373#else 379#else
374 fd = memfd_create("HostMemory", 0); 380 fd = memfd_create("HostMemory", 0);
375#endif 381#endif
376 if (fd == -1) { 382 if (fd < 0) {
377 LOG_CRITICAL(HW_Memory, "memfd_create failed: {}", strerror(errno)); 383 LOG_CRITICAL(HW_Memory, "memfd_create failed: {}", strerror(errno));
378 throw std::bad_alloc{}; 384 throw std::bad_alloc{};
379 } 385 }
380 386
387#ifndef ANDROID
381 // Defined to extend the file with zeros 388 // Defined to extend the file with zeros
382 int ret = ftruncate(fd, backing_size); 389 int ret = ftruncate(fd, backing_size);
383 if (ret != 0) { 390 if (ret != 0) {
@@ -385,6 +392,7 @@ public:
385 strerror(errno)); 392 strerror(errno));
386 throw std::bad_alloc{}; 393 throw std::bad_alloc{};
387 } 394 }
395#endif
388 396
389 backing_base = static_cast<u8*>( 397 backing_base = static_cast<u8*>(
390 mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); 398 mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0));