[Mlir-commits] [mlir] [mlir] Add guard for using posixmemalign <= Android API 28 (PR #194263)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Apr 26 13:03:18 PDT 2026


https://github.com/trcrsired created https://github.com/llvm/llvm-project/pull/194263

aligned_alloc does not exist for Android before 28 too just like apple

>From 7d382d8cfebc831b6983ae00af800e4722289584 Mon Sep 17 00:00:00 2001
From: cqwrteur <oyzawqgcfc at gmail.com>
Date: Mon, 27 Apr 2026 04:01:17 +0800
Subject: [PATCH] Add guard for using posixmemalign <= Android API 28

aligned_alloc does not exist for Android before 28 too just like apple
---
 mlir/lib/ExecutionEngine/CRunnerUtils.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/lib/ExecutionEngine/CRunnerUtils.cpp b/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
index 41c619566b55d..272137d4b1d7c 100644
--- a/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
+++ b/mlir/lib/ExecutionEngine/CRunnerUtils.cpp
@@ -152,7 +152,7 @@ extern "C" void *mlirAlloc(uint64_t size) { return malloc(size); }
 extern "C" void *mlirAlignedAlloc(uint64_t alignment, uint64_t size) {
 #ifdef _WIN32
   return _aligned_malloc(size, alignment);
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) || (defined(__ANDROID_API__) && __ANDROID_API__ <= 28)
   // aligned_alloc was added in MacOS 10.15. Fall back to posix_memalign to also
   // support older versions.
   void *result = nullptr;



More information about the Mlir-commits mailing list