[android] fix memfd_create() issue
All checks were successful
eden-license / license-header (pull_request) Successful in 22s

Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie 2025-09-25 18:12:53 +00:00
parent 29731247fe
commit 0cb234dfd9
Signed by: Lizzie
GPG key ID: 00287378CADCAB13

View file

@ -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);