From 8756d29e190e377972013a7a9d43551a2218bea4 Mon Sep 17 00:00:00 2001 From: mkolchurin <33422855+mkolchurin@users.noreply.github.com> Date: Wed, 10 Apr 2024 03:19:46 +0300 Subject: [PATCH] zephyr: Add missing pthread library functions (#3291) For use with WAMR_BUILD_LIB_PTHREAD, add os_thread_detach, os_thread_exit, os_cond_broadcast. Signed-off-by: Maxim Kolchurin --- core/shared/platform/zephyr/zephyr_thread.c | 32 ++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/core/shared/platform/zephyr/zephyr_thread.c b/core/shared/platform/zephyr/zephyr_thread.c index 105d5399..53ca71f6 100644 --- a/core/shared/platform/zephyr/zephyr_thread.c +++ b/core/shared/platform/zephyr/zephyr_thread.c @@ -577,4 +577,34 @@ os_thread_get_stack_boundary() void os_thread_jit_write_protect_np(bool enabled) -{} \ No newline at end of file +{} + +int +os_thread_detach(korp_tid thread) +{ + (void)thread; + return BHT_OK; +} + +void +os_thread_exit(void *retval) +{ + (void)retval; + os_thread_cleanup(); + k_thread_abort(k_current_get()); +} + +int +os_cond_broadcast(korp_cond *cond) +{ + os_thread_wait_node *node; + k_mutex_lock(&cond->wait_list_lock, K_FOREVER); + node = cond->thread_wait_list; + while (node) { + os_thread_wait_node *next = node->next; + k_sem_give(&node->sem); + node = next; + } + k_mutex_unlock(&cond->wait_list_lock); + return BHT_OK; +}