Fixed build errors
* Resolves problem in macOS Monterey + Clang 13 where there is no memalloc and
memalign must be used
* Resolves builld error when passing an empty list of files to the AR
tool
* Resolves MLCE-685
Change-Id: I862ff1dc7f74b2ba32479f6e8abaa32a88d47995
Signed-off-by: Pablo Marquez Tello <pablo.tello@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6706
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Reviewed-by: Giorgio Arena <giorgio.arena@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
diff --git a/src/cpu/CpuContext.cpp b/src/cpu/CpuContext.cpp
index 1a971a6..917bf68 100644
--- a/src/cpu/CpuContext.cpp
+++ b/src/cpu/CpuContext.cpp
@@ -28,7 +28,10 @@
#include "src/cpu/CpuTensor.h"
#include <cstdlib>
+#if !defined(__APPLE__)
#include <malloc.h>
+#endif // !defined(__APPLE__)
+
namespace arm_compute
{
@@ -50,11 +53,11 @@
{
ARM_COMPUTE_UNUSED(user_data);
void *ptr = nullptr;
-#if defined(BARE_METAL) || defined(__APPLE__)
+#if defined(BARE_METAL)
size_t rem = size % alignment;
size_t real_size = (rem) ? (size + alignment - rem) : size;
ptr = memalign(alignment, real_size);
-#else /* defined(BARE_METAL) || defined(__APPLE__) */
+#else /* defined(BARE_METAL) */
if(posix_memalign(&ptr, alignment, size) != 0)
{
// posix_memalign returns non-zero on failures, the return values will be
@@ -62,7 +65,7 @@
// - ENOMEM: insufficient memory
ARM_COMPUTE_LOG_ERROR_ACL("posix_memalign failed, the returned pointer will be invalid");
}
-#endif /* defined(BARE_METAL) || defined(__APPLE__) */
+#endif /* defined(BARE_METAL) */
return ptr;
}
void default_aligned_free(void *user_data, void *ptr)