Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/asmjit/asmjit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkobalicek <kobalicek.petr@gmail.com>2021-05-16 10:33:45 +0300
committerkobalicek <kobalicek.petr@gmail.com>2021-05-16 23:08:06 +0300
commit8ee4c76ee3bf4c33478347caefc5d4f7f0e97992 (patch)
treedb6c1a8c96a3c17a24a8fec80bfedc87db0dd71e
parent0dd16b0a98ae1da48563c9cc62f757a9e6bbe9b6 (diff)
[Bug] Fixed android build (Android doesn't provide shm_open() and shm_unlink() functions)
-rw-r--r--src/asmjit/core/virtmem.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/asmjit/core/virtmem.cpp b/src/asmjit/core/virtmem.cpp
index b3f98b4..bcd1ff7 100644
--- a/src/asmjit/core/virtmem.cpp
+++ b/src/asmjit/core/virtmem.cpp
@@ -62,12 +62,19 @@
#include <atomic>
-#if defined(__APPLE__)
+#if defined(__APPLE__) || defined(__BIONIC__)
#define ASMJIT_VM_SHM_DETECT 0
#else
#define ASMJIT_VM_SHM_DETECT 1
#endif
+// Android NDK doesn't provide `shm_open()` and `shm_unlink()`.
+#if defined(__BIONIC__)
+ #define ASMJIT_VM_SHM_AVAILABLE 0
+#else
+ #define ASMJIT_VM_SHM_AVAILABLE 1
+#endif
+
ASMJIT_BEGIN_NAMESPACE
// ============================================================================
@@ -341,7 +348,9 @@ public:
bits -= uint64_t(OSUtils::getTickCount()) * 773703683;
bits = ((bits >> 14) ^ (bits << 6)) + uint64_t(++internalCounter) * 10619863;
- if (!ASMJIT_VM_SHM_DETECT || preferTmpOverDevShm) {
+ bool useTmp = !ASMJIT_VM_SHM_DETECT || preferTmpOverDevShm;
+
+ if (useTmp) {
_tmpName.assign(VirtMem_getTmpDir());
_tmpName.appendFormat(kShmFormat, (unsigned long long)bits);
_fd = ::open(_tmpName.data(), O_RDWR | O_CREAT | O_EXCL, 0);
@@ -350,6 +359,7 @@ public:
return kErrorOk;
}
}
+#if !ASMJIT_VM_SHM_AVAILABLE
else {
_tmpName.assignFormat(kShmFormat, (unsigned long long)bits);
_fd = ::shm_open(_tmpName.data(), O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
@@ -358,6 +368,7 @@ public:
return kErrorOk;
}
}
+#endif
int e = errno;
if (e != EEXIST)
@@ -372,10 +383,17 @@ public:
FileType type = _fileType;
_fileType = kFileTypeNone;
- if (type == kFileTypeShm)
+#if !ASMJIT_VM_SHM_AVAILABLE
+ if (type == kFileTypeShm) {
::shm_unlink(_tmpName.data());
- else if (type == kFileTypeTmp)
+ return;
+ }
+#endif
+
+ if (type == kFileTypeTmp) {
::unlink(_tmpName.data());
+ return;
+ }
}
void close() noexcept {