aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSang-Hoon Park <sang-hoon.park@arm.com>2021-03-04 11:06:48 +0000
committerSang-Hoon Park <sang-hoon.park@arm.com>2021-03-05 12:56:46 +0000
commit57d7366524ed02e7e3eab62af05cd38171efaea8 (patch)
tree98e86d86291ce806cd33d7663f4c9a262c9130a1
parentdcf3c7e1591cfac19ee2b800141df3b3fe45062d (diff)
downloadComputeLibrary-57d7366524ed02e7e3eab62af05cd38171efaea8.tar.gz
Add log on memory allocation failure in CpuContext
In CpuContext, a logging is added on memory allocation failure. Practically, it also fixes the unused result build error. Change-Id: I8a3fd4fd5839ce7ce072b75eec7e7e22fc9bc531 Signed-off-by: Sang-Hoon Park <sang-hoon.park@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5216 Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
-rw-r--r--src/cpu/CpuContext.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/cpu/CpuContext.cpp b/src/cpu/CpuContext.cpp
index 5980a5ab0d..5d71d9a6d8 100644
--- a/src/cpu/CpuContext.cpp
+++ b/src/cpu/CpuContext.cpp
@@ -53,7 +53,13 @@ void *default_aligned_allocate(void *user_data, size_t size, size_t alignment)
size_t real_size = (rem) ? (size + alignment - rem) : size;
ptr = aligned_alloc(alignment, real_size);
#else /* defined(BARE_METAL) || defined(__APPLE__) */
- posix_memalign(&ptr, alignment, size);
+ 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");
+ }
#endif /* defined(BARE_METAL) || defined(__APPLE__) */
return ptr;
}