Skip to content

Commit e87f7a9

Browse files
authored
Fix Windows compile error when uvwasi is enabled (#3810)
No need to compile win_file.c when uvwasi is enabled.
1 parent 2133099 commit e87f7a9

5 files changed

Lines changed: 13 additions & 6 deletions

File tree

core/iwasm/aot/aot_loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2520,7 +2520,7 @@ try_merge_data_and_text(const uint8 **buf, const uint8 **buf_end,
25202520
/* order not essential just as compiler does: .text section first */
25212521
*buf = sections;
25222522
*buf_end = sections + code_size;
2523-
bh_memcpy_s(sections, code_size, old_buf, code_size);
2523+
bh_memcpy_s(sections, (uint32)code_size, old_buf, (uint32)code_size);
25242524
os_munmap(old_buf, code_size);
25252525
sections += align_uint((uint32)code_size, page_size);
25262526

core/iwasm/common/wasm_runtime_common.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ runtime_exception_handler(EXCEPTION_POINTERS *exce_info)
340340
PEXCEPTION_RECORD ExceptionRecord = exce_info->ExceptionRecord;
341341
uint8 *sig_addr = (uint8 *)ExceptionRecord->ExceptionInformation[1];
342342
WASMModuleInstance *module_inst;
343-
WASMMemoryInstance *memory_inst;
344343
WASMJmpBuf *jmpbuf_node;
345344
uint8 *mapped_mem_start_addr = NULL;
346345
uint8 *mapped_mem_end_addr = NULL;

core/shared/platform/windows/platform_internal.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,13 @@ typedef struct windows_dir_stream {
168168
windows_handle *handle;
169169
} windows_dir_stream;
170170

171-
typedef windows_handle *os_file_handle;
172171
typedef windows_dir_stream *os_dir_stream;
173172

174-
#if WASM_ENABLE_UVWASI != 1
173+
#if WASM_ENABLE_UVWASI == 0
174+
typedef windows_handle *os_file_handle;
175175
typedef HANDLE os_raw_file_handle;
176176
#else
177+
typedef uint32_t os_file_handle;
177178
typedef uint32_t os_raw_file_handle;
178179
#endif
179180

@@ -190,7 +191,11 @@ typedef uint32_t os_raw_file_handle;
190191
static inline os_file_handle
191192
os_get_invalid_handle(void)
192193
{
194+
#if WASM_ENABLE_UVWASI == 0
193195
return NULL;
196+
#else
197+
return -1;
198+
#endif
194199
}
195200

196201
#ifdef __cplusplus

core/shared/platform/windows/shared_platform.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c
1515

1616
if (NOT WAMR_BUILD_LIBC_WASI EQUAL 1)
1717
list(REMOVE_ITEM source_all ${PLATFORM_SHARED_DIR}/win_file.c)
18+
elseif (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
19+
# uvwasi doesn't need to compile win_file.c
20+
list(REMOVE_ITEM source_all ${PLATFORM_SHARED_DIR}/win_file.c)
1821
else()
1922
include (${CMAKE_CURRENT_LIST_DIR}/../common/libc-util/platform_common_libc_util.cmake)
2023
set(source_all ${source_all} ${PLATFORM_COMMON_LIBC_UTIL_SOURCE})

core/shared/platform/windows/win_socket.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ os_socket_accept(bh_socket_t server_sock, bh_socket_t *sock, void *addr,
182182
(*sock)->type = windows_handle_type_socket;
183183
(*sock)->access_mode = windows_access_mode_read | windows_access_mode_write;
184184
(*sock)->fdflags = 0;
185-
(*sock)->raw.socket =
186-
accept(server_sock->raw.socket, (struct sockaddr *)&addr_tmp, &len);
185+
(*sock)->raw.socket = accept(server_sock->raw.socket,
186+
(struct sockaddr *)&addr_tmp, (int *)&len);
187187

188188
if ((*sock)->raw.socket == INVALID_SOCKET) {
189189
BH_FREE(*sock);

0 commit comments

Comments
 (0)