MCPcopy Create free account
hub / github.com/PLSysSec/wave / poll_parse_fds

Function poll_parse_fds

src/poll.rs:70–93  ·  view source on GitHub ↗
(
    ctx: &VmCtx,
    pollfds: &mut Vec<libc::pollfd>,
    fd_data: &mut Vec<(u64, SubscriptionFdType)>,
    userdata: u64,
    subscription_readwrite: SubscriptionFdReadWrite,
)

Source from the content-addressed store, hash-verified

68#[ensures(trace_safe(trace, ctx))]
69#[external_methods(push, to_posix)]
70pub fn poll_parse_fds(
71 ctx: &VmCtx,
72 pollfds: &mut Vec<libc::pollfd>,
73 fd_data: &mut Vec<(u64, SubscriptionFdType)>,
74 userdata: u64,
75 subscription_readwrite: SubscriptionFdReadWrite,
76) -> RuntimeResult<()> {
77 let fd = ctx.fdmap.fd_to_native(subscription_readwrite.v_fd)?;
78 let os_fd: usize = fd.to_raw();
79 // let event = match subscription_readwrite.typ {
80 // SubscriptionFdType::Read => libc::POLLIN,
81 // SubscriptionFdType::Write => libc::POLLOUT,
82 // };
83 let event = subscription_readwrite.typ.to_posix();
84 // convert FD subscriptions to their libc versions
85 let pollfd = libc::pollfd {
86 fd: os_fd as i32,
87 events: event,
88 revents: 0,
89 };
90 pollfds.push(pollfd);
91 fd_data.push((userdata, subscription_readwrite.typ));
92 Ok(())
93}
94
95#[with_ghost_var(trace: &mut Trace)]
96#[requires(ctx_safe(ctx))]

Callers 1

parse_subscriptionsFunction · 0.85

Calls 4

fd_to_nativeMethod · 0.80
to_rawMethod · 0.80
to_posixMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected