use
super::*;
#[repr(C)]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct __BindgenBitfieldUnit<Storage, Align>
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
{
storage: Storage,
align: [Align; 0],
}
impl<Storage, Align> __BindgenBitfieldUnit<Storage, Align>
where
Storage: AsRef<[u8]> + AsMut<[u8]>,
{
#[inline]
pub fn new(storage: Storage) -> Self {
Self { storage, align: [] }
}
#[inline]
pub fn get_bit(&self, index: usize) -> bool {
debug_assert!(index / 8 < self.storage.as_ref().len());
let byte_index = index / 8;
let byte = self.storage.as_ref()[byte_index];
let bit_index = if cfg!(target_endian = "big") {
7 - (index % 8)
} else {
index % 8
};
let mask = 1 << bit_index;
byte & mask == mask
}
#[inline]
pub fn set_bit(&mut self, index: usize, val: bool) {
debug_assert!(index / 8 < self.storage.as_ref().len());
let byte_index = index / 8;
let byte = &mut self.storage.as_mut()[byte_index];
let bit_index = if cfg!(target_endian = "big") {
7 - (index % 8)
} else {
index % 8
};
let mask = 1 << bit_index;
if val {
*byte |= mask;
} else {
*byte &= !mask;
}
}
#[inline]
pub fn get(&self, bit_offset: usize, bit_width: u8) -> u64 {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
let mut val = 0;
for i in 0..(bit_width as usize) {
if self.get_bit(i + bit_offset) {
let index = if cfg!(target_endian = "big") {
bit_width as usize - 1 - i
} else {
i
};
val |= 1 << index;
}
}
val
}
#[inline]
pub fn set(&mut self, bit_offset: usize, bit_width: u8, val: u64) {
debug_assert!(bit_width <= 64);
debug_assert!(bit_offset / 8 < self.storage.as_ref().len());
debug_assert!((bit_offset + (bit_width as usize)) / 8 <= self.storage.as_ref().len());
for i in 0..(bit_width as usize) {
let mask = 1 << i;
let val_bit_is_set = val & mask == mask;
let index = if cfg!(target_endian = "big") {
bit_width as usize - 1 - i
} else {
i
};
self.set_bit(index + bit_offset, val_bit_is_set);
}
}
}
pub const LV_MEM_CUSTOM: u32 = 0;
pub const LV_MEM_SIZE: u32 = 4096;
pub const LV_MEM_ADR: u32 = 0;
pub const LV_MEM_AUTO_DEFRAG: u32 = 1;
pub const LV_MEMCPY_MEMSET_STD: u32 = 0;
pub const LV_MEM_BUF_MAX_NUM: u32 = 16;
pub type lv_res_t = u8;
#[doc = " Heap information structure."]
#[repr(C)]
#[derive(Default, Copy, Clone)]
pub struct lv_mem_monitor_t {
#[doc = "< Total heap size"]
pub total_size: u32,
pub free_cnt: u32,
#[doc = "< Size of available memory"]
pub free_size: u32,
pub free_biggest_size: u32,
pub used_cnt: u32,
#[doc = "< Max size of Heap memory used"]
pub max_used: u32,
#[doc = "< Percentage used"]
pub used_pct: u8,
#[doc = "< Amount of fragmentation"]
pub frag_pct: u8,
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct lv_mem_buf_t {
pub p: *mut ::cty::c_void,
pub size: u16,
pub _bitfield_1: __BindgenBitfieldUnit<[u8; 1usize], u8>,
pub __bindgen_padding_0: [u8; 5usize],
}
impl Default for lv_mem_buf_t {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl lv_mem_buf_t {
#[inline]
pub fn used(&self) -> u8 {
unsafe { ::core::mem::transmute(self._bitfield_1.get(0usize, 1u8) as u8) }
}
#[inline]
pub fn set_used(&mut self, val: u8) {
unsafe {
let val: u8 = ::core::mem::transmute(val);
self._bitfield_1.set(0usize, 1u8, val as u64)
}
}
#[inline]
pub fn new_bitfield_1(used: u8) -> __BindgenBitfieldUnit<[u8; 1usize], u8> {
let mut __bindgen_bitfield_unit: __BindgenBitfieldUnit<[u8; 1usize], u8> =
Default::default();
__bindgen_bitfield_unit.set(0usize, 1u8, {
let used: u8 = unsafe { ::core::mem::transmute(used) };
used as u64
});
__bindgen_bitfield_unit
}
}
pub type lv_mem_buf_arr_t = [lv_mem_buf_t; 16usize];
#[lvgl_macros::safe_wrap(attr)] extern "C" {
#[doc = " Allocate a memory dynamically"]
#[doc = " - __`size`__: size of the memory to allocate in bytes"]
#[doc = " Return: pointer to the allocated memory"]
pub fn lv_mem_alloc(size: usize) -> *mut ::cty::c_void;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
#[doc = " Free an allocated data"]
#[doc = " - __`data`__: pointer to an allocated memory"]
pub fn lv_mem_free(data: *const ::cty::c_void);
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
#[doc = " Reallocate a memory with a new size. The old content will be kept."]
#[doc = " - __`data`__: pointer to an allocated memory."]
#[doc = " Its content will be copied to the new memory block and freed"]
#[doc = " - __`new_size`__: the desired new size in byte"]
#[doc = " Return: pointer to the new memory"]
pub fn lv_mem_realloc(data_p: *mut ::cty::c_void, new_size: usize) -> *mut ::cty::c_void;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
#[doc = " Join the adjacent free memory blocks"]
pub fn lv_mem_defrag();
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
#[doc = " @return"]
pub fn lv_mem_test() -> lv_res_t;
}
#[lvgl_macros::safe_wrap(attr)] extern "C" {
#[doc = " Give information about the work memory of dynamic allocation"]
#[doc = " - __`mon_p`__: pointer to a dm_mon_p variable,"]
#[doc = " the result of the analysis will be stored here"]
pub fn lv_mem_monitor(mon_p: *mut lv_mem_monitor_t);
}