Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/iwasm/common/wasm_application.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,10 @@ execute_func(WASMModuleInstanceCommon *module_inst, const char *name,
}
case VALUE_TYPE_F32:
{
os_printf("%.7g:f32", *(float32 *)(argv1 + k));
// Explicit cast to double to avoid warning.
// Float arguments are promoted to double in variadic
// functions per section 6.5.2.2 of the C99 standard.
os_printf("%.7g:f32", (double)*(float32 *)(argv1 + k));
k++;
break;
}
Expand Down
17 changes: 8 additions & 9 deletions core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,12 +1016,10 @@ update_clock_subscription_data(wasi_subscription_t *in, uint32 nsubscriptions,
}

static wasi_errno_t
execute_interruptible_poll_oneoff(
#if !defined(WASMTIME_SSP_STATIC_CURFDS)
struct fd_table *curfds,
#endif
const __wasi_subscription_t *in, __wasi_event_t *out, size_t nsubscriptions,
size_t *nevents, wasm_exec_env_t exec_env)
execute_interruptible_poll_oneoff(struct fd_table *curfds,
const __wasi_subscription_t *in,
__wasi_event_t *out, size_t nsubscriptions,
size_t *nevents, wasm_exec_env_t exec_env)
{
if (nsubscriptions == 0) {
*nevents = 0;
Expand Down Expand Up @@ -2118,15 +2116,16 @@ wasi_sock_recv(wasm_exec_env_t exec_env, wasi_fd_t sock, iovec_app_t *ri_data,
wasi_roflags_t *ro_flags)
{
wasm_module_inst_t module_inst = get_module_inst(exec_env);
__wasi_addr_t src_addr;
wasi_errno_t error;

if (!validate_native_addr(ro_flags, (uint64)sizeof(wasi_roflags_t)))
return __WASI_EINVAL;

// We call `recvfrom` with NULL source address as `recv` doesn't
// return the source address and this parameter is not used.
*ro_data_len = 0;
error = wasi_sock_recv_from(exec_env, sock, ri_data, ri_data_len, ri_flags,
&src_addr, ro_data_len);
*ro_flags = ri_flags;
NULL, ro_data_len);

return error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ blocking_op_openat(wasm_exec_env_t exec_env, os_file_handle handle,
#ifndef BH_PLATFORM_WINDOWS
/* REVISIT: apply the os_file_handle style abstraction for pollfd? */
__wasi_errno_t
blocking_op_poll(wasm_exec_env_t exec_env, struct pollfd *pfds, nfds_t nfds,
int timeout_ms, int *retp)
blocking_op_poll(wasm_exec_env_t exec_env, os_poll_file_handle *pfds,
os_nfds_t nfds, int timeout_ms, int *retp)
{
int ret;
if (!wasm_runtime_begin_blocking_op(exec_env)) {
return __WASI_EINTR;
}
ret = poll(pfds, nfds, timeout_ms);
ret = os_poll(pfds, nfds, timeout_ms);
wasm_runtime_end_blocking_op(exec_env);
if (ret == -1) {
return convert_errno(errno);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ blocking_op_openat(wasm_exec_env_t exec_env, os_file_handle handle,

#ifndef BH_PLATFORM_WINDOWS
__wasi_errno_t
blocking_op_poll(wasm_exec_env_t exec_env, struct pollfd *pfds, nfds_t nfds,
int timeout, int *retp);
blocking_op_poll(wasm_exec_env_t exec_env, os_poll_file_handle *pfds,
os_nfds_t nfds, int timeout, int *retp);
#endif

#endif /* end of _BLOCKING_OP_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,12 @@ static inline bool
cond_timedwait(struct cond *cond, struct mutex *lock, uint64_t timeout,
bool abstime) REQUIRES_EXCLUSIVE(*lock) NO_LOCK_ANALYSIS
{
#if defined(BH_PLATFORM_ZEPHYR)
// TODO: Implement this for Zephyr
return false;
#else
int ret;
struct timespec ts = {
os_timespec ts = {
.tv_sec = (time_t)(timeout / 1000000000),
.tv_nsec = (long)(timeout % 1000000000),
};
Expand All @@ -210,8 +214,8 @@ cond_timedwait(struct cond *cond, struct mutex *lock, uint64_t timeout,
* realtime clock.
*/
if (cond->clock != CLOCK_REALTIME) {
struct timespec ts_monotonic;
struct timespec ts_realtime;
os_timespec ts_monotonic;
os_timespec ts_realtime;

clock_gettime(cond->clock, &ts_monotonic);
ts.tv_sec -= ts_monotonic.tv_sec;
Expand All @@ -229,7 +233,7 @@ cond_timedwait(struct cond *cond, struct mutex *lock, uint64_t timeout,
++ts.tv_sec;
}
}
#endif
#endif /* !CONFIG_HAS_PTHREAD_CONDATTR_SETCLOCK */
}
else {
#if CONFIG_HAS_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP
Expand All @@ -241,7 +245,7 @@ cond_timedwait(struct cond *cond, struct mutex *lock, uint64_t timeout,
return ret == ETIMEDOUT;
#else
/* Convert to absolute timeout. */
struct timespec ts_now;
os_timespec ts_now;
#if CONFIG_HAS_PTHREAD_CONDATTR_SETCLOCK
clock_gettime(cond->clock, &ts_now);
#else
Expand All @@ -253,13 +257,14 @@ cond_timedwait(struct cond *cond, struct mutex *lock, uint64_t timeout,
ts.tv_nsec -= 1000000000;
++ts.tv_sec;
}
#endif
#endif /* CONFIG_HAS_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */
}

ret = pthread_cond_timedwait(&cond->object, &lock->object, &ts);
bh_assert((ret == 0 || ret == ETIMEDOUT)
&& "pthread_cond_timedwait() failed");
return ret == ETIMEDOUT;
#endif /* BH_PLATFORM_ZEPHYR */
}
#endif

Expand Down
Loading
Loading