termux-packages/packages/erlang/emulator-asmjit-virtmem-shm...

61 lines
1.7 KiB
Diff

diff --git a/erts/emulator/asmjit/core/virtmem.cpp b/erts/emulator/asmjit/core/virtmem.cpp
index a1b0f95..d1eb1ad 100644
--- a/erts/emulator/asmjit/core/virtmem.cpp
+++ b/erts/emulator/asmjit/core/virtmem.cpp
@@ -62,12 +62,18 @@
#include <atomic>
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__ANDROID__)
#define ASMJIT_VM_SHM_DETECT 0
#else
#define ASMJIT_VM_SHM_DETECT 1
#endif
+#if defined(__ANDROID__)
+ #define ASMJIT_VM_SHM_AVAILABLE 0
+#else
+ #define ASMJIT_VM_SHM_AVAILABLE 1
+#endif
+
ASMJIT_BEGIN_NAMESPACE
// ============================================================================
@@ -258,8 +264,10 @@ public:
if (type == kFileTypeTmp)
return unlink(tmpName.data());
+#if ASMJIT_VM_SHM_AVAILABLE
else if (type == kFileTypeShm)
return shm_unlink(tmpName.data());
+#endif
else
return 0;
}
@@ -388,7 +396,7 @@ static ASMJIT_INLINE int VirtMem_appleSpecificMMapFlags(uint32_t flags) noexcept
#if !defined(SHM_ANON)
static const char* VirtMem_getTmpDir() noexcept {
const char* tmpDir = getenv("TMPDIR");
- return tmpDir ? tmpDir : "/tmp";
+ return tmpDir ? tmpDir : "@TERMUX_PREFIX@/tmp";
}
#endif
@@ -448,6 +456,7 @@ static Error VirtMem_openAnonymousMemory(AnonymousMemory* anonMem, bool preferTm
return kErrorOk;
}
}
+#if ASMJIT_VM_SHM_AVAILABLE
else {
anonMem->tmpName.assignFormat(kShmFormat, (unsigned long long)bits);
anonMem->fd = shm_open(anonMem->tmpName.data(), O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
@@ -456,6 +465,7 @@ static Error VirtMem_openAnonymousMemory(AnonymousMemory* anonMem, bool preferTm
return kErrorOk;
}
}
+#endif
int e = errno;
if (e != EEXIST)