From 390dadf78ed615322ff6bb45b5c8fb03798f2bd8 Mon Sep 17 00:00:00 2001 From: DH Date: Fri, 17 Oct 2025 02:43:13 +0300 Subject: [PATCH] fix android build --- rx/include/rx/mem.hpp | 2 +- rx/src/Mappable.cpp | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/rx/include/rx/mem.hpp b/rx/include/rx/mem.hpp index fb4985b9b..efd733d0b 100644 --- a/rx/include/rx/mem.hpp +++ b/rx/include/rx/mem.hpp @@ -4,7 +4,7 @@ #include "EnumBitSet.hpp" #include #include -#include +#include namespace rx::mem { enum class Protection { diff --git a/rx/src/Mappable.cpp b/rx/src/Mappable.cpp index 78a6c7856..f0ebb16bb 100644 --- a/rx/src/Mappable.cpp +++ b/rx/src/Mappable.cpp @@ -15,7 +15,12 @@ #endif #ifdef ANDROID -#include "format-base.hpp" +#include + +static int memfd_create(const char *name, uint flags) { + // FIXME: requires modern android + return syscall(__NR_memfd_create, name, flags); +} #endif std::pair @@ -32,22 +37,13 @@ rx::Mappable::CreateMemory(std::size_t size) { } result.m_handle = handle; -#else -#ifdef ANDROID - auto name = rx::format("/{}-{:x}", (void *)&result, size); - auto fd = ::shm_open(name.c_str(), O_CREAT | O_TRUNC, 0666); #else auto fd = ::memfd_create("", 0); -#endif if (fd < 0) { return {{}, std::errc{errno}}; } -#ifdef ANDROID - ::shm_unlink(name.c_str()); -#endif - result.m_handle = fd; if (::ftruncate(fd, size) < 0) {