use crate::trace::*;
use crate::types::*;
#[cfg(not(feature = "list-data-integrity-check"))]
mod integrity {
use super::*;
#[inline(always)]
pub fn listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE(_pxItem: &mut ListItem_t) {}
#[inline(always)]
pub fn listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE(_pxItem: &mut ListItem_t) {}
#[inline(always)]
pub fn listSET_LIST_INTEGRITY_CHECK_1_VALUE(_pxList: &mut List_t) {}
#[inline(always)]
pub fn listSET_LIST_INTEGRITY_CHECK_2_VALUE(_pxList: &mut List_t) {}
#[inline(always)]
pub fn listTEST_LIST_ITEM_INTEGRITY(_pxItem: &ListItem_t) {}
#[inline(always)]
pub fn listTEST_LIST_INTEGRITY(_pxList: &List_t) {}
}
#[cfg(feature = "list-data-integrity-check")]
mod integrity {
use super::*;
use crate::configASSERT;
#[inline(always)]
pub fn listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE(pxItem: &mut ListItem_t) {
pxItem.xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE;
}
#[inline(always)]
pub fn listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE(pxItem: &mut ListItem_t) {
pxItem.xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE;
}
#[inline(always)]
pub fn listSET_LIST_INTEGRITY_CHECK_1_VALUE(pxList: &mut List_t) {
pxList.xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE;
}
#[inline(always)]
pub fn listSET_LIST_INTEGRITY_CHECK_2_VALUE(pxList: &mut List_t) {
pxList.xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE;
}
#[inline(always)]
pub fn listTEST_LIST_ITEM_INTEGRITY(pxItem: &ListItem_t) {
configASSERT(
pxItem.xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE
&& pxItem.xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE,
);
}
#[inline(always)]
pub fn listTEST_LIST_INTEGRITY(pxList: &List_t) {
configASSERT(
pxList.xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE
&& pxList.xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE,
);
}
}
use integrity::*;
#[inline(always)]
fn mtCOVERAGE_TEST_DELAY() {}
#[inline(always)]
fn mtCOVERAGE_TEST_MARKER() {}
#[repr(C)]
pub struct ListItem_t {
#[cfg(feature = "list-data-integrity-check")]
pub xListItemIntegrityValue1: TickType_t,
pub xItemValue: TickType_t,
pub pxNext: *mut ListItem_t,
pub pxPrevious: *mut ListItem_t,
pub pvOwner: *mut core::ffi::c_void,
pub pxContainer: *mut List_t,
#[cfg(feature = "list-data-integrity-check")]
pub xListItemIntegrityValue2: TickType_t,
}
impl ListItem_t {
pub const fn new() -> Self {
ListItem_t {
#[cfg(feature = "list-data-integrity-check")]
xListItemIntegrityValue1: 0,
xItemValue: 0,
pxNext: core::ptr::null_mut(),
pxPrevious: core::ptr::null_mut(),
pvOwner: core::ptr::null_mut(),
pxContainer: core::ptr::null_mut(),
#[cfg(feature = "list-data-integrity-check")]
xListItemIntegrityValue2: 0,
}
}
}
pub type MiniListItem_t = ListItem_t;
pub type StaticListItem_t = ListItem_t;
#[repr(C)]
pub struct List_t {
#[cfg(feature = "list-data-integrity-check")]
pub xListIntegrityValue1: TickType_t,
pub uxNumberOfItems: UBaseType_t,
pub pxIndex: *mut ListItem_t,
pub xListEnd: MiniListItem_t,
#[cfg(feature = "list-data-integrity-check")]
pub xListIntegrityValue2: TickType_t,
}
impl List_t {
pub const fn new() -> Self {
List_t {
#[cfg(feature = "list-data-integrity-check")]
xListIntegrityValue1: 0,
uxNumberOfItems: 0,
pxIndex: core::ptr::null_mut(),
xListEnd: ListItem_t::new(),
#[cfg(feature = "list-data-integrity-check")]
xListIntegrityValue2: 0,
}
}
}
#[inline(always)]
pub unsafe fn listSET_LIST_ITEM_OWNER(
pxListItem: *mut ListItem_t,
pxOwner: *mut core::ffi::c_void,
) {
(*pxListItem).pvOwner = pxOwner;
}
#[inline(always)]
pub unsafe fn listGET_LIST_ITEM_OWNER(pxListItem: *const ListItem_t) -> *mut core::ffi::c_void {
(*pxListItem).pvOwner
}
#[inline(always)]
pub unsafe fn listSET_LIST_ITEM_VALUE(pxListItem: *mut ListItem_t, xValue: TickType_t) {
(*pxListItem).xItemValue = xValue;
}
#[inline(always)]
pub unsafe fn listGET_LIST_ITEM_VALUE(pxListItem: *const ListItem_t) -> TickType_t {
(*pxListItem).xItemValue
}
#[inline(always)]
pub unsafe fn listGET_ITEM_VALUE_OF_HEAD_ENTRY(pxList: *const List_t) -> TickType_t {
(*(*pxList).xListEnd.pxNext).xItemValue
}
#[inline(always)]
pub unsafe fn listGET_HEAD_ENTRY(pxList: *const List_t) -> *mut ListItem_t {
(*pxList).xListEnd.pxNext
}
#[inline(always)]
pub unsafe fn listGET_NEXT(pxListItem: *const ListItem_t) -> *mut ListItem_t {
(*pxListItem).pxNext
}
#[inline(always)]
pub unsafe fn listGET_END_MARKER(pxList: *const List_t) -> *const ListItem_t {
&(*pxList).xListEnd as *const MiniListItem_t as *const ListItem_t
}
#[inline(always)]
pub unsafe fn listLIST_IS_EMPTY(pxList: *const List_t) -> BaseType_t {
if (*pxList).uxNumberOfItems == 0 {
pdTRUE
} else {
pdFALSE
}
}
#[inline(always)]
pub unsafe fn listCURRENT_LIST_LENGTH(pxList: *const List_t) -> UBaseType_t {
(*pxList).uxNumberOfItems
}
#[inline(always)]
pub unsafe fn listGET_OWNER_OF_HEAD_ENTRY(pxList: *const List_t) -> *mut core::ffi::c_void {
(*(*pxList).xListEnd.pxNext).pvOwner
}
#[inline(always)]
pub unsafe fn listIS_CONTAINED_WITHIN(
pxList: *const List_t,
pxListItem: *const ListItem_t,
) -> BaseType_t {
if (*pxListItem).pxContainer == pxList as *mut List_t {
pdTRUE
} else {
pdFALSE
}
}
#[inline(always)]
pub unsafe fn listLIST_ITEM_CONTAINER(pxListItem: *const ListItem_t) -> *mut List_t {
(*pxListItem).pxContainer
}
#[inline(always)]
pub unsafe fn listLIST_IS_INITIALISED(pxList: *const List_t) -> BaseType_t {
if (*pxList).xListEnd.xItemValue == portMAX_DELAY {
pdTRUE
} else {
pdFALSE
}
}
#[inline(always)]
pub unsafe fn listGET_OWNER_OF_NEXT_ENTRY(pxList: *mut List_t) -> *mut core::ffi::c_void {
let pxConstList = pxList;
(*pxConstList).pxIndex = (*(*pxConstList).pxIndex).pxNext;
if (*pxConstList).pxIndex as *const ListItem_t == listGET_END_MARKER(pxConstList) {
(*pxConstList).pxIndex = (*(*pxConstList).xListEnd.pxNext).pxNext;
(*pxConstList).pxIndex = (*pxConstList).xListEnd.pxNext;
}
(*(*pxConstList).pxIndex).pvOwner
}
pub unsafe fn vListInitialise(pxList: *mut List_t) {
traceENTER_vListInitialise(pxList);
(*pxList).pxIndex = &mut (*pxList).xListEnd as *mut MiniListItem_t as *mut ListItem_t;
listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE(&mut (*pxList).xListEnd);
(*pxList).xListEnd.xItemValue = portMAX_DELAY;
(*pxList).xListEnd.pxNext = &mut (*pxList).xListEnd as *mut MiniListItem_t as *mut ListItem_t;
(*pxList).xListEnd.pxPrevious =
&mut (*pxList).xListEnd as *mut MiniListItem_t as *mut ListItem_t;
(*pxList).xListEnd.pvOwner = core::ptr::null_mut();
(*pxList).xListEnd.pxContainer = core::ptr::null_mut();
listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE(&mut (*pxList).xListEnd);
(*pxList).uxNumberOfItems = 0;
listSET_LIST_INTEGRITY_CHECK_1_VALUE(&mut *pxList);
listSET_LIST_INTEGRITY_CHECK_2_VALUE(&mut *pxList);
traceRETURN_vListInitialise();
}
pub unsafe fn vListInitialiseItem(pxItem: *mut ListItem_t) {
traceENTER_vListInitialiseItem(pxItem);
(*pxItem).pxContainer = core::ptr::null_mut();
listSET_FIRST_LIST_ITEM_INTEGRITY_CHECK_VALUE(&mut *pxItem);
listSET_SECOND_LIST_ITEM_INTEGRITY_CHECK_VALUE(&mut *pxItem);
traceRETURN_vListInitialiseItem();
}
pub unsafe fn vListInsertEnd(pxList: *mut List_t, pxNewListItem: *mut ListItem_t) {
let pxIndex: *mut ListItem_t = (*pxList).pxIndex;
traceENTER_vListInsertEnd(pxList, pxNewListItem);
listTEST_LIST_INTEGRITY(&*pxList);
listTEST_LIST_ITEM_INTEGRITY(&*pxNewListItem);
(*pxNewListItem).pxNext = pxIndex;
(*pxNewListItem).pxPrevious = (*pxIndex).pxPrevious;
mtCOVERAGE_TEST_DELAY();
(*(*pxIndex).pxPrevious).pxNext = pxNewListItem;
(*pxIndex).pxPrevious = pxNewListItem;
(*pxNewListItem).pxContainer = pxList;
(*pxList).uxNumberOfItems = (*pxList).uxNumberOfItems + 1;
traceRETURN_vListInsertEnd();
}
pub unsafe fn vListInsert(pxList: *mut List_t, pxNewListItem: *mut ListItem_t) {
let mut pxIterator: *mut ListItem_t;
let xValueOfInsertion: TickType_t = (*pxNewListItem).xItemValue;
traceENTER_vListInsert(pxList, pxNewListItem);
listTEST_LIST_INTEGRITY(&*pxList);
listTEST_LIST_ITEM_INTEGRITY(&*pxNewListItem);
if xValueOfInsertion == portMAX_DELAY {
pxIterator = (*pxList).xListEnd.pxPrevious;
} else {
pxIterator = &mut (*pxList).xListEnd as *mut MiniListItem_t as *mut ListItem_t;
while (*(*pxIterator).pxNext).xItemValue <= xValueOfInsertion {
pxIterator = (*pxIterator).pxNext;
}
}
(*pxNewListItem).pxNext = (*pxIterator).pxNext;
(*(*pxNewListItem).pxNext).pxPrevious = pxNewListItem;
(*pxNewListItem).pxPrevious = pxIterator;
(*pxIterator).pxNext = pxNewListItem;
(*pxNewListItem).pxContainer = pxList;
(*pxList).uxNumberOfItems = (*pxList).uxNumberOfItems + 1;
traceRETURN_vListInsert();
}
pub unsafe fn uxListRemove(pxItemToRemove: *mut ListItem_t) -> UBaseType_t {
let pxList: *mut List_t = (*pxItemToRemove).pxContainer;
traceENTER_uxListRemove(pxItemToRemove);
(*(*pxItemToRemove).pxNext).pxPrevious = (*pxItemToRemove).pxPrevious;
(*(*pxItemToRemove).pxPrevious).pxNext = (*pxItemToRemove).pxNext;
mtCOVERAGE_TEST_DELAY();
if (*pxList).pxIndex == pxItemToRemove {
(*pxList).pxIndex = (*pxItemToRemove).pxPrevious;
} else {
mtCOVERAGE_TEST_MARKER();
}
(*pxItemToRemove).pxContainer = core::ptr::null_mut();
(*pxList).uxNumberOfItems = (*pxList).uxNumberOfItems - 1;
traceRETURN_uxListRemove((*pxList).uxNumberOfItems);
(*pxList).uxNumberOfItems
}
#[inline(always)]
pub unsafe fn listREMOVE_ITEM(pxItemToRemove: *mut ListItem_t) {
let pxList: *mut List_t = (*pxItemToRemove).pxContainer;
(*(*pxItemToRemove).pxNext).pxPrevious = (*pxItemToRemove).pxPrevious;
(*(*pxItemToRemove).pxPrevious).pxNext = (*pxItemToRemove).pxNext;
if (*pxList).pxIndex == pxItemToRemove {
(*pxList).pxIndex = (*pxItemToRemove).pxPrevious;
}
(*pxItemToRemove).pxContainer = core::ptr::null_mut();
(*pxList).uxNumberOfItems = (*pxList).uxNumberOfItems - 1;
}
#[inline(always)]
pub unsafe fn listINSERT_END(pxList: *mut List_t, pxNewListItem: *mut ListItem_t) {
let pxIndex: *mut ListItem_t = (*pxList).pxIndex;
listTEST_LIST_INTEGRITY(&*pxList);
listTEST_LIST_ITEM_INTEGRITY(&*pxNewListItem);
(*pxNewListItem).pxNext = pxIndex;
(*pxNewListItem).pxPrevious = (*pxIndex).pxPrevious;
(*(*pxIndex).pxPrevious).pxNext = pxNewListItem;
(*pxIndex).pxPrevious = pxNewListItem;
(*pxNewListItem).pxContainer = pxList;
(*pxList).uxNumberOfItems = (*pxList).uxNumberOfItems + 1;
}