MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / HostFuncSub

Function HostFuncSub

test/plugins/unittest/testplugin.c:37–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37static WasmEdge_Result
38HostFuncSub(void *Data, const WasmEdge_CallingFrameContext *CallFrameCxt,
39 const WasmEdge_Value *In, WasmEdge_Value *Out) {
40 (void)CallFrameCxt;
41 /*
42 * Host function to calculate A - B,
43 * and accumulate (A - B) to the host data.
44 */
45 int32_t Val1 = WasmEdge_ValueGetI32(In[0]);
46 int32_t Val2 = WasmEdge_ValueGetI32(In[1]);
47 Out[0] = WasmEdge_ValueGenI32(Val1 - Val2);
48 int32_t *Accum = (int32_t *)Data;
49 *Accum += WasmEdge_ValueGetI32(Out[0]);
50 printf("Current accumulate: %d\n", *Accum);
51 return WasmEdge_Result_Success;
52}
53
54static WasmEdge_ModuleInstanceContext *
55CreateTestModule(const struct WasmEdge_ModuleDescriptor *Desc) {

Callers

nothing calls this directly

Calls 1

WasmEdge_ValueGetI32Function · 0.85

Tested by

no test coverage detected