diff options
| author | LC <mathew1800@gmail.com> | 2020-07-16 14:23:51 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-16 14:23:51 -0400 |
| commit | c59648337a8e65178d03687ec7bf7349e9bc9ccd (patch) | |
| tree | cbf11e846c41f3108fa45944cb091ec92c749630 /Source | |
| parent | d987cf1ddec05f398969c2bbe0017cfdc76e07b6 (diff) | |
| parent | 00cde7cbbddbd5be5e104a72f259578b109d8bb7 (diff) | |
Merge pull request #8955 from JosJuice/android-no-ashmem
Android: Don't access /dev/ashmem on newer Android versions
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Core/Common/MemArena.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Source/Core/Common/MemArena.cpp b/Source/Core/Common/MemArena.cpp index fcd18892ba..19085e3d8f 100644 --- a/Source/Core/Common/MemArena.cpp +++ b/Source/Core/Common/MemArena.cpp @@ -23,6 +23,7 @@ #include <sys/mman.h> #include <unistd.h> #ifdef ANDROID +#include <dlfcn.h> #include <linux/ashmem.h> #include <sys/ioctl.h> #endif @@ -35,6 +36,18 @@ namespace Common static int AshmemCreateFileMapping(const char* name, size_t size) { + // ASharedMemory path - works on API >= 26 and falls through on API < 26: + + // We can't call ASharedMemory_create the normal way without increasing the + // minimum version requirement to API 26, so we use dlopen/dlsym instead + static void* libandroid = dlopen("libandroid.so", RTLD_LAZY | RTLD_LOCAL); + static auto shared_memory_create = + reinterpret_cast<int (*)(const char*, size_t)>(dlsym(libandroid, "ASharedMemory_create")); + if (shared_memory_create) + return shared_memory_create(name, size); + + // /dev/ashmem path - works on API < 29: + int fd, ret; fd = open(ASHMEM_DEVICE, O_RDWR); if (fd < 0) |
