Skip to content

Commit c020326

Browse files
committed
refactor: remove duplicated code
1 parent 34ede54 commit c020326

1 file changed

Lines changed: 13 additions & 25 deletions

File tree

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

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,12 @@
66
#include "libc_wasi_wrapper.h"
77
#include "bh_platform.h"
88
#include "wasm_export.h"
9+
#include "wasm_runtime_common.h"
910

1011
#if WASM_ENABLE_THREAD_MGR != 0
1112
#include "../../../thread-mgr/thread_manager.h"
12-
typedef struct WASIContext *wasi_ctx_t;
13-
#else
14-
typedef struct WASIContext {
15-
struct fd_table *curfds;
16-
struct fd_prestats *prestats;
17-
struct argv_environ_values *argv_environ;
18-
struct addr_pool *addr_pool;
19-
char *ns_lookup_buf;
20-
char **ns_lookup_list;
21-
char *argv_buf;
22-
char **argv_list;
23-
char *env_buf;
24-
char **env_list;
25-
uint32_t exit_code;
26-
} * wasi_ctx_t;
2713
#endif
2814

29-
typedef struct wasi_prestat_app {
30-
wasi_preopentype_t pr_type;
31-
uint32 pr_name_len;
32-
} wasi_prestat_app_t;
33-
34-
typedef struct iovec_app {
35-
uint32 buf_offset;
36-
uint32 buf_len;
37-
} iovec_app_t;
38-
3915
void
4016
wasm_runtime_set_exception(wasm_module_inst_t module, const char *exception);
4117

@@ -65,6 +41,18 @@ wasm_runtime_set_exception(wasm_module_inst_t module, const char *exception);
6541
wasm_runtime_module_free(module_inst, offset)
6642
/* clang-format on */
6743

44+
typedef struct wasi_prestat_app {
45+
wasi_preopentype_t pr_type;
46+
uint32 pr_name_len;
47+
} wasi_prestat_app_t;
48+
49+
typedef struct iovec_app {
50+
uint32 buf_offset;
51+
uint32 buf_len;
52+
} iovec_app_t;
53+
54+
typedef struct WASIContext *wasi_ctx_t;
55+
6856
wasi_ctx_t
6957
wasm_runtime_get_wasi_ctx(wasm_module_inst_t module_inst);
7058

0 commit comments

Comments
 (0)