Skip to content

map support#6

Merged
dvc94ch merged 5 commits intomasterfrom
maps
Jan 22, 2021
Merged

map support#6
dvc94ch merged 5 commits intomasterfrom
maps

Conversation

@dvc94ch
Copy link
Owner

@dvc94ch dvc94ch commented Jan 20, 2021

No description provided.

Comment on lines 21 to 45
/// Hash table map.
///
/// High level API for BPF_MAP_TYPE_HASH maps.
#[repr(transparent)]
#[repr(C)]
pub struct HashMap<K, V> {
def: bpf_helpers_sys::bpf_map_def,
_k: PhantomData<K>,
_v: PhantomData<V>,
type_: c_uint,
key_size: *const [K; 1],
value_size: *const [V; 1],
max_entries: *const [(); 16],
map_flags: *const [u8; 1],
}

impl<K, V> HashMap<K, V> {
/// Creates a map with the specified maximum number of elements.
pub const fn with_max_entries(max_entries: u32) -> Self {
Self {
def: bpf_helpers_sys::bpf_map_def {
type_: bpf_helpers_sys::bpf_map_type_BPF_MAP_TYPE_HASH,
key_size: mem::size_of::<K>() as u32,
value_size: mem::size_of::<V>() as u32,
max_entries,
map_flags: 0,
},
_k: PhantomData,
_v: PhantomData,
type_: bpf_helpers_sys::bpf_map_type_BPF_MAP_TYPE_HASH,
key_size: core::ptr::null(), //mem::size_of::<K>() as _,
value_size: core::ptr::null(), //mem::size_of::<V>() as _,
max_entries: core::ptr::null(),
map_flags: core::ptr::null(), //0,
}
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

@dvc94ch dvc94ch marked this pull request as ready for review January 22, 2021 23:24
@dvc94ch dvc94ch merged commit 143239c into master Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant