From 86ee237769aefc76ee1c3d58ae6a991c1ff50f34 Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Tue, 9 Mar 2021 19:33:12 +0000 Subject: Use memalign on bare metal Some compilers don't support aligned_alloc as they fallback on posix_memalign. Change-Id: Ifa2ca9fa4684a7ffbe3674328060c0603ec0c6b4 Signed-off-by: Michalis Spyrou Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5244 Tested-by: Arm Jenkins Reviewed-by: Michele Di Giorgio Comments-Addressed: Arm Jenkins --- src/cpu/CpuContext.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/cpu/CpuContext.cpp') diff --git a/src/cpu/CpuContext.cpp b/src/cpu/CpuContext.cpp index 5d71d9a6d8..6ff35602f3 100644 --- a/src/cpu/CpuContext.cpp +++ b/src/cpu/CpuContext.cpp @@ -27,6 +27,7 @@ #include "src/runtime/CPUUtils.h" #include +#include namespace arm_compute { @@ -51,14 +52,14 @@ void *default_aligned_allocate(void *user_data, size_t size, size_t alignment) #if defined(BARE_METAL) || defined(__APPLE__) size_t rem = size % alignment; size_t real_size = (rem) ? (size + alignment - rem) : size; - ptr = aligned_alloc(alignment, real_size); + ptr = memalign(alignment, real_size); #else /* defined(BARE_METAL) || defined(__APPLE__) */ if(posix_memalign(&ptr, alignment, size) != 0) { // posix_memalign returns non-zero on failures, the return values will be // - EINVAL: wrong alignment // - ENOMEM: insufficient memory - ARM_COMPUTE_LOG_ERROR_ACL("posix_memalign failed, the returned pointer will be invalid"); + ARM_COMPUTE_LOG_ERROR_ACL("posix_memalign failed, the returned pointer will be invalid"); } #endif /* defined(BARE_METAL) || defined(__APPLE__) */ return ptr; -- cgit v1.2.1