Fix zephyr sample build errors (#1757)

This commit is contained in:
Wenyong Huang 2022-11-28 11:23:51 +08:00 committed by GitHub
parent 9c5e1cb600
commit ec5ab8274d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 8 deletions

View File

@ -449,8 +449,6 @@ ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */
ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
static double
freebsd_sqrt(double x);
static double
freebsd_floor(double x);
static double
@ -622,6 +620,7 @@ freebsd_atan2(double y, double x)
}
}
#ifndef BH_HAS_SQRTF
static float
freebsd_sqrtf(float x)
{
@ -689,7 +688,9 @@ freebsd_sqrtf(float x)
SET_FLOAT_WORD(z, ix);
return z;
}
#endif /* end of BH_HAS_SQRTF */
#ifndef BH_HAS_SQRT
static double
freebsd_sqrt(double x) /* wrapper sqrt */
{
@ -799,6 +800,7 @@ freebsd_sqrt(double x) /* wrapper sqrt */
return z;
}
#endif /* end of BH_HAS_SQRT */
static double
freebsd_floor(double x)
@ -1554,11 +1556,13 @@ atan2(double y, double x)
return freebsd_atan2(y, x);
}
#ifndef BH_HAS_SQRT
double
sqrt(double x)
{
return freebsd_sqrt(x);
}
#endif
double
floor(double x)
@ -1656,11 +1660,13 @@ fmaxf(float x, float y)
return freebsd_fmaxf(x, y);
}
#ifndef BH_HAS_SQRTF
float
sqrtf(float x)
{
return freebsd_sqrtf(x);
}
#endif
double
pow(double x, double y)

View File

@ -193,6 +193,10 @@ typedef void *(*thread_start_routine_t)(void *);
#define SCNxPTR __PRIPTR_PREFIX "x"
#endif
#ifndef NAN
#define NAN (0.0 / 0.0)
#endif
#ifdef __cplusplus
}
#endif

View File

@ -7,14 +7,21 @@
#define _PLATFORM_INTERNAL_H
#include <autoconf.h>
#include <version.h>
#if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */
#include <zephyr.h>
#include <kernel.h>
#include <version.h>
#if KERNEL_VERSION_NUMBER >= 0x020200 /* version 2.2.0 */
#include <sys/printk.h>
#else
#include <misc/printk.h>
#endif
#else /* else of KERNEL_VERSION_NUMBER < 0x030200 */
#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
#endif /* end of KERNEL_VERSION_NUMBER < 0x030200 */
#include <inttypes.h>
#include <stdarg.h>
#include <ctype.h>
@ -24,9 +31,12 @@
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#ifndef CONFIG_NET_BUF_USER_DATA_SIZE
#define CONFIG_NET_BUF_USER_DATA_SIZE 0
#endif
#if KERNEL_VERSION_NUMBER < 0x030200 /* version 3.2.0 */
#include <net/net_pkt.h>
#include <net/net_if.h>
#include <net/net_ip.h>
@ -36,6 +46,17 @@
#ifdef CONFIG_ARM_MPU
#include <arch/arm/aarch32/cortex_m/cmsis.h>
#endif
#else /* else of KERNEL_VERSION_NUMBER < 0x030200 */
#include <zephyr/net/net_pkt.h>
#include <zephyr/net/net_if.h>
#include <zephyr/net/net_ip.h>
#include <zephyr/net/net_core.h>
#include <zephyr/net/net_context.h>
#ifdef CONFIG_ARM_MPU
#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
#endif
#endif /* end of KERNEL_VERSION_NUMBER < 0x030200 */
#ifndef BH_PLATFORM_ZEPHYR
#define BH_PLATFORM_ZEPHYR
@ -96,6 +117,11 @@ double strtod(const char *nptr, char **endptr);
float strtof(const char *nptr, char **endptr);
/* clang-format on */
#if KERNEL_VERSION_NUMBER >= 0x030100 /* version 3.1.0 */
#define BH_HAS_SQRT
#define BH_HAS_SQRTF
#endif
/**
* @brief Allocate executable memroy
*

View File

@ -42,12 +42,12 @@ endif ()
# Override the global heap usage
if (NOT DEFINED WAMR_BUILD_GLOBAL_HEAP_POOL)
add_definitions (-DWASM_ENABLE_GLOBAL_HEAP_POOL=1)
set (WAMR_BUILD_GLOBAL_HEAP_POOL 1)
endif ()
# Override the global heap size for small devices
if (NOT DEFINED WAMR_BUILD_GLOBAL_HEAP_SIZE)
add_definitions (-DWASM_GLOBAL_HEAP_SIZE=131072) # 128 kB
set (WAMR_BUILD_GLOBAL_HEAP_SIZE 131072) # 128 KB
endif ()
set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../..)

View File

@ -15,9 +15,6 @@
#include "test_wasm.h"
#endif /* end of BUILD_TARGET_RISCV64_LP64 || BUILD_TARGET_RISCV32_ILP32 */
#include <zephyr.h>
#include <sys/printk.h>
#if defined(BUILD_TARGET_RISCV64_LP64) || defined(BUILD_TARGET_RISCV32_ILP32)
#if defined(BUILD_TARGET_RISCV64_LP64)
#define CONFIG_GLOBAL_HEAP_BUF_SIZE 4360