aboutsummaryrefslogtreecommitdiff
path: root/src/cpu/CpuContext.cpp
diff options
context:
space:
mode:
authorMichalis Spyrou <michalis.spyrou@arm.com>2021-03-09 19:33:12 +0000
committerMichalis Spyrou <michalis.spyrou@arm.com>2021-03-10 11:52:32 +0000
commit86ee237769aefc76ee1c3d58ae6a991c1ff50f34 (patch)
treef60ce6d7ff7c6ce2ee13549b68a15c82b4538894 /src/cpu/CpuContext.cpp
parentd0b7b4b1ce489058ea3ad34e29f94d568b4d64eb (diff)
downloadComputeLibrary-86ee237769aefc76ee1c3d58ae6a991c1ff50f34.tar.gz
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 <michalis.spyrou@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5244 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/cpu/CpuContext.cpp')
-rw-r--r--src/cpu/CpuContext.cpp5
1 files changed, 3 insertions, 2 deletions
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 <cstdlib>
+#include <malloc.h>
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;