mirror of
				https://github.com/bytecodealliance/wasm-micro-runtime.git
				synced 2025-10-31 05:11:19 +00:00 
			
		
		
		
	Using posix thread implementation for NuttX (#462)
Signed-off-by: Huang Qi <huangqi3@xiaomi.com> Co-authored-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
		
							parent
							
								
									388530c738
								
							
						
					
					
						commit
						b75224ce03
					
				|  | @ -57,14 +57,3 @@ os_mprotect(void *addr, size_t size, int prot) | |||
| void | ||||
| os_dcache_flush() | ||||
| {} | ||||
| 
 | ||||
| uint64 | ||||
| os_time_get_boot_microsecond() | ||||
| { | ||||
|     struct timespec ts; | ||||
|     if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) { | ||||
|         return 0; | ||||
|     } | ||||
| 
 | ||||
|     return ((uint64)ts.tv_sec) * 1000 * 1000 + ((uint64)ts.tv_nsec) / 1000; | ||||
| } | ||||
|  |  | |||
|  | @ -1,80 +0,0 @@ | |||
| /*
 | ||||
|  * Copyright (C) 2020 XiaoMi Corporation.  All rights reserved. | ||||
|  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
|  */ | ||||
| 
 | ||||
| #include "platform_api_extension.h" | ||||
| #include "platform_api_vmcore.h" | ||||
| 
 | ||||
| korp_tid | ||||
| os_self_thread() | ||||
| { | ||||
|     return (korp_tid)pthread_self(); | ||||
| } | ||||
| 
 | ||||
| int | ||||
| os_mutex_init(korp_mutex *mutex) | ||||
| { | ||||
|     return pthread_mutex_init(mutex, NULL) == 0 ? BHT_OK : BHT_ERROR; | ||||
| } | ||||
| 
 | ||||
| int | ||||
| os_mutex_destroy(korp_mutex *mutex) | ||||
| { | ||||
|     int ret; | ||||
| 
 | ||||
|     assert(mutex); | ||||
|     ret = pthread_mutex_destroy(mutex); | ||||
| 
 | ||||
|     return ret == 0 ? BHT_OK : BHT_ERROR; | ||||
| } | ||||
| 
 | ||||
| int | ||||
| os_mutex_lock(korp_mutex *mutex) | ||||
| { | ||||
|     int ret; | ||||
| 
 | ||||
|     assert(mutex); | ||||
|     ret = pthread_mutex_lock(mutex); | ||||
| 
 | ||||
|     return ret == 0 ? BHT_OK : BHT_ERROR; | ||||
| } | ||||
| 
 | ||||
| int | ||||
| os_mutex_unlock(korp_mutex *mutex) | ||||
| { | ||||
|     int ret; | ||||
| 
 | ||||
|     assert(mutex); | ||||
|     ret = pthread_mutex_unlock(mutex); | ||||
| 
 | ||||
|     return ret == 0 ? BHT_OK : BHT_ERROR; | ||||
| } | ||||
| 
 | ||||
| uint8 * | ||||
| os_thread_get_stack_boundary() | ||||
| { | ||||
|     return NULL; | ||||
| } | ||||
| 
 | ||||
| int | ||||
| os_cond_init(korp_cond *cond) | ||||
| { | ||||
|     assert(cond); | ||||
| 
 | ||||
|     if (pthread_cond_init(cond, NULL) != BHT_OK) | ||||
|         return BHT_ERROR; | ||||
| 
 | ||||
|     return BHT_OK; | ||||
| } | ||||
| 
 | ||||
| int | ||||
| os_cond_destroy(korp_cond *cond) | ||||
| { | ||||
|     assert(cond); | ||||
| 
 | ||||
|     if (pthread_cond_destroy(cond) != BHT_OK) | ||||
|         return BHT_ERROR; | ||||
| 
 | ||||
|     return BHT_OK; | ||||
| } | ||||
|  | @ -16,6 +16,8 @@ | |||
| #include <stdlib.h> | ||||
| #include <string.h> | ||||
| #include <math.h> | ||||
| #include <sys/time.h> | ||||
| #include <sys/mman.h> | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
|  |  | |||
|  | @ -153,7 +153,8 @@ CFLAGS += -I${IWASM_ROOT}/interpreter | |||
| endif | ||||
| 
 | ||||
| CSRCS += nuttx_platform.c \
 | ||||
|          nuttx_thread.c \
 | ||||
|          posix_thread.c \
 | ||||
|          posix_time.c \
 | ||||
|          mem_alloc.c \
 | ||||
|          ems_kfc.c \
 | ||||
|          ems_alloc.c \
 | ||||
|  | @ -176,6 +177,7 @@ CSRCS += nuttx_platform.c \ | |||
| ASRCS += ${INVOKE_NATIVE} | ||||
| 
 | ||||
| VPATH += ${SHARED_ROOT}/platform/nuttx | ||||
| VPATH += ${SHARED_ROOT}/platform/common/posix | ||||
| VPATH += ${SHARED_ROOT}/mem-alloc | ||||
| VPATH += ${SHARED_ROOT}/mem-alloc/ems | ||||
| VPATH += ${SHARED_ROOT}/utils | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Huang Qi
						Huang Qi