Răsfoiți Sursa

Fix compilation errors on zephyr platform (#2777)

Add dummy korp_rwlock struct and fix os_dir_stream definition on
platform zephyr/riot/rt-thread/alios to fix the compilation errors.
Wenyong Huang 2 ani în urmă
părinte
comite
a3349cc8c1

+ 9 - 1
core/shared/platform/alios/platform_internal.h

@@ -32,6 +32,12 @@ typedef aos_task_t *aos_tid_t;
 typedef aos_mutex_t korp_mutex;
 typedef aos_sem_t korp_sem;
 
+/* korp_rwlock is used in platform_api_extension.h,
+   we just define the type to make the compiler happy */
+typedef struct {
+    int dummy;
+} korp_rwlock;
+
 struct os_thread_wait_node;
 typedef struct os_thread_wait_node *os_thread_wait_list;
 typedef struct korp_cond {
@@ -64,8 +70,10 @@ int signbit(double x);
 int isnan(double x);
 /* clang-format on */
 
+/* The below types are used in platform_api_extension.h,
+   we just define them to make the compiler happy */
 typedef int os_file_handle;
-typedef DIR *os_dir_stream;
+typedef void *os_dir_stream;
 typedef int os_raw_file_handle;
 
 static inline os_file_handle

+ 9 - 1
core/shared/platform/riot/platform_internal.h

@@ -40,6 +40,12 @@ typedef kernel_pid_t korp_tid;
 typedef mutex_t korp_mutex;
 typedef unsigned int korp_sem;
 
+/* korp_rwlock is used in platform_api_extension.h,
+   we just define the type to make the compiler happy */
+typedef struct {
+    int dummy;
+} korp_rwlock;
+
 /* typedef sema_t korp_sem; */
 
 struct os_thread_wait_node;
@@ -52,8 +58,10 @@ typedef struct korp_cond {
 #define os_printf printf
 #define os_vprintf vprintf
 
+/* The below types are used in platform_api_extension.h,
+   we just define them to make the compiler happy */
 typedef int os_file_handle;
-typedef DIR *os_dir_stream;
+typedef void *os_dir_stream;
 typedef int os_raw_file_handle;
 
 #if WA_MATH

+ 9 - 1
core/shared/platform/rt-thread/platform_internal.h

@@ -38,6 +38,12 @@ typedef struct rt_thread korp_cond;
 typedef struct rt_thread korp_thread;
 typedef unsigned int korp_sem;
 
+/* korp_rwlock is used in platform_api_extension.h,
+   we just define the type to make the compiler happy */
+typedef struct {
+    int dummy;
+} korp_rwlock;
+
 typedef rt_uint8_t uint8_t;
 typedef rt_int8_t int8_t;
 typedef rt_uint16_t uint16_t;
@@ -45,8 +51,10 @@ typedef rt_int16_t int16_t;
 typedef rt_uint64_t uint64_t;
 typedef rt_int64_t int64_t;
 
+/* The below types are used in platform_api_extension.h,
+   we just define them to make the compiler happy */
 typedef int os_file_handle;
-typedef DIR *os_dir_stream;
+typedef void *os_dir_stream;
 typedef int os_raw_file_handle;
 
 static inline os_file_handle

+ 9 - 1
core/shared/platform/zephyr/platform_internal.h

@@ -74,6 +74,12 @@ typedef korp_thread *korp_tid;
 typedef struct k_mutex korp_mutex;
 typedef unsigned int korp_sem;
 
+/* korp_rwlock is used in platform_api_extension.h,
+   we just define the type to make the compiler happy */
+typedef struct {
+    int dummy;
+} korp_rwlock;
+
 struct os_thread_wait_node;
 typedef struct os_thread_wait_node *os_thread_wait_list;
 typedef struct korp_cond {
@@ -148,8 +154,10 @@ void
 set_exec_mem_alloc_func(exec_mem_alloc_func_t alloc_func,
                         exec_mem_free_func_t free_func);
 
+/* The below types are used in platform_api_extension.h,
+   we just define them to make the compiler happy */
 typedef int os_file_handle;
-typedef DIR *os_dir_stream;
+typedef void *os_dir_stream;
 typedef int os_raw_file_handle;
 
 static inline os_file_handle

+ 10 - 0
product-mini/platforms/zephyr/simple/src/main.c

@@ -265,8 +265,18 @@ iwasm_init(void)
         iwasm_main, NULL, NULL, NULL, MAIN_THREAD_PRIORITY, 0, K_NO_WAIT);
     return tid ? true : false;
 }
+
+#if KERNEL_VERSION_NUMBER < 0x030400 /* version 3.4.0 */
 void
 main(void)
 {
     iwasm_init();
 }
+#else
+int
+main(void)
+{
+    iwasm_init();
+    return 0;
+}
+#endif