1212#include <dfs_fs.h>
1313#include <dfs_posix.h>
1414
15+ #ifdef WAMR_ENABLE_RTT_EXPORT
16+
17+ #ifdef WAMR_RTT_EXPORT_VPRINTF
1518static int wasm_vprintf (wasm_exec_env_t env , const char * fmt , va_list va )
1619{
1720 return vprintf (fmt , va );
@@ -27,6 +30,9 @@ static int wasm_vsnprintf(wasm_exec_env_t env, char *buf, int n, const char *fmt
2730 return vsnprintf (buf , n , fmt , va );
2831}
2932
33+ #endif /* WAMR_RTT_EXPORT_VPRINTF */
34+
35+ #ifdef WAMR_RTT_EXPORT_DEVICE_OPS
3036static rt_device_t wasm_rt_device_find (wasm_exec_env_t env , const char * name )
3137{
3238 return rt_device_find (name );
@@ -57,7 +63,11 @@ static rt_err_t wasm_rt_device_control(wasm_exec_env_t env, rt_device_t dev, in
5763 return rt_device_control (dev , cmd , arg );
5864}
5965
66+ #endif /* WAMR_RTT_EXPORT_DEVICE_OPS */
67+
6068static NativeSymbol native_export_symbols [] = {
69+
70+ #ifdef WAMR_RTT_EXPORT_VPRINTF
6171 {
6272 "vprintf" ,
6373 wasm_vprintf ,
@@ -73,6 +83,9 @@ static NativeSymbol native_export_symbols[] = {
7383 wasm_vsnprintf ,
7484 "($i$*)i"
7585 },
86+ #endif /* WAMR_RTT_EXPORT_VPRINTF */
87+
88+ #ifdef WAMR_RTT_EXPORT_DEVICE_OPS
7689 {
7790 "rt_device_find" ,
7891 wasm_rt_device_find ,
@@ -102,9 +115,39 @@ static NativeSymbol native_export_symbols[] = {
102115 "rt_device_control" ,
103116 wasm_rt_device_control ,
104117 "(ii*)i"
105- }
118+ },
119+ #ifdef WAMR_RTT_EXPORT_DEVICE_OPS_CPP
120+ {
121+ "_Z15rt_device_closeP9rt_device" ,
122+ wasm_rt_device_close ,
123+ "(i)i"
124+ },
125+ {
126+ "_Z14rt_device_readP9rt_devicejPvj" ,
127+ wasm_rt_device_read ,
128+ "(ii*~)i"
129+ },
130+ {
131+ "_Z15rt_device_writeP9rt_devicejPKvj" ,
132+ wasm_rt_device_write ,
133+ "(ii*~)i"
134+ },
135+ {
136+ "_Z14rt_device_openP9rt_devicet" ,
137+ wasm_rt_device_open ,
138+ "(ii)i"
139+ },
140+ {
141+ "_Z14rt_device_findPKc" ,
142+ wasm_rt_device_find ,
143+ "($)i"
144+ },
145+ #endif /* WAMR_RTT_EXPORT_DEVICE_OPS_CPP */
146+ #endif /* WAMR_RTT_EXPORT_DEVICE_OPS */
106147};
107148
149+ #endif /* WAMR_ENABLE_RTT_EXPORT */
150+
108151/**
109152 * run WASM module instance.
110153 * @param module_inst instance of wasm module
@@ -236,9 +279,11 @@ int iwasm(int argc, char **argv)
236279 init_args .mem_alloc_option .allocator .malloc_func = os_malloc ;
237280 init_args .mem_alloc_option .allocator .realloc_func = os_realloc ;
238281 init_args .mem_alloc_option .allocator .free_func = os_free ;
282+ #ifdef WAMR_ENABLE_RTT_EXPORT
239283 init_args .native_symbols = native_export_symbols ;
240284 init_args .n_native_symbols = sizeof (native_export_symbols ) / sizeof (NativeSymbol );
241285 init_args .native_module_name = "env" ;
286+ #endif /* WAMR_ENABLE_RTT_EXPORT */
242287
243288#ifdef WAMR_ENABLE_IWASM_PARAMS
244289#if defined(RT_USING_HEAP ) && defined(RT_USING_MEMHEAP_AS_HEAP )
0 commit comments