Browse Source

[android] fix memfd_create() issue

Signed-off-by: lizzie <lizzie@eden-emu.dev>
pull/2585/head
lizzie 6 months ago
committed by crueter
parent
commit
0aa04e9010
  1. 5
      src/common/host_memory.cpp

5
src/common/host_memory.cpp

@ -439,10 +439,11 @@ static void* ChooseVirtualBase(size_t virtual_size) {
#endif #endif
#if defined(__sun__) || defined(__HAIKU__) || defined(__NetBSD__) || defined(__DragonFly__)
#if defined(__sun__) || defined(__HAIKU__) || defined(__NetBSD__) || defined(__DragonFly__) || (defined(__ANDROID__) && __ANDROID_API__ <= 29)
/// Most Unices don't have a portable shm_open (AIX, OpenBSD, NetBSD, Solaris 11, OpenIndiana) /// Most Unices don't have a portable shm_open (AIX, OpenBSD, NetBSD, Solaris 11, OpenIndiana)
/// Portable implementation of shm_open(SHM_ANON, ...) - roughly equivalent but without /// Portable implementation of shm_open(SHM_ANON, ...) - roughly equivalent but without
/// OS support - may fail sporadically, beware! /// OS support - may fail sporadically, beware!
/// For example legacy android (ndk <= 29, aka. Android 10) doesn't have memfd_create()
static int shm_open_anon(int flags, mode_t mode) { static int shm_open_anon(int flags, mode_t mode) {
char name[16] = "/shm-"; char name[16] = "/shm-";
char *const limit = name + sizeof(name) - 1; char *const limit = name + sizeof(name) - 1;
@ -494,7 +495,7 @@ public:
ASSERT_MSG(page_size == 0x1000, "page size {:#x} is incompatible with 4K paging", ASSERT_MSG(page_size == 0x1000, "page size {:#x} is incompatible with 4K paging",
page_size); page_size);
// Backing memory initialization // Backing memory initialization
#if defined(__sun__) || defined(__HAIKU__) || defined(__NetBSD__) || defined(__DragonFly__)
#if defined(__sun__) || defined(__HAIKU__) || defined(__NetBSD__) || defined(__DragonFly__) || (defined(__ANDROID__) && __ANDROID_API__ <= 29)
fd = shm_open_anon(O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0600); fd = shm_open_anon(O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0600);
#elif defined(__OpenBSD__) #elif defined(__OpenBSD__)
fd = shm_open_anon(O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0600); fd = shm_open_anon(O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0600);

Loading…
Cancel
Save