From 21e5c824e6485ced8ba0e80124bd12229cc239c0 Mon Sep 17 00:00:00 2001 From: Maxim Kolchurin Date: Thu, 22 Feb 2024 11:31:59 +0300 Subject: [PATCH] zephyr: include math only with minimal libc Signed-off-by: Maxim Kolchurin --- core/shared/platform/zephyr/platform_internal.h | 7 ++++++- core/shared/platform/zephyr/shared_platform.cmake | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/shared/platform/zephyr/platform_internal.h b/core/shared/platform/zephyr/platform_internal.h index 85ca39be09..00bb49567d 100644 --- a/core/shared/platform/zephyr/platform_internal.h +++ b/core/shared/platform/zephyr/platform_internal.h @@ -102,7 +102,8 @@ void abort(void); size_t strspn(const char *s, const char *accept); size_t strcspn(const char *s, const char *reject); -/* math functions which are not provided by os */ +/* math functions which are not provided by os with minimal libc */ +#if defined(CONFIG_MINIMAL_LIBC) double atan(double x); double atan2(double y, double x); double sqrt(double x); @@ -129,6 +130,10 @@ double scalbn(double x, int n); unsigned long long int strtoull(const char *nptr, char **endptr, int base); double strtod(const char *nptr, char **endptr); float strtof(const char *nptr, char **endptr); +#else +#include +#endif /* CONFIG_MINIMAL_LIBC */ + /* clang-format on */ #if KERNEL_VERSION_NUMBER >= 0x030100 /* version 3.1.0 */ diff --git a/core/shared/platform/zephyr/shared_platform.cmake b/core/shared/platform/zephyr/shared_platform.cmake index 9b043b52f3..dfd45a4064 100644 --- a/core/shared/platform/zephyr/shared_platform.cmake +++ b/core/shared/platform/zephyr/shared_platform.cmake @@ -8,7 +8,9 @@ add_definitions(-DBH_PLATFORM_ZEPHYR) include_directories(${PLATFORM_SHARED_DIR}) include_directories(${PLATFORM_SHARED_DIR}/../include) -include (${CMAKE_CURRENT_LIST_DIR}/../common/math/platform_api_math.cmake) +if(${CONFIG_MINIMAL_LIBC}) + include (${CMAKE_CURRENT_LIST_DIR}/../common/math/platform_api_math.cmake) +endif() file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c)