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

Method body

plugins/wasm_bpf/func-bpf-buffer-poll.cpp:16–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16Expect<int32_t> BpfBufferPoll::body(const Runtime::CallingFrame &Frame,
17 handle_t program, int32_t fd,
18 int32_t sample_func, uint32_t ctx,
19 uint32_t data, uint32_t max_size,
20 int32_t timeout_ms) {
21 auto c_ctx = toCallFrameCxt(&Frame);
22 auto c_module = WasmEdge_CallingFrameGetModuleInstance(c_ctx);
23 auto c_executor = WasmEdge_CallingFrameGetExecutor(c_ctx);
24 if (unlikely(!c_ctx || !c_module || !c_executor)) {
25 return Unexpect(ErrCode::Value::HostFuncError);
26 }
27 auto *memory = Frame.getMemoryByIndex(0);
28 if (unlikely(!memory)) {
29 return Unexpect(ErrCode::Value::HostFuncError);
30 }
31 auto module_instance = Frame.getModule();
32 if (unlikely(!module_instance)) {
33 return Unexpect(ErrCode::Value::HostFuncError);
34 }
35 std::shared_lock lock(state->lock);
36 auto program_ptr = state->handles.find(program);
37 if (program_ptr == state->handles.end()) {
38 return Unexpect(ErrCode::Value::HostFuncError);
39 }
40 auto data_buf = memory->getSpan<char>(data, max_size);
41 if (data_buf.size() != max_size) {
42 return Unexpect(ErrCode::Value::HostFuncError);
43 }
44 return program_ptr->second->bpf_buffer_poll(c_executor, c_module, fd,
45 sample_func, ctx, data_buf.data(),
46 max_size, timeout_ms, data);
47}
48
49} // namespace Host
50} // namespace WasmEdge

Callers

nothing calls this directly

Calls 12

toCallFrameCxtFunction · 0.85
unlikelyFunction · 0.85
UnexpectFunction · 0.85
getMemoryByIndexMethod · 0.80
bpf_buffer_pollMethod · 0.80
getModuleMethod · 0.45
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected