The code below would fail to compile because XDP_UMEM_PGOFF_FILL_RING and XDP_UMEM_PGOFF_COMPLETION_RING are of type c_ulonglong (u64) while XDP_PGOFF_RX_RING and XDP_PGOFF_TX_RING are of type off_t (i64).
enum RingBufferType {
XdpRx,
XdpTx,
XdpFill,
XdpCompletion
}
impl RingBufferType {
fn get_mmap_offset(&self) -> libc::off_t {
match self {
RingBufferType::XdpRx => libc::XDP_PGOFF_RX_RING,
RingBufferType::XdpTx => libc::XDP_PGOFF_TX_RING,
RingBufferType::XdpFill => libc::XDP_UMEM_PGOFF_FILL_RING,
RingBufferType::XdpCompletion => libc::XDP_UMEM_PGOFF_COMPLETION_RING,
}
}
}
Considering that these constants are used for mmap calls in the position of the offset parameter they should all be off type off_t as that is what mmap expects. This can currently be worked around by simple casting the constant with as.
The code below would fail to compile because
XDP_UMEM_PGOFF_FILL_RINGandXDP_UMEM_PGOFF_COMPLETION_RINGare of typec_ulonglong(u64) whileXDP_PGOFF_RX_RINGandXDP_PGOFF_TX_RINGare of typeoff_t(i64).Considering that these constants are used for
mmapcalls in the position of the offset parameter they should all be off typeoff_tas that is whatmmapexpects. This can currently be worked around by simple casting the constant withas.