Skip to content

Commit 2f1420a

Browse files
committed
Fixed windows & sgx implementation error & clang formatted
1 parent c85a957 commit 2f1420a

File tree

7 files changed

+64
-54
lines changed

7 files changed

+64
-54
lines changed

core/iwasm/libraries/lib-socket/inc/wasi_socket_ext.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@ static inline __wasi_errno_t
455455
__wasi_sock_get_recv_timeout(__wasi_fd_t fd, uint64_t *timeout_us)
456456
{
457457
return (__wasi_errno_t)
458-
__imported_wasi_snapshot_preview1_sock_get_recv_timeout((int32_t)fd,
459-
(int32_t)timeout_us);
458+
__imported_wasi_snapshot_preview1_sock_get_recv_timeout(
459+
(int32_t)fd, (int32_t)timeout_us);
460460
}
461461

462462
int32_t
@@ -469,8 +469,8 @@ static inline __wasi_errno_t
469469
__wasi_sock_set_recv_timeout(__wasi_fd_t fd, uint64_t *timeout_us)
470470
{
471471
return (__wasi_errno_t)
472-
__imported_wasi_snapshot_preview1_sock_set_recv_timeout((int32_t)fd,
473-
(int32_t)timeout_us);
472+
__imported_wasi_snapshot_preview1_sock_set_recv_timeout(
473+
(int32_t)fd, (int32_t)timeout_us);
474474
}
475475

476476
int32_t
@@ -483,8 +483,8 @@ static inline __wasi_errno_t
483483
__wasi_sock_get_send_timeout(__wasi_fd_t fd, uint64_t *timeout_us)
484484
{
485485
return (__wasi_errno_t)
486-
__imported_wasi_snapshot_preview1_sock_get_send_timeout((int32_t)fd,
487-
(int32_t)timeout_us);
486+
__imported_wasi_snapshot_preview1_sock_get_send_timeout(
487+
(int32_t)fd, (int32_t)timeout_us);
488488
}
489489

490490
int32_t
@@ -497,8 +497,8 @@ static inline __wasi_errno_t
497497
__wasi_sock_set_send_timeout(__wasi_fd_t fd, uint64_t *timeout_us)
498498
{
499499
return (__wasi_errno_t)
500-
__imported_wasi_snapshot_preview1_sock_set_send_timeout((int32_t)fd,
501-
(int32_t)timeout_us);
500+
__imported_wasi_snapshot_preview1_sock_set_send_timeout(
501+
(int32_t)fd, (int32_t)timeout_us);
502502
}
503503

504504
/**

core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,8 @@ wasi_sock_get_recv_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
11141114
}
11151115

11161116
static wasi_errno_t
1117-
wasi_sock_get_recv_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd, uint64_t *timeout_us)
1117+
wasi_sock_get_recv_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
1118+
uint64_t *timeout_us)
11181119
{
11191120
wasm_module_inst_t module_inst = get_module_inst(exec_env);
11201121
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
@@ -1148,7 +1149,8 @@ wasi_sock_get_send_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
11481149
}
11491150

11501151
static wasi_errno_t
1151-
wasi_sock_get_send_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd, uint64_t *timeout_us)
1152+
wasi_sock_get_send_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
1153+
uint64_t *timeout_us)
11521154
{
11531155
wasm_module_inst_t module_inst = get_module_inst(exec_env);
11541156
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
@@ -1202,7 +1204,8 @@ wasi_sock_set_recv_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
12021204
}
12031205

12041206
static wasi_errno_t
1205-
wasi_sock_set_recv_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd, uint64_t *timeout_us)
1207+
wasi_sock_set_recv_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
1208+
uint64_t *timeout_us)
12061209
{
12071210
wasm_module_inst_t module_inst = get_module_inst(exec_env);
12081211
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
@@ -1236,7 +1239,8 @@ wasi_sock_set_send_buf_size(wasm_exec_env_t exec_env, wasi_fd_t fd,
12361239
}
12371240

12381241
static wasi_errno_t
1239-
wasi_sock_set_send_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd, uint64_t *timeout_us)
1242+
wasi_sock_set_send_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd,
1243+
uint64_t *timeout_us)
12401244
{
12411245
wasm_module_inst_t module_inst = get_module_inst(exec_env);
12421246
wasi_ctx_t wasi_ctx = get_wasi_ctx(module_inst);
@@ -1250,7 +1254,6 @@ wasi_sock_set_send_timeout(wasm_exec_env_t exec_env, wasi_fd_t fd, uint64_t *tim
12501254
return wasmtime_ssp_sock_set_send_timeout(curfds, fd, *timeout_us);
12511255
}
12521256

1253-
12541257
static wasi_errno_t
12551258
wasi_sock_recv(wasm_exec_env_t exec_env, wasi_fd_t sock, iovec_app_t *ri_data,
12561259
uint32 ri_data_len, wasi_riflags_t ri_flags, uint32 *ro_data_len,

core/iwasm/libraries/libc-wasi/sandboxed-system-primitives/src/posix.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3437,30 +3437,30 @@ addr_pool_destroy(struct addr_pool *addr_pool)
34373437
#define WASMTIME_SSP_PASSTHROUGH_FD_TABLE
34383438
#endif
34393439

3440-
// Defines a function that passes through the socket option to the OS implementation
3440+
// Defines a function that passes through the socket option to the OS
3441+
// implementation
34413442
#define WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(FUNC_NAME, OPTION_TYPE) \
3442-
__wasi_errno_t wasmtime_ssp_sock_##FUNC_NAME( \
3443-
WASMTIME_SSP_PASSTHROUGH_FD_TABLE \
3444-
__wasi_fd_t sock, \
3445-
OPTION_TYPE option \
3446-
) { \
3447-
struct fd_object *fo; \
3448-
__wasi_errno_t error; \
3449-
int ret; \
3450-
error = fd_object_get(curfds, &fo, sock, 0, 0); \
3451-
if (error != 0) \
3452-
return error; \
3453-
ret = os_socket_##FUNC_NAME(fd_number(fo), option); \
3454-
fd_object_release(fo); \
3455-
if (BHT_OK != ret) \
3456-
return convert_errno(errno); \
3457-
return __WASI_ESUCCESS; \
3458-
}
3443+
__wasi_errno_t wasmtime_ssp_sock_##FUNC_NAME( \
3444+
WASMTIME_SSP_PASSTHROUGH_FD_TABLE __wasi_fd_t sock, \
3445+
OPTION_TYPE option) \
3446+
{ \
3447+
struct fd_object *fo; \
3448+
__wasi_errno_t error; \
3449+
int ret; \
3450+
error = fd_object_get(curfds, &fo, sock, 0, 0); \
3451+
if (error != 0) \
3452+
return error; \
3453+
ret = os_socket_##FUNC_NAME(fd_number(fo), option); \
3454+
fd_object_release(fo); \
3455+
if (BHT_OK != ret) \
3456+
return convert_errno(errno); \
3457+
return __WASI_ESUCCESS; \
3458+
}
34593459

34603460
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_send_timeout, uint64)
3461-
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_send_timeout, uint64*)
3461+
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_send_timeout, uint64 *)
34623462
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(set_recv_timeout, uint64)
3463-
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_recv_timeout, uint64*)
3463+
WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION(get_recv_timeout, uint64 *)
34643464

34653465
#undef WASMTIME_SSP_PASSTHROUGH_FD_TABLE
34663466
#undef WASMTIME_SSP_PASSTHROUGH_SOCKET_OPTION

core/shared/platform/common/posix/posix_socket.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ os_socket_convert_sockaddr(struct sockaddr *addr, uint8_t *buf, size_t buflen,
313313
}
314314

315315
int
316-
os_socket_set_send_timeout(bh_socket_t socket, uint64 timeout_us)
316+
os_socket_set_send_timeout(bh_socket_t socket, uint64 timeout_us)
317317
{
318318
struct timeval tv;
319319
tv.tv_sec = timeout_us / 1000000UL;
@@ -325,7 +325,7 @@ os_socket_set_send_timeout(bh_socket_t socket, uint64 timeout_us)
325325
}
326326

327327
int
328-
os_socket_get_send_timeout(bh_socket_t socket, uint64 *timeout_us)
328+
os_socket_get_send_timeout(bh_socket_t socket, uint64 *timeout_us)
329329
{
330330
struct timeval tv;
331331
socklen_t tv_len = sizeof(tv);
@@ -337,7 +337,7 @@ os_socket_get_send_timeout(bh_socket_t socket, uint64 *timeout_us)
337337
}
338338

339339
int
340-
os_socket_set_recv_timeout(bh_socket_t socket, uint64 timeout_us)
340+
os_socket_set_recv_timeout(bh_socket_t socket, uint64 timeout_us)
341341
{
342342
struct timeval tv;
343343
tv.tv_sec = timeout_us / 1000000UL;
@@ -349,7 +349,7 @@ os_socket_set_recv_timeout(bh_socket_t socket, uint64 timeout_us)
349349
}
350350

351351
int
352-
os_socket_get_recv_timeout(bh_socket_t socket, uint64 *timeout_us)
352+
os_socket_get_recv_timeout(bh_socket_t socket, uint64 *timeout_us)
353353
{
354354
struct timeval tv;
355355
socklen_t tv_len = sizeof(tv);

core/shared/platform/linux-sgx/sgx_socket.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -651,35 +651,35 @@ os_socket_addr_remote(bh_socket_t socket, uint8_t *buf, size_t buflen,
651651
}
652652

653653
int
654-
os_socket_set_send_timeout(bh_socket_t socket, uint64 timeout_us)
654+
os_socket_set_send_timeout(bh_socket_t socket, uint64 timeout_us)
655655
{
656656
errno = ENOSYS;
657657

658-
return BHT_ERROR
658+
return BHT_ERROR;
659659
}
660660

661661
int
662-
os_socket_get_send_timeout(bh_socket_t socket, uint64 *timeout_us)
662+
os_socket_get_send_timeout(bh_socket_t socket, uint64 *timeout_us)
663663
{
664664
errno = ENOSYS;
665665

666-
return BHT_ERROR
666+
return BHT_ERROR;
667667
}
668668

669669
int
670-
os_socket_set_recv_timeout(bh_socket_t socket, uint64 timeout_us)
670+
os_socket_set_recv_timeout(bh_socket_t socket, uint64 timeout_us)
671671
{
672672
errno = ENOSYS;
673673

674-
return BHT_ERROR
674+
return BHT_ERROR;
675675
}
676676

677677
int
678-
os_socket_get_recv_timeout(bh_socket_t socket, uint64 *timeout_us)
678+
os_socket_get_recv_timeout(bh_socket_t socket, uint64 *timeout_us)
679679
{
680680
errno = ENOSYS;
681681

682-
return BHT_ERROR
682+
return BHT_ERROR;
683683
}
684684

685685
#endif

core/shared/platform/windows/win_socket.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,35 +184,35 @@ os_socket_addr_local(bh_socket_t socket, uint8_t *buf, size_t buflen,
184184
}
185185

186186
int
187-
os_socket_set_send_timeout(bh_socket_t socket, uint64 timeout_us)
187+
os_socket_set_send_timeout(bh_socket_t socket, uint64 timeout_us)
188188
{
189189
errno = ENOSYS;
190190

191-
return BHT_ERROR
191+
return BHT_ERROR;
192192
}
193193

194194
int
195-
os_socket_get_send_timeout(bh_socket_t socket, uint64 *timeout_us)
195+
os_socket_get_send_timeout(bh_socket_t socket, uint64 *timeout_us)
196196
{
197197
errno = ENOSYS;
198198

199-
return BHT_ERROR
199+
return BHT_ERROR;
200200
}
201201

202202
int
203-
os_socket_set_recv_timeout(bh_socket_t socket, uint64 timeout_us)
203+
os_socket_set_recv_timeout(bh_socket_t socket, uint64 timeout_us)
204204
{
205205
errno = ENOSYS;
206206

207-
return BHT_ERROR
207+
return BHT_ERROR;
208208
}
209209

210210
int
211-
os_socket_get_recv_timeout(bh_socket_t socket, uint64 *timeout_us)
211+
os_socket_get_recv_timeout(bh_socket_t socket, uint64 *timeout_us)
212212
{
213213
errno = ENOSYS;
214214

215-
return BHT_ERROR
215+
return BHT_ERROR;
216216
}
217217

218218
int

samples/socket-api/wasm-src/socket_opts.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
#include <wasi_socket_ext.h>
77
#endif
88

9-
#define OPTION_ASSERT(A, B, OPTION) if (A == B) { printf("%s is expected\n", OPTION); } else { printf("%s is unexpected\n", OPTION); return EXIT_FAILURE; }
9+
#define OPTION_ASSERT(A, B, OPTION) \
10+
if (A == B) { \
11+
printf("%s is expected\n", OPTION); \
12+
} \
13+
else { \
14+
printf("%s is unexpected\n", OPTION); \
15+
return EXIT_FAILURE; \
16+
}
1017

1118
int
1219
main(int argc, char *argv[])

0 commit comments

Comments
 (0)