@ -71,7 +71,7 @@
# include "../concurrency/strucon.h"
# if YC_DEBUG
# if YC_DEBUG _CODE
/**
* A function to compare list indices , a @ a y_Comparator .
@ -267,7 +267,8 @@ y_list_checkValidity(y_list* l)
y_return_void_dbg ;
}
# endif // YC_DEBUG
# endif // YC_DEBUG_CODE
/**
* Grows the list . This grows it by 4 times to reduce contention when moving
@ -303,9 +304,9 @@ y_list_grow(y_list* l)
oldalloc = l - > cap ;
esize = l - > esize ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
// I want to grow the list 4 times bigger each time.
do
@ -488,9 +489,9 @@ y_list_len(const y_List l)
yc_assert ( l , YC_ASSERT_LIST_NULL ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
ret = l - > nused ;
@ -506,9 +507,9 @@ y_list_cap(const y_List l)
yc_assert ( l , YC_ASSERT_LIST_NULL ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
ret = l - > cap ;
@ -524,9 +525,9 @@ y_list_esize(const y_List l)
yc_assert ( l , YC_ASSERT_LIST_NULL ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
ret = l - > esize ;
@ -546,9 +547,9 @@ y_list_head(const y_List l)
yc_assert ( ( l - > head = = y_LIST_INVALID_ID ) = = ( l - > tail = = y_LIST_INVALID_ID ) ,
YC_ASSERT_LIST_MISMATCH ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
if ( l - > head = = y_LIST_INVALID_ID )
{
@ -575,9 +576,9 @@ y_list_head_id(const y_List l)
yc_assert ( ( l - > head = = y_LIST_INVALID_ID ) = = ( l - > tail = = y_LIST_INVALID_ID ) ,
YC_ASSERT_LIST_MISMATCH ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
ret = l - > head ;
@ -600,9 +601,9 @@ y_list_tail(const y_List l)
yc_assert ( ( l - > head = = y_LIST_INVALID_ID ) = = ( l - > tail = = y_LIST_INVALID_ID ) ,
YC_ASSERT_LIST_MISMATCH ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
if ( l - > tail = = y_LIST_INVALID_ID )
{
@ -629,9 +630,9 @@ y_list_tail_id(const y_List l)
yc_assert ( ( l - > head = = y_LIST_INVALID_ID ) = = ( l - > tail = = y_LIST_INVALID_ID ) ,
YC_ASSERT_LIST_MISMATCH ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
ret = l - > tail ;
@ -653,10 +654,10 @@ y_list_item(const y_List l, y_ListID id)
yc_assert ( l - > head ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
yc_assert ( id ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkId ( l , id ) ;
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
arrayIdx = y_LIST_ARRAY_IDX ( id ) ;
itemIdx = y_LIST_ITEM_IDX ( arrayIdx , id ) ;
@ -682,10 +683,10 @@ y_list_hasPrev(const y_List l, y_ListID id)
yc_assert ( l - > head ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
yc_assert ( id ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkId ( l , id ) ;
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
arrayIdx = y_LIST_ARRAY_IDX ( id ) ;
itemIdx = y_LIST_ITEM_IDX ( arrayIdx , id ) ;
@ -713,10 +714,10 @@ y_list_prev(const y_List l, y_ListID id)
yc_assert ( l - > head ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
yc_assert ( id ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkId ( l , id ) ;
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
arrayIdx = y_LIST_ARRAY_IDX ( id ) ;
itemIdx = y_LIST_ITEM_IDX ( arrayIdx , id ) ;
@ -754,10 +755,10 @@ y_list_prev_id(const y_List l, y_ListID id)
yc_assert ( l - > head ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
yc_assert ( id ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkId ( l , id ) ;
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
arrayIdx = y_LIST_ARRAY_IDX ( id ) ;
itemIdx = y_LIST_ITEM_IDX ( arrayIdx , id ) ;
@ -784,10 +785,10 @@ y_list_hasNext(const y_List l, y_ListID id)
yc_assert ( l - > head ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
yc_assert ( id ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkId ( l , id ) ;
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
arrayIdx = y_LIST_ARRAY_IDX ( id ) ;
itemIdx = y_LIST_ITEM_IDX ( arrayIdx , id ) ;
@ -814,10 +815,10 @@ y_list_next(const y_List l, y_ListID id)
YC_ASSERT_LIST_MISMATCH ) ;
yc_assert ( l - > head ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkId ( l , id ) ;
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
arrayIdx = y_LIST_ARRAY_IDX ( id ) ;
itemIdx = y_LIST_ITEM_IDX ( arrayIdx , id ) ;
@ -854,10 +855,10 @@ y_list_next_id(const y_List l, y_ListID id)
yc_assert ( l - > head ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
yc_assert ( id ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkId ( l , id ) ;
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
arrayIdx = y_LIST_ARRAY_IDX ( id ) ;
itemIdx = y_LIST_ITEM_IDX ( arrayIdx , id ) ;
@ -890,9 +891,9 @@ y_list_prepend_id(y_List l, const void* data, y_ListID* ret)
y_u32 insertIdx ;
y_ListIdxs * idxs ;
void * ptr ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_usize insIdx ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
y_call_dbg ( ) ;
@ -976,14 +977,14 @@ y_list_prepend_id(y_List l, const void* data, y_ListID* ret)
l - > head = insertIdx ;
* ret = insertIdx ;
# if YC_DEBUG
# if YC_DEBUG _CODE
insIdx = y_vec_bsearch_add ( & l - > used , & insertIdx , y_list_idxCmp ) ;
s = y_vec_pushAt ( & l - > used , insIdx , & insertIdx ) ;
y_assert ( s = = y_STATUS_SUCCESS , " Failed to insert used index " ) ;
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
y_return_dbg ( y_STATUS_SUCCESS ) ;
}
@ -1010,9 +1011,9 @@ y_list_append_id(y_List l, const void* data, y_ListID* ret)
y_u32 insertIdx ;
y_ListIdxs * idxs ;
void * ptr ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_usize insIdx ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
// XXX: This function can only use the *_dbg() versions of the y_call*() and
// y_return*() macros! This is because it is used as part of the bootstrap
@ -1103,7 +1104,7 @@ y_list_append_id(y_List l, const void* data, y_ListID* ret)
l - > tail = insertIdx ;
* ret = insertIdx ;
# if YC_DEBUG
# if YC_DEBUG _CODE
if ( l - > emptyHead ! = y_LIST_INVALID_ID )
{
arrayIdx = y_LIST_ARRAY_IDX ( l - > emptyHead ) ;
@ -1120,7 +1121,7 @@ y_list_append_id(y_List l, const void* data, y_ListID* ret)
y_assert ( s = = y_STATUS_SUCCESS , " Failed to insert used index " ) ;
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
y_return_dbg ( y_STATUS_SUCCESS ) ;
}
@ -1149,17 +1150,17 @@ y_list_addBeforeHelper(y_List l, y_ListID id, y_ListIdxs* next_idxs,
y_usize arrayIdx ;
y_usize itemIdx ;
y_ListIdxs * cur_idxs ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_Status s ;
y_ListID oldEmptyHead ;
y_usize insIdx ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
y_call_dbg ( ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
oldEmptyHead = y_LIST_INVALID_ID ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
yc_assert ( l , YC_ASSERT_LIST_NULL ) ;
yc_assert ( ( l - > head = = y_LIST_INVALID_ID ) = = ( l - > tail = = y_LIST_INVALID_ID ) ,
@ -1168,9 +1169,9 @@ y_list_addBeforeHelper(y_List l, y_ListID id, y_ListIdxs* next_idxs,
yc_assert ( id ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
y_assert ( l - > len < y_LIST_INVALID_ID , " List is too big " ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkId ( l , id ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
if ( l - > emptyHead ! = y_LIST_INVALID_ID )
{
@ -1190,9 +1191,9 @@ y_list_addBeforeHelper(y_List l, y_ListID id, y_ListIdxs* next_idxs,
if ( l - > emptyHead ! = y_LIST_INVALID_ID )
{
# if YC_DEBUG
# if YC_DEBUG _CODE
oldEmptyHead = l - > emptyHead ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
l - > emptyHead = cur_idxs - > next ;
}
@ -1221,7 +1222,7 @@ y_list_addBeforeHelper(y_List l, y_ListID id, y_ListIdxs* next_idxs,
l - > head = newID ;
}
# if YC_DEBUG
# if YC_DEBUG _CODE
if ( oldEmptyHead ! = y_LIST_INVALID_ID )
{
arrayIdx = y_LIST_ARRAY_IDX ( l - > emptyHead ) ;
@ -1236,7 +1237,7 @@ y_list_addBeforeHelper(y_List l, y_ListID id, y_ListIdxs* next_idxs,
y_assert ( s = = y_STATUS_SUCCESS , " Failed to insert used index " ) ;
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
y_return_dbg ( newID ) ;
}
@ -1360,17 +1361,17 @@ y_list_addAfterHelper(y_List l, y_ListID id, y_ListIdxs* prev_idxs,
y_usize arrayIdx ;
y_usize itemIdx ;
y_ListIdxs * cur_idxs ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_Status s ;
y_ListID oldEmptyHead ;
y_usize insIdx ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
y_call_dbg ( ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
oldEmptyHead = y_LIST_INVALID_ID ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
yc_assert ( l , YC_ASSERT_LIST_NULL ) ;
yc_assert ( ( l - > head = = y_LIST_INVALID_ID ) = = ( l - > tail = = y_LIST_INVALID_ID ) ,
@ -1379,9 +1380,9 @@ y_list_addAfterHelper(y_List l, y_ListID id, y_ListIdxs* prev_idxs,
yc_assert ( id ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
y_assert ( l - > len < y_LIST_INVALID_ID , " List is too big " ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkId ( l , id ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
if ( l - > emptyHead ! = y_LIST_INVALID_ID )
{
@ -1401,9 +1402,9 @@ y_list_addAfterHelper(y_List l, y_ListID id, y_ListIdxs* prev_idxs,
if ( l - > emptyHead ! = y_LIST_INVALID_ID )
{
# if YC_DEBUG
# if YC_DEBUG _CODE
oldEmptyHead = l - > emptyHead ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
l - > emptyHead = cur_idxs - > next ;
}
@ -1432,7 +1433,7 @@ y_list_addAfterHelper(y_List l, y_ListID id, y_ListIdxs* prev_idxs,
l - > tail = newID ;
}
# if YC_DEBUG
# if YC_DEBUG _CODE
if ( oldEmptyHead ! = y_LIST_INVALID_ID )
{
arrayIdx = y_LIST_ARRAY_IDX ( l - > emptyHead ) ;
@ -1447,7 +1448,7 @@ y_list_addAfterHelper(y_List l, y_ListID id, y_ListIdxs* prev_idxs,
y_assert ( s = = y_STATUS_SUCCESS , " Failed to insert used index " ) ;
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
y_return_dbg ( newID ) ;
}
@ -1579,9 +1580,9 @@ y_list_nmoveBefore(y_List l, y_usize n, y_ListID itemId, y_ListID id)
YC_ASSERT_LIST_MISMATCH ) ;
yc_assert ( id ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkId ( l , id ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
idxs = NULL ;
tempId = itemId ;
@ -1670,9 +1671,9 @@ y_list_nmoveBefore(y_List l, y_usize n, y_ListID itemId, y_ListID id)
l - > head = itemId ;
}
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
y_return_void_dbg ;
}
@ -1709,9 +1710,9 @@ y_list_nmoveAfter(y_List l, y_usize n, y_ListID itemId, y_ListID id)
YC_ASSERT_LIST_MISMATCH ) ;
yc_assert ( id ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkId ( l , id ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
idxs = NULL ;
tempId = itemId ;
@ -1794,9 +1795,9 @@ y_list_nmoveAfter(y_List l, y_usize n, y_ListID itemId, y_ListID id)
l - > tail = prevId ;
}
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
y_return_void_dbg ;
}
@ -1828,9 +1829,9 @@ y_list_nremove(y_list* l, y_usize n, y_ListID id)
y_assert ( n > 0 , " Must remove more than 0 elements " ) ;
yc_assert ( id ! = y_LIST_INVALID_ID , YC_ASSERT_LIST_INVALID_ID ) ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkId ( l , id ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
arrayIdx = y_LIST_ARRAY_IDX ( id ) ;
itemIdx = y_LIST_ITEM_IDX ( arrayIdx , id ) ;
@ -1850,7 +1851,7 @@ y_list_nremove(y_list* l, y_usize n, y_ListID id)
for ( i = 0 ; i < n ; + + i )
{
# if YC_DEBUG
# if YC_DEBUG _CODE
y_usize j ;
j = y_vec_bsearch ( & l - > used , & id , y_list_idxCmp ) ;
@ -1858,7 +1859,7 @@ y_list_nremove(y_list* l, y_usize n, y_ListID id)
y_assertv ( j ! = y_VEC_INVALID_IDX , " index is invalid: %zu " , j ) ;
y_vec_popAt ( & l - > used , j ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
arrayIdx = y_LIST_ARRAY_IDX ( id ) ;
itemIdx = y_LIST_ITEM_IDX ( arrayIdx , id ) ;
@ -1882,7 +1883,7 @@ y_list_nremove(y_list* l, y_usize n, y_ListID id)
{
for ( i = 0 ; i < n ; + + i )
{
# if YC_DEBUG
# if YC_DEBUG _CODE
y_usize j ;
j = y_vec_bsearch ( & l - > used , & id , y_list_idxCmp ) ;
@ -1890,7 +1891,7 @@ y_list_nremove(y_list* l, y_usize n, y_ListID id)
y_assertv ( j ! = y_VEC_INVALID_IDX , " index is invalid: %zu " , j ) ;
y_vec_popAt ( & l - > used , j ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
arrayIdx = y_LIST_ARRAY_IDX ( id ) ;
itemIdx = y_LIST_ITEM_IDX ( arrayIdx , id ) ;
@ -1955,9 +1956,9 @@ y_list_nremove(y_list* l, y_usize n, y_ListID id)
l - > nused - = 1 ;
# if YC_DEBUG
# if YC_DEBUG _CODE
y_list_checkValidity ( l ) ;
# endif // YC_DEBUG
# endif // YC_DEBUG _CODE
y_return_void_dbg ;
}