| 14 | } |
| 15 | |
| 16 | Expect<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 |
nothing calls this directly
no test coverage detected