summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-12-18 08:29:15 +0100
committerbunnei <bunneidev@gmail.com>2023-06-03 09:05:26 +0200
commitafdee9abea39637eb145d7ddb98a316a597da1bd (patch)
tree1df70bf234ec532bf4f5fa9e8781fb8fc191d3de /src/common
parentandroid: Minimal JNI for yuzu. (diff)
downloadyuzu-afdee9abea39637eb145d7ddb98a316a597da1bd.tar
yuzu-afdee9abea39637eb145d7ddb98a316a597da1bd.tar.gz
yuzu-afdee9abea39637eb145d7ddb98a316a597da1bd.tar.bz2
yuzu-afdee9abea39637eb145d7ddb98a316a597da1bd.tar.lz
yuzu-afdee9abea39637eb145d7ddb98a316a597da1bd.tar.xz
yuzu-afdee9abea39637eb145d7ddb98a316a597da1bd.tar.zst
yuzu-afdee9abea39637eb145d7ddb98a316a597da1bd.zip
Diffstat (limited to 'src/common')
-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 8e4f1f97a..703ddb4a4 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
@@ -366,17 +370,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) {
@@ -384,6 +391,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));