1616#include " include/proxy-wasm/wasm_vm.h"
1717
1818#include " include/proxy-wasm/dyn_vm_plugin.h"
19- #include < iostream >
19+ #include < cstdarg >
2020#include < dlfcn.h>
21- #include < thread >
21+ #include < iostream >
2222#include < sstream>
23- #include < string>
2423#include < stdexcept>
24+ #include < string>
25+ #include < thread>
2526#include < unistd.h>
26- #include < cstdarg>
2727
2828namespace proxy_wasm {
2929
@@ -61,16 +61,16 @@ DynVmPluginSource::~DynVmPluginSource() {
6161}
6262
6363void DynVmPlugin::getFunction (std::string_view function_name, proxy_wasm::WasmCallVoid<0 > *f) {
64- if (source->dl_handle == NULL ) {
64+ if (source->dl_handle == nullptr ) {
6565 *f = nullptr ;
6666 return ;
6767 }
6868 void *target = dlsym (source->dl_handle , std::string (function_name).c_str ());
69- if (target == NULL ) {
69+ if (target == nullptr ) {
7070 *f = nullptr ;
7171 return ;
7272 }
73- void (* target_func)() = reinterpret_cast <void (*)()>(target);
73+ auto target_func = reinterpret_cast <void (*)()>(target);
7474 *f = [this , target_func, function_name](proxy_wasm::ContextBase *context) {
7575 proxy_wasm::SaveRestoreContext saved_context (context);
7676 wasm_vm_->integration ()->trace (call_format (function_name, 0 ));
@@ -79,16 +79,16 @@ void DynVmPlugin::getFunction(std::string_view function_name, proxy_wasm::WasmCa
7979}
8080
8181void DynVmPlugin::getFunction (std::string_view function_name, proxy_wasm::WasmCallVoid<1 > *f) {
82- if (source->dl_handle == NULL ) {
82+ if (source->dl_handle == nullptr ) {
8383 *f = nullptr ;
8484 return ;
8585 }
8686 void *target = dlsym (source->dl_handle , std::string (function_name).c_str ());
87- if (target == NULL ) {
87+ if (target == nullptr ) {
8888 *f = nullptr ;
8989 return ;
9090 }
91- void (* target_func)( uint64_t ) = reinterpret_cast <void (*)(uint64_t )>(target);
91+ auto target_func = reinterpret_cast <void (*)(uint64_t )>(target);
9292 *f = [this , target_func, function_name](proxy_wasm::ContextBase *context, proxy_wasm::Word w1) {
9393 proxy_wasm::SaveRestoreContext saved_context (context);
9494 wasm_vm_->integration ()->trace (call_format (function_name, 1 , w1));
@@ -97,16 +97,16 @@ void DynVmPlugin::getFunction(std::string_view function_name, proxy_wasm::WasmCa
9797}
9898
9999void DynVmPlugin::getFunction (std::string_view function_name, proxy_wasm::WasmCallVoid<2 > *f) {
100- if (source->dl_handle == NULL ) {
100+ if (source->dl_handle == nullptr ) {
101101 *f = nullptr ;
102102 return ;
103103 }
104104 void *target = dlsym (source->dl_handle , std::string (function_name).c_str ());
105- if (target == NULL ) {
105+ if (target == nullptr ) {
106106 *f = nullptr ;
107107 return ;
108108 }
109- void (* target_func)( uint64_t , uint64_t ) = reinterpret_cast <void (*)(uint64_t , uint64_t )>(target);
109+ auto target_func = reinterpret_cast <void (*)(uint64_t , uint64_t )>(target);
110110 *f = [this , target_func, function_name](proxy_wasm::ContextBase *context, proxy_wasm::Word w1,
111111 proxy_wasm::Word w2) {
112112 proxy_wasm::SaveRestoreContext saved_context (context);
@@ -116,16 +116,16 @@ void DynVmPlugin::getFunction(std::string_view function_name, proxy_wasm::WasmCa
116116}
117117
118118void DynVmPlugin::getFunction (std::string_view function_name, proxy_wasm::WasmCallVoid<3 > *f) {
119- if (source->dl_handle == NULL ) {
119+ if (source->dl_handle == nullptr ) {
120120 *f = nullptr ;
121121 return ;
122122 }
123123 void *target = dlsym (source->dl_handle , std::string (function_name).c_str ());
124- if (target == NULL ) {
124+ if (target == nullptr ) {
125125 *f = nullptr ;
126126 return ;
127127 }
128- void (* target_func)( uint64_t , uint64_t , uint64_t ) =
128+ auto target_func =
129129 reinterpret_cast <void (*)(uint64_t , uint64_t , uint64_t )>(target);
130130 *f = [this , target_func, function_name](proxy_wasm::ContextBase *context, proxy_wasm::Word w1,
131131 proxy_wasm::Word w2, proxy_wasm::Word w3) {
@@ -136,16 +136,16 @@ void DynVmPlugin::getFunction(std::string_view function_name, proxy_wasm::WasmCa
136136}
137137
138138void DynVmPlugin::getFunction (std::string_view function_name, proxy_wasm::WasmCallVoid<5 > *f) {
139- if (source->dl_handle == NULL ) {
139+ if (source->dl_handle == nullptr ) {
140140 *f = nullptr ;
141141 return ;
142142 }
143143 void *target = dlsym (source->dl_handle , std::string (function_name).c_str ());
144- if (target == NULL ) {
144+ if (target == nullptr ) {
145145 *f = nullptr ;
146146 return ;
147147 }
148- void (* target_func)( uint64_t , uint64_t , uint64_t , uint64_t , uint64_t ) =
148+ auto target_func =
149149 reinterpret_cast <void (*)(uint64_t , uint64_t , uint64_t , uint64_t , uint64_t )>(target);
150150 *f = [this , target_func, function_name](proxy_wasm::ContextBase *context, proxy_wasm::Word w1,
151151 proxy_wasm::Word w2, proxy_wasm::Word w3,
@@ -157,16 +157,16 @@ void DynVmPlugin::getFunction(std::string_view function_name, proxy_wasm::WasmCa
157157}
158158
159159void DynVmPlugin::getFunction (std::string_view function_name, proxy_wasm::WasmCallWord<1 > *f) {
160- if (source->dl_handle == NULL || function_name == " malloc" ) {
160+ if (source->dl_handle == nullptr || function_name == " malloc" ) {
161161 *f = nullptr ;
162162 return ;
163163 }
164164 void *target = dlsym (source->dl_handle , std::string (function_name).c_str ());
165- if (target == NULL ) {
165+ if (target == nullptr ) {
166166 *f = nullptr ;
167167 return ;
168168 }
169- uint64_t (* target_func)( uint64_t ) = reinterpret_cast <uint64_t (*)(uint64_t )>(target);
169+ auto target_func = reinterpret_cast <uint64_t (*)(uint64_t )>(target);
170170 *f = [this , target_func, function_name](proxy_wasm::ContextBase *context, proxy_wasm::Word w1) {
171171 proxy_wasm::SaveRestoreContext saved_context (context);
172172 wasm_vm_->integration ()->trace (call_format (function_name, 1 , w1));
@@ -175,16 +175,16 @@ void DynVmPlugin::getFunction(std::string_view function_name, proxy_wasm::WasmCa
175175}
176176
177177void DynVmPlugin::getFunction (std::string_view function_name, proxy_wasm::WasmCallWord<2 > *f) {
178- if (source->dl_handle == NULL ) {
178+ if (source->dl_handle == nullptr ) {
179179 *f = nullptr ;
180180 return ;
181181 }
182182 void *target = dlsym (source->dl_handle , std::string (function_name).c_str ());
183- if (target == NULL ) {
183+ if (target == nullptr ) {
184184 *f = nullptr ;
185185 return ;
186186 }
187- uint64_t (* target_func)( uint64_t , uint64_t ) =
187+ auto target_func =
188188 reinterpret_cast <uint64_t (*)(uint64_t , uint64_t )>(target);
189189 *f = [this , target_func, function_name](proxy_wasm::ContextBase *context, proxy_wasm::Word w1,
190190 proxy_wasm::Word w2) {
@@ -195,16 +195,16 @@ void DynVmPlugin::getFunction(std::string_view function_name, proxy_wasm::WasmCa
195195}
196196
197197void DynVmPlugin::getFunction (std::string_view function_name, proxy_wasm::WasmCallWord<3 > *f) {
198- if (source->dl_handle == NULL ) {
198+ if (source->dl_handle == nullptr ) {
199199 *f = nullptr ;
200200 return ;
201201 }
202202 void *target = dlsym (source->dl_handle , std::string (function_name).c_str ());
203- if (target == NULL ) {
203+ if (target == nullptr ) {
204204 *f = nullptr ;
205205 return ;
206206 }
207- uint64_t (* target_func)( uint64_t , uint64_t , uint64_t ) =
207+ auto target_func =
208208 reinterpret_cast <uint64_t (*)(uint64_t , uint64_t , uint64_t )>(target);
209209 *f = [this , target_func, function_name](proxy_wasm::ContextBase *context, proxy_wasm::Word w1,
210210 proxy_wasm::Word w2, proxy_wasm::Word w3) {
0 commit comments