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

Method body

test/plugins/wasm_bpf/simple_ringbuf_test.cpp:47–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45public:
46 PollCallbackFunction() {}
47 WasmEdge::Expect<int32_t> body(const WasmEdge::Runtime::CallingFrame &Frame,
48 uint32_t __attribute__((unused)) ctx,
49 uint32_t data, uint32_t data_sz) {
50 using namespace std;
51 using WasmEdge::unlikely;
52 auto *memory = Frame.getMemoryByIndex(0);
53 if (unlikely(!memory)) {
54 return WasmEdge::Unexpect(WasmEdge::ErrCode::Value::HostFuncError);
55 }
56 if (data_sz < static_cast<uint32_t>(sizeof(uint32_t))) {
57 return WasmEdge::Unexpect(WasmEdge::ErrCode::Value::HostFuncError);
58 }
59 const uint32_t *dataPtr = memory->getSpan<const uint32_t>(data, 1).data();
60 if (unlikely(!dataPtr)) {
61 return WasmEdge::Unexpect(WasmEdge::ErrCode::Value::HostFuncError);
62 }
63 EXPECT_EQ(*dataPtr, UINT32_C(0xABCD1234));
64 return 0;
65 }
66};
67
68} // namespace

Callers

nothing calls this directly

Calls 4

unlikelyFunction · 0.85
UnexpectFunction · 0.85
getMemoryByIndexMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected