mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-06 15:05:19 +00:00
Fix os_cond_timedwait and other issues for NuttX sim/macOS (#562)
This commit is contained in:
parent
631838cfd9
commit
15dd651539
|
@ -3618,7 +3618,7 @@ wasm_loader_find_block_addr(BlockAddr *block_addr_cache,
|
|||
uint32 block_nested_depth = 1, count, i, j, t;
|
||||
uint32 error_buf_size = sizeof(error_buf);
|
||||
uint8 opcode, u8;
|
||||
BlockAddr block_stack[16] = { 0 }, *block;
|
||||
BlockAddr block_stack[16] = {{0}}, *block;
|
||||
|
||||
i = ((uintptr_t)start_addr) & (uintptr_t)(BLOCK_ADDR_CACHE_SIZE - 1);
|
||||
block = block_addr_cache + BLOCK_ADDR_CONFLICT_SIZE * i;
|
||||
|
|
|
@ -92,7 +92,7 @@ gc_init_with_struct_and_pool(char *struct_buf, gc_size_t struct_buf_size,
|
|||
}
|
||||
|
||||
if (struct_buf_size < sizeof(gc_handle_t)) {
|
||||
os_printf("[GC_ERROR]heap init struct buf size (%u) < %u\n",
|
||||
os_printf("[GC_ERROR]heap init struct buf size (%u) < %zu\n",
|
||||
struct_buf_size, sizeof(gc_handle_t));
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ static void *os_thread_wrapper(void *arg)
|
|||
os_signal_handler handler = targ->signal_handler;
|
||||
#endif
|
||||
|
||||
os_printf("THREAD CREATED %p\n", pthread_self());
|
||||
os_printf("THREAD CREATED %jx\n", (uintmax_t)(uintptr_t)pthread_self());
|
||||
BH_FREE(targ);
|
||||
#ifdef OS_ENABLE_HW_BOUND_CHECK
|
||||
if (os_thread_signal_init(handler) != 0)
|
||||
|
@ -184,17 +184,18 @@ int os_cond_wait(korp_cond *cond, korp_mutex *mutex)
|
|||
static void msec_nsec_to_abstime(struct timespec *ts, uint64 usec)
|
||||
{
|
||||
struct timeval tv;
|
||||
long int tv_sec_new, tv_nsec_new;
|
||||
time_t tv_sec_new;
|
||||
long int tv_nsec_new;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
|
||||
tv_sec_new = (long int)(tv.tv_sec + usec / 1000000);
|
||||
tv_sec_new = (time_t)(tv.tv_sec + usec / 1000000);
|
||||
if (tv_sec_new >= tv.tv_sec) {
|
||||
ts->tv_sec = tv_sec_new;
|
||||
}
|
||||
else {
|
||||
/* integer overflow */
|
||||
ts->tv_sec = LONG_MAX;
|
||||
ts->tv_sec = BH_TIME_T_MAX;
|
||||
os_printf("Warning: os_cond_reltimedwait exceeds limit, "
|
||||
"set to max timeout instead\n");
|
||||
}
|
||||
|
@ -211,7 +212,7 @@ static void msec_nsec_to_abstime(struct timespec *ts, uint64 usec)
|
|||
"set to max timeout instead\n");
|
||||
}
|
||||
|
||||
if (ts->tv_nsec >= 1000000000L && ts->tv_sec < LONG_MAX) {
|
||||
if (ts->tv_nsec >= 1000000000L && ts->tv_sec < BH_TIME_T_MAX) {
|
||||
ts->tv_sec++;
|
||||
ts->tv_nsec -= 1000000000L;
|
||||
}
|
||||
|
@ -263,7 +264,9 @@ void os_thread_exit(void *retval)
|
|||
return pthread_exit(retval);
|
||||
}
|
||||
|
||||
#if defined(os_thread_local_attribute)
|
||||
static os_thread_local_attribute uint8 *thread_stack_boundary = NULL;
|
||||
#endif
|
||||
|
||||
uint8 *os_thread_get_stack_boundary()
|
||||
{
|
||||
|
@ -276,8 +279,10 @@ uint8 *os_thread_get_stack_boundary()
|
|||
size_t stack_size, max_stack_size;
|
||||
int page_size;
|
||||
|
||||
#if defined(os_thread_local_attribute)
|
||||
if (thread_stack_boundary)
|
||||
return thread_stack_boundary;
|
||||
#endif
|
||||
|
||||
page_size = getpagesize();
|
||||
self = pthread_self();
|
||||
|
@ -312,7 +317,9 @@ uint8 *os_thread_get_stack_boundary()
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(os_thread_local_attribute)
|
||||
thread_stack_boundary = addr;
|
||||
#endif
|
||||
return addr;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,10 @@ extern "C" {
|
|||
#define BH_FREE os_free
|
||||
#endif
|
||||
|
||||
#ifndef BH_TIME_T_MAX
|
||||
#define BH_TIME_T_MAX LONG_MAX
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_BUILD)
|
||||
#if defined(COMPILING_WASM_RUNTIME_API)
|
||||
__declspec(dllexport) void *BH_MALLOC(unsigned int size);
|
||||
|
|
|
@ -40,6 +40,9 @@ typedef pthread_t korp_thread;
|
|||
#define os_printf printf
|
||||
#define os_vprintf vprintf
|
||||
|
||||
/* On NuttX, time_t is uint32_t */
|
||||
#define BH_TIME_T_MAX 0xffffffff
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -23,7 +23,7 @@ WAMR_BUILD_TARGET := X86_64
|
|||
endif
|
||||
ifeq ($(CONFIG_HOST_MACOS),y)
|
||||
# Note: invokeNative_em64.s needs BH_PLATFORM_DARWIN
|
||||
CFLAGS += -DBH_PLATFORM_DARWIN
|
||||
AFLAGS += -DBH_PLATFORM_DARWIN
|
||||
endif
|
||||
endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user