diff options
author | bunnei <bunneidev@gmail.com> | 2023-06-06 06:43:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-06 06:43:43 +0200 |
commit | cb95d7fe1b6d81899fe6b279400da2c991e3132c (patch) | |
tree | a856ac45b1053009c4c11ee141c49d7faa4c8a19 /src/common/host_memory.cpp | |
parent | Merge pull request #10611 from liamwhite/audio-deadlock (diff) | |
parent | Merge pull request #10633 from t895/variable-surface-ratio (diff) | |
download | yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.tar yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.tar.gz yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.tar.bz2 yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.tar.lz yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.tar.xz yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.tar.zst yuzu-cb95d7fe1b6d81899fe6b279400da2c991e3132c.zip |
Diffstat (limited to 'src/common/host_memory.cpp')
-rw-r--r-- | src/common/host_memory.cpp | 12 |
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 @@ #elif defined(__linux__) || defined(__FreeBSD__) // ^^^ Windows ^^^ vvv Linux vvv +#ifdef ANDROID +#include <android/sharedmem.h> +#endif + #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif @@ -367,17 +371,20 @@ public: } // Backing memory initialization -#if defined(__FreeBSD__) && __FreeBSD__ < 13 +#ifdef ANDROID + fd = ASharedMemory_create("HostMemory", backing_size); +#elif defined(__FreeBSD__) && __FreeBSD__ < 13 // XXX Drop after FreeBSD 12.* reaches EOL on 2024-06-30 fd = shm_open(SHM_ANON, O_RDWR, 0600); #else fd = memfd_create("HostMemory", 0); #endif - if (fd == -1) { + if (fd < 0) { LOG_CRITICAL(HW_Memory, "memfd_create failed: {}", strerror(errno)); throw std::bad_alloc{}; } +#ifndef ANDROID // Defined to extend the file with zeros int ret = ftruncate(fd, backing_size); if (ret != 0) { @@ -385,6 +392,7 @@ public: strerror(errno)); throw std::bad_alloc{}; } +#endif backing_base = static_cast<u8*>( mmap(nullptr, backing_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)); |