1219820Sjeff/* 2219820Sjeff * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved. 3219820Sjeff * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved. 4219820Sjeff * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 5219820Sjeff * 6219820Sjeff * This software is available to you under a choice of one of two 7219820Sjeff * licenses. You may choose to be licensed under the terms of the GNU 8219820Sjeff * General Public License (GPL) Version 2, available from the file 9219820Sjeff * COPYING in the main directory of this source tree, or the 10219820Sjeff * OpenIB.org BSD license below: 11219820Sjeff * 12219820Sjeff * Redistribution and use in source and binary forms, with or 13219820Sjeff * without modification, are permitted provided that the following 14219820Sjeff * conditions are met: 15219820Sjeff * 16219820Sjeff * - Redistributions of source code must retain the above 17219820Sjeff * copyright notice, this list of conditions and the following 18219820Sjeff * disclaimer. 19219820Sjeff * 20219820Sjeff * - Redistributions in binary form must reproduce the above 21219820Sjeff * copyright notice, this list of conditions and the following 22219820Sjeff * disclaimer in the documentation and/or other materials 23219820Sjeff * provided with the distribution. 24219820Sjeff * 25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32219820Sjeff * SOFTWARE. 33219820Sjeff * 34219820Sjeff */ 35219820Sjeff 36219820Sjeff/* 37219820Sjeff * Abstract: 38219820Sjeff * Declaration of quick list. 39219820Sjeff */ 40219820Sjeff 41219820Sjeff#ifndef _CL_QUICK_LIST_H_ 42219820Sjeff#define _CL_QUICK_LIST_H_ 43219820Sjeff 44219820Sjeff#include <complib/cl_types.h> 45219820Sjeff 46219820Sjeff#ifdef __cplusplus 47219820Sjeff# define BEGIN_C_DECLS extern "C" { 48219820Sjeff# define END_C_DECLS } 49219820Sjeff#else /* !__cplusplus */ 50219820Sjeff# define BEGIN_C_DECLS 51219820Sjeff# define END_C_DECLS 52219820Sjeff#endif /* __cplusplus */ 53219820Sjeff 54219820SjeffBEGIN_C_DECLS 55219820Sjeff/****h* Component Library/Quick List 56219820Sjeff* NAME 57219820Sjeff* Quick List 58219820Sjeff* 59219820Sjeff* DESCRIPTION 60219820Sjeff* Quick list implements a doubly linked that stores user provided 61219820Sjeff* cl_list_item_t structures. 62219820Sjeff* Quick list does not allocate any memory, and can therefore not fail any 63219820Sjeff* operations. Quick list can therefore be useful in minimizing the error 64219820Sjeff* paths in code. 65219820Sjeff* 66219820Sjeff* Quick list is not thread safe, and users must provide serialization when 67219820Sjeff* adding and removing items from the list. Note that it is possible to 68219820Sjeff* walk a quick list while simultaneously adding to it. 69219820Sjeff* 70219820Sjeff* The Quick List functions operate on a cl_qlist_t structure which should be 71219820Sjeff* treated as opaque and should be manipulated only through the provided 72219820Sjeff* functions. 73219820Sjeff* 74219820Sjeff* SEE ALSO 75219820Sjeff* Structures: 76219820Sjeff* cl_qlist_t, cl_list_item_t, cl_list_obj_t 77219820Sjeff* 78219820Sjeff* Callbacks: 79219820Sjeff* cl_pfn_qlist_apply_t, cl_pfn_qlist_find_t 80219820Sjeff* 81219820Sjeff* Item Manipulation: 82219820Sjeff* cl_qlist_set_obj, cl_qlist_obj 83219820Sjeff* 84219820Sjeff* Initialization: 85219820Sjeff* cl_qlist_init 86219820Sjeff* 87219820Sjeff* Iteration: 88219820Sjeff* cl_qlist_next, cl_qlist_prev, cl_qlist_head, cl_qlist_tail, 89219820Sjeff* cl_qlist_end 90219820Sjeff* 91219820Sjeff* Manipulation: 92219820Sjeff* cl_qlist_insert_head, cl_qlist_insert_tail, 93219820Sjeff* cl_qlist_insert_list_head, cl_qlist_insert_list_tail, 94219820Sjeff* cl_qlist_insert_array_head, cl_qlist_insert_array_tail, 95219820Sjeff* cl_qlist_insert_prev, cl_qlist_insert_next, 96219820Sjeff* cl_qlist_remove_head, cl_qlist_remove_tail, 97219820Sjeff* cl_qlist_remove_item, cl_qlist_remove_all 98219820Sjeff* 99219820Sjeff* Search: 100219820Sjeff* cl_is_item_in_qlist, cl_qlist_find_next, cl_qlist_find_prev, 101219820Sjeff* cl_qlist_find_from_head, cl_qlist_find_from_tail 102219820Sjeff* cl_qlist_apply_func, cl_qlist_move_items 103219820Sjeff* 104219820Sjeff* Attributes: 105219820Sjeff* cl_qlist_count, cl_is_qlist_empty 106219820Sjeff*********/ 107219820Sjeff/****s* Component Library: Quick List/cl_list_item_t 108219820Sjeff* NAME 109219820Sjeff* cl_list_item_t 110219820Sjeff* 111219820Sjeff* DESCRIPTION 112219820Sjeff* The cl_list_item_t structure is used by lists to store objects. 113219820Sjeff* 114219820Sjeff* SYNOPSIS 115219820Sjeff*/ 116219820Sjefftypedef struct _cl_list_item { 117219820Sjeff struct _cl_list_item *p_next; 118219820Sjeff struct _cl_list_item *p_prev; 119219820Sjeff#ifdef _DEBUG_ 120219820Sjeff struct _cl_qlist *p_list; 121219820Sjeff#endif 122219820Sjeff} cl_list_item_t; 123219820Sjeff/* 124219820Sjeff* FIELDS 125219820Sjeff* p_next 126219820Sjeff* Used internally by the list. Users should not use this field. 127219820Sjeff* 128219820Sjeff* p_prev 129219820Sjeff* Used internally by the list. Users should not use this field. 130219820Sjeff* 131219820Sjeff* SEE ALSO 132219820Sjeff* Quick List 133219820Sjeff*********/ 134219820Sjeff 135219820Sjeff#define cl_item_obj(item_ptr, obj_ptr, item_field) (typeof(obj_ptr)) \ 136219820Sjeff ((void *)item_ptr - (unsigned long)&((typeof(obj_ptr))0)->item_field) 137219820Sjeff 138219820Sjeff 139219820Sjeff/****s* Component Library: Quick List/cl_list_obj_t 140219820Sjeff* NAME 141219820Sjeff* cl_list_obj_t 142219820Sjeff* 143219820Sjeff* DESCRIPTION 144219820Sjeff* The cl_list_obj_t structure is used by lists to store objects. 145219820Sjeff* 146219820Sjeff* SYNOPSIS 147219820Sjeff*/ 148219820Sjefftypedef struct _cl_list_obj { 149219820Sjeff cl_list_item_t list_item; 150219820Sjeff const void *p_object; /* User's context */ 151219820Sjeff} cl_list_obj_t; 152219820Sjeff/* 153219820Sjeff* FIELDS 154219820Sjeff* list_item 155219820Sjeff* Used internally by the list. Users should not use this field. 156219820Sjeff* 157219820Sjeff* p_object 158219820Sjeff* User defined context. Users should not access this field directly. 159219820Sjeff* Use cl_qlist_set_obj and cl_qlist_obj to set and retrieve the value 160219820Sjeff* of this field. 161219820Sjeff* 162219820Sjeff* NOTES 163219820Sjeff* Users can use the cl_qlist_set_obj and cl_qlist_obj functions to store 164219820Sjeff* and retrieve context information in the list item. 165219820Sjeff* 166219820Sjeff* SEE ALSO 167219820Sjeff* Quick List, cl_qlist_set_obj, cl_qlist_obj, cl_list_item_t 168219820Sjeff*********/ 169219820Sjeff 170219820Sjeff/****s* Component Library: Quick List/cl_qlist_t 171219820Sjeff* NAME 172219820Sjeff* cl_qlist_t 173219820Sjeff* 174219820Sjeff* DESCRIPTION 175219820Sjeff* Quick list structure. 176219820Sjeff* 177219820Sjeff* The cl_qlist_t structure should be treated as opaque and should be 178219820Sjeff* manipulated only through the provided functions. 179219820Sjeff* 180219820Sjeff* SYNOPSIS 181219820Sjeff*/ 182219820Sjefftypedef struct _cl_qlist { 183219820Sjeff cl_list_item_t end; 184219820Sjeff size_t count; 185219820Sjeff cl_state_t state; 186219820Sjeff} cl_qlist_t; 187219820Sjeff/* 188219820Sjeff* FIELDS 189219820Sjeff* end 190219820Sjeff* List item used to mark the end of the list. 191219820Sjeff* 192219820Sjeff* count 193219820Sjeff* Number of items in the list. 194219820Sjeff* 195219820Sjeff* state 196219820Sjeff* State of the quick list. 197219820Sjeff* 198219820Sjeff* SEE ALSO 199219820Sjeff* Quick List 200219820Sjeff*********/ 201219820Sjeff 202219820Sjeff/****d* Component Library: Quick List/cl_pfn_qlist_apply_t 203219820Sjeff* NAME 204219820Sjeff* cl_pfn_qlist_apply_t 205219820Sjeff* 206219820Sjeff* DESCRIPTION 207219820Sjeff* The cl_pfn_qlist_apply_t function type defines the prototype for functions 208219820Sjeff* used to iterate items in a quick list. 209219820Sjeff* 210219820Sjeff* SYNOPSIS 211219820Sjeff*/ 212219820Sjefftypedef void 213219820Sjeff (*cl_pfn_qlist_apply_t) (IN cl_list_item_t * const p_list_item, 214219820Sjeff IN void *context); 215219820Sjeff/* 216219820Sjeff* PARAMETERS 217219820Sjeff* p_list_item 218219820Sjeff* [in] Pointer to a cl_list_item_t structure. 219219820Sjeff* 220219820Sjeff* context 221219820Sjeff* [in] Value passed to the callback function. 222219820Sjeff* 223219820Sjeff* RETURN VALUE 224219820Sjeff* This function does not return a value. 225219820Sjeff* 226219820Sjeff* NOTES 227219820Sjeff* This function type is provided as function prototype reference for the 228219820Sjeff* function provided by users as a parameter to the cl_qlist_apply_func 229219820Sjeff* function. 230219820Sjeff* 231219820Sjeff* SEE ALSO 232219820Sjeff* Quick List, cl_qlist_apply_func 233219820Sjeff*********/ 234219820Sjeff 235219820Sjeff/****d* Component Library: Quick List/cl_pfn_qlist_find_t 236219820Sjeff* NAME 237219820Sjeff* cl_pfn_qlist_find_t 238219820Sjeff* 239219820Sjeff* DESCRIPTION 240219820Sjeff* The cl_pfn_qlist_find_t function type defines the prototype for functions 241219820Sjeff* used to find items in a quick list. 242219820Sjeff* 243219820Sjeff* SYNOPSIS 244219820Sjeff*/ 245219820Sjefftypedef cl_status_t 246219820Sjeff (*cl_pfn_qlist_find_t) (IN const cl_list_item_t * const p_list_item, 247219820Sjeff IN void *context); 248219820Sjeff/* 249219820Sjeff* PARAMETERS 250219820Sjeff* p_list_item 251219820Sjeff* [in] Pointer to a cl_list_item_t. 252219820Sjeff* 253219820Sjeff* context 254219820Sjeff* [in] Value passed to the callback function. 255219820Sjeff* 256219820Sjeff* RETURN VALUES 257219820Sjeff* Return CL_SUCCESS if the desired item was found. This stops list iteration. 258219820Sjeff* 259219820Sjeff* Return CL_NOT_FOUND to continue list iteration. 260219820Sjeff* 261219820Sjeff* NOTES 262219820Sjeff* This function type is provided as function prototype reference for the 263219820Sjeff* function provided by users as a parameter to the cl_qlist_find_from_head, 264219820Sjeff* cl_qlist_find_from_tail, cl_qlist_find_next, and cl_qlist_find_prev 265219820Sjeff* functions. 266219820Sjeff* 267219820Sjeff* SEE ALSO 268219820Sjeff* Quick List, cl_qlist_find_from_head, cl_qlist_find_from_tail, 269219820Sjeff* cl_qlist_find_next, cl_qlist_find_prev 270219820Sjeff*********/ 271219820Sjeff 272219820Sjeff/****i* Component Library: Quick List/__cl_primitive_insert 273219820Sjeff* NAME 274219820Sjeff* __cl_primitive_insert 275219820Sjeff* 276219820Sjeff* DESCRIPTION 277219820Sjeff* Add a new item in front of the specified item. This is a low level 278219820Sjeff* function for use internally by the queuing routines. 279219820Sjeff* 280219820Sjeff* SYNOPSIS 281219820Sjeff*/ 282219820Sjeffstatic inline void 283219820Sjeff__cl_primitive_insert(IN cl_list_item_t * const p_list_item, 284219820Sjeff IN cl_list_item_t * const p_new_item) 285219820Sjeff{ 286219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 287219820Sjeff CL_ASSERT(p_list_item); 288219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 289219820Sjeff CL_ASSERT(p_new_item); 290219820Sjeff 291219820Sjeff p_new_item->p_next = p_list_item; 292219820Sjeff p_new_item->p_prev = p_list_item->p_prev; 293219820Sjeff p_list_item->p_prev = p_new_item; 294219820Sjeff p_new_item->p_prev->p_next = p_new_item; 295219820Sjeff} 296219820Sjeff 297219820Sjeff/* 298219820Sjeff* PARAMETERS 299219820Sjeff* p_list_item 300219820Sjeff* [in] Pointer to cl_list_item_t to insert in front of 301219820Sjeff* 302219820Sjeff* p_new_item 303219820Sjeff* [in] Pointer to cl_list_item_t to add 304219820Sjeff* 305219820Sjeff* RETURN VALUE 306219820Sjeff* This function does not return a value. 307219820Sjeff*********/ 308219820Sjeff 309219820Sjeff/****i* Component Library: Quick List/__cl_primitive_remove 310219820Sjeff* NAME 311219820Sjeff* __cl_primitive_remove 312219820Sjeff* 313219820Sjeff* DESCRIPTION 314219820Sjeff* Remove an item from a list. This is a low level routine 315219820Sjeff* for use internally by the queuing routines. 316219820Sjeff* 317219820Sjeff* SYNOPSIS 318219820Sjeff*/ 319219820Sjeffstatic inline void __cl_primitive_remove(IN cl_list_item_t * const p_list_item) 320219820Sjeff{ 321219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 322219820Sjeff CL_ASSERT(p_list_item); 323219820Sjeff 324219820Sjeff /* set the back pointer */ 325219820Sjeff p_list_item->p_next->p_prev = p_list_item->p_prev; 326219820Sjeff /* set the next pointer */ 327219820Sjeff p_list_item->p_prev->p_next = p_list_item->p_next; 328219820Sjeff 329219820Sjeff /* if we're debugging, spruce up the pointers to help find bugs */ 330219820Sjeff#if defined( _DEBUG_ ) 331219820Sjeff if (p_list_item != p_list_item->p_next) { 332219820Sjeff p_list_item->p_next = NULL; 333219820Sjeff p_list_item->p_prev = NULL; 334219820Sjeff } 335219820Sjeff#endif /* defined( _DEBUG_ ) */ 336219820Sjeff} 337219820Sjeff 338219820Sjeff/* 339219820Sjeff* PARAMETERS 340219820Sjeff* p_list_item 341219820Sjeff* [in] Pointer to cl_list_item_t to remove 342219820Sjeff* 343219820Sjeff* RETURN VALUE 344219820Sjeff* This function does not return a value. 345219820Sjeff*********/ 346219820Sjeff 347219820Sjeff/* 348219820Sjeff * Declaration of quick list functions 349219820Sjeff */ 350219820Sjeff 351219820Sjeff/****f* Component Library: Quick List/cl_qlist_set_obj 352219820Sjeff* NAME 353219820Sjeff* cl_qlist_set_obj 354219820Sjeff* 355219820Sjeff* DESCRIPTION 356219820Sjeff* The cl_qlist_set_obj function sets the object stored in a list object. 357219820Sjeff* 358219820Sjeff* SYNOPSIS 359219820Sjeff*/ 360219820Sjeffstatic inline void 361219820Sjeffcl_qlist_set_obj(IN cl_list_obj_t * const p_list_obj, 362219820Sjeff IN const void *const p_object) 363219820Sjeff{ 364219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 365219820Sjeff CL_ASSERT(p_list_obj); 366219820Sjeff p_list_obj->p_object = p_object; 367219820Sjeff} 368219820Sjeff 369219820Sjeff/* 370219820Sjeff* PARAMETERS 371219820Sjeff* p_list_obj 372219820Sjeff* [in] Pointer to a cl_list_obj_t structure. 373219820Sjeff* 374219820Sjeff* p_object 375219820Sjeff* [in] User defined context. 376219820Sjeff* 377219820Sjeff* RETURN VALUE 378219820Sjeff* This function does not return a value. 379219820Sjeff* 380219820Sjeff* SEE ALSO 381219820Sjeff* Quick List, cl_qlist_obj 382219820Sjeff*********/ 383219820Sjeff 384219820Sjeff/****f* Component Library: Quick List/cl_qlist_obj 385219820Sjeff* NAME 386219820Sjeff* cl_qlist_obj 387219820Sjeff* 388219820Sjeff* DESCRIPTION 389219820Sjeff* The cl_qlist_set_obj function returns the object stored in a list object. 390219820Sjeff* 391219820Sjeff* SYNOPSIS 392219820Sjeff*/ 393219820Sjeffstatic inline void *cl_qlist_obj(IN const cl_list_obj_t * const p_list_obj) 394219820Sjeff{ 395219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 396219820Sjeff CL_ASSERT(p_list_obj); 397219820Sjeff 398219820Sjeff return ((void *)p_list_obj->p_object); 399219820Sjeff} 400219820Sjeff 401219820Sjeff/* 402219820Sjeff* PARAMETERS 403219820Sjeff* p_list_obj 404219820Sjeff* [in] Pointer to a cl_list_obj_t structure. 405219820Sjeff* 406219820Sjeff* RETURN VALUE 407219820Sjeff* Returns the value of the object pointer stored in the list object. 408219820Sjeff* 409219820Sjeff* SEE ALSO 410219820Sjeff* Quick List, cl_qlist_set_obj 411219820Sjeff*********/ 412219820Sjeff 413219820Sjeffstatic inline void __cl_qlist_reset(IN cl_qlist_t * const p_list) 414219820Sjeff{ 415219820Sjeff /* Point the end item to itself. */ 416219820Sjeff p_list->end.p_next = &p_list->end; 417219820Sjeff p_list->end.p_prev = &p_list->end; 418219820Sjeff#if defined( _DEBUG_ ) 419219820Sjeff p_list->end.p_list = p_list; 420219820Sjeff#endif 421219820Sjeff 422219820Sjeff /* Clear the count. */ 423219820Sjeff p_list->count = 0; 424219820Sjeff} 425219820Sjeff 426219820Sjeff/****f* Component Library: Quick List/cl_qlist_init 427219820Sjeff* NAME 428219820Sjeff* cl_qlist_init 429219820Sjeff* 430219820Sjeff* DESCRIPTION 431219820Sjeff* The cl_qlist_init function initializes a quick list. 432219820Sjeff* 433219820Sjeff* SYNOPSIS 434219820Sjeff*/ 435219820Sjeffstatic inline void cl_qlist_init(IN cl_qlist_t * const p_list) 436219820Sjeff{ 437219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 438219820Sjeff CL_ASSERT(p_list); 439219820Sjeff 440219820Sjeff p_list->state = CL_INITIALIZED; 441219820Sjeff 442219820Sjeff /* Reset the quick list data structure. */ 443219820Sjeff __cl_qlist_reset(p_list); 444219820Sjeff} 445219820Sjeff 446219820Sjeff/* 447219820Sjeff* PARAMETERS 448219820Sjeff* p_list 449219820Sjeff* [in] Pointer to a cl_qlist_t structure to initialize. 450219820Sjeff* 451219820Sjeff* RETURN VALUES 452219820Sjeff* This function does not return a value. 453219820Sjeff* 454219820Sjeff* NOTES 455219820Sjeff* Allows calling quick list manipulation functions. 456219820Sjeff* 457219820Sjeff* SEE ALSO 458219820Sjeff* Quick List, cl_qlist_insert_head, cl_qlist_insert_tail, 459219820Sjeff* cl_qlist_remove_head, cl_qlist_remove_tail 460219820Sjeff*********/ 461219820Sjeff 462219820Sjeff/****f* Component Library: Quick List/cl_qlist_count 463219820Sjeff* NAME 464219820Sjeff* cl_qlist_count 465219820Sjeff* 466219820Sjeff* DESCRIPTION 467219820Sjeff* The cl_qlist_count function returns the number of list items stored 468219820Sjeff* in a quick list. 469219820Sjeff* 470219820Sjeff* SYNOPSIS 471219820Sjeff*/ 472219820Sjeffstatic inline uint32_t cl_qlist_count(IN const cl_qlist_t * const p_list) 473219820Sjeff{ 474219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 475219820Sjeff CL_ASSERT(p_list); 476219820Sjeff /* CL_ASSERT that the list was initialized. */ 477219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 478219820Sjeff return ((uint32_t) p_list->count); 479219820Sjeff 480219820Sjeff} 481219820Sjeff 482219820Sjeff/* 483219820Sjeff* PARAMETERS 484219820Sjeff* p_list 485219820Sjeff* [in] Pointer to a cl_qlist_t structure. 486219820Sjeff* 487219820Sjeff* RETURN VALUE 488219820Sjeff* Number of items in the list. This function iterates though the quick 489219820Sjeff* list to count the items. 490219820Sjeff* 491219820Sjeff* SEE ALSO 492219820Sjeff* Quick List, cl_is_qlist_empty 493219820Sjeff*********/ 494219820Sjeff 495219820Sjeff/****f* Component Library: Quick List/cl_is_qlist_empty 496219820Sjeff* NAME 497219820Sjeff* cl_is_qlist_empty 498219820Sjeff* 499219820Sjeff* DESCRIPTION 500219820Sjeff* The cl_is_qlist_empty function returns whether a quick list is empty. 501219820Sjeff* 502219820Sjeff* SYNOPSIS 503219820Sjeff*/ 504219820Sjeffstatic inline boolean_t cl_is_qlist_empty(IN const cl_qlist_t * const p_list) 505219820Sjeff{ 506219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 507219820Sjeff CL_ASSERT(p_list); 508219820Sjeff /* CL_ASSERT that the list was initialized. */ 509219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 510219820Sjeff 511219820Sjeff return (!cl_qlist_count(p_list)); 512219820Sjeff} 513219820Sjeff 514219820Sjeff/* 515219820Sjeff* PARAMETERS 516219820Sjeff* p_list 517219820Sjeff* [in] Pointer to a cl_qlist_t structure. 518219820Sjeff* 519219820Sjeff* RETURN VALUES 520219820Sjeff* TRUE if the specified quick list is empty. 521219820Sjeff* 522219820Sjeff* FALSE otherwise. 523219820Sjeff* 524219820Sjeff* SEE ALSO 525219820Sjeff* Quick List, cl_qlist_count, cl_qlist_remove_all 526219820Sjeff*********/ 527219820Sjeff 528219820Sjeff/****f* Component Library: Quick List/cl_qlist_next 529219820Sjeff* NAME 530219820Sjeff* cl_qlist_next 531219820Sjeff* 532219820Sjeff* DESCRIPTION 533219820Sjeff* The cl_qlist_next function returns a pointer to the list item following 534219820Sjeff* a given list item in a quick list. 535219820Sjeff* 536219820Sjeff* SYNOPSIS 537219820Sjeff*/ 538219820Sjeffstatic inline cl_list_item_t *cl_qlist_next(IN const cl_list_item_t * 539219820Sjeff const p_list_item) 540219820Sjeff{ 541219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 542219820Sjeff CL_ASSERT(p_list_item); 543219820Sjeff /* CL_ASSERT that the list was initialized. */ 544219820Sjeff CL_ASSERT(p_list_item->p_list->state == CL_INITIALIZED); 545219820Sjeff 546219820Sjeff /* Return the next item. */ 547219820Sjeff return (p_list_item->p_next); 548219820Sjeff} 549219820Sjeff 550219820Sjeff/* 551219820Sjeff* PARAMETERS 552219820Sjeff* p_list_item 553219820Sjeff* [in] Pointer to the cl_list_item_t whose successor to return. 554219820Sjeff* 555219820Sjeff* Returns: 556219820Sjeff* Pointer to the list item following the list item specified by 557219820Sjeff* the p_list_item parameter in the quick list. 558219820Sjeff* 559219820Sjeff* Pointer to the list end if p_list_item was at the tail of the list. 560219820Sjeff* 561219820Sjeff* SEE ALSO 562219820Sjeff* Quick List, cl_qlist_head, cl_qlist_tail, cl_qlist_prev, cl_qlist_end, 563219820Sjeff* cl_list_item_t 564219820Sjeff*********/ 565219820Sjeff 566219820Sjeff/****f* Component Library: Quick List/cl_qlist_prev 567219820Sjeff* NAME 568219820Sjeff* cl_qlist_prev 569219820Sjeff* 570219820Sjeff* DESCRIPTION 571219820Sjeff* The cl_qlist_prev function returns a poirter to the list item preceding 572219820Sjeff* a given list item in a quick list. 573219820Sjeff* 574219820Sjeff* SYNOPSIS 575219820Sjeff*/ 576219820Sjeffstatic inline cl_list_item_t *cl_qlist_prev(IN const cl_list_item_t * 577219820Sjeff const p_list_item) 578219820Sjeff{ 579219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 580219820Sjeff CL_ASSERT(p_list_item); 581219820Sjeff /* CL_ASSERT that the list was initialized. */ 582219820Sjeff CL_ASSERT(p_list_item->p_list->state == CL_INITIALIZED); 583219820Sjeff 584219820Sjeff /* Return the previous item. */ 585219820Sjeff return (p_list_item->p_prev); 586219820Sjeff} 587219820Sjeff 588219820Sjeff/* 589219820Sjeff* PARAMETERS 590219820Sjeff* p_list_item 591219820Sjeff* [in] Pointer to the cl_list_item_t whose predecessor to return. 592219820Sjeff* 593219820Sjeff* Returns: 594219820Sjeff* Pointer to the list item preceding the list item specified by 595219820Sjeff* the p_list_item parameter in the quick list. 596219820Sjeff* 597219820Sjeff* Pointer to the list end if p_list_item was at the tail of the list. 598219820Sjeff* 599219820Sjeff* SEE ALSO 600219820Sjeff* Quick List, cl_qlist_head, cl_qlist_tail, cl_qlist_next, cl_qlist_end, 601219820Sjeff* cl_list_item_t 602219820Sjeff*********/ 603219820Sjeff 604219820Sjeff/****f* Component Library: Quick List/cl_qlist_head 605219820Sjeff* NAME 606219820Sjeff* cl_qlist_head 607219820Sjeff* 608219820Sjeff* DESCRIPTION 609219820Sjeff* The cl_qlist_head function returns the list item at 610219820Sjeff* the head of a quick list. 611219820Sjeff* 612219820Sjeff* SYNOPSIS 613219820Sjeff*/ 614219820Sjeffstatic inline cl_list_item_t *cl_qlist_head(IN const cl_qlist_t * const p_list) 615219820Sjeff{ 616219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 617219820Sjeff CL_ASSERT(p_list); 618219820Sjeff /* CL_ASSERT that the list was initialized. */ 619219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 620219820Sjeff 621219820Sjeff return (cl_qlist_next(&p_list->end)); 622219820Sjeff} 623219820Sjeff 624219820Sjeff/* 625219820Sjeff* PARAMETERS 626219820Sjeff* p_list 627219820Sjeff* [in] Pointer to a cl_qlist_t structure. 628219820Sjeff* 629219820Sjeff* RETURN VALUES 630219820Sjeff* Pointer to the list item at the head of the quick list. 631219820Sjeff* 632219820Sjeff* Pointer to the list end if the list was empty. 633219820Sjeff* 634219820Sjeff* NOTES 635219820Sjeff* cl_qlist_head does not remove the item from the list. 636219820Sjeff* 637219820Sjeff* SEE ALSO 638219820Sjeff* Quick List, cl_qlist_tail, cl_qlist_next, cl_qlist_prev, cl_qlist_end, 639219820Sjeff* cl_list_item_t 640219820Sjeff*********/ 641219820Sjeff 642219820Sjeff/****f* Component Library: Quick List/cl_qlist_tail 643219820Sjeff* NAME 644219820Sjeff* cl_qlist_tail 645219820Sjeff* 646219820Sjeff* DESCRIPTION 647219820Sjeff* The cl_qlist_tail function returns the list item at 648219820Sjeff* the tail of a quick list. 649219820Sjeff* 650219820Sjeff* SYNOPSIS 651219820Sjeff*/ 652219820Sjeffstatic inline cl_list_item_t *cl_qlist_tail(IN const cl_qlist_t * const p_list) 653219820Sjeff{ 654219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 655219820Sjeff CL_ASSERT(p_list); 656219820Sjeff /* CL_ASSERT that the list was initialized. */ 657219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 658219820Sjeff 659219820Sjeff return (cl_qlist_prev(&p_list->end)); 660219820Sjeff} 661219820Sjeff 662219820Sjeff/* 663219820Sjeff* PARAMETERS 664219820Sjeff* p_list 665219820Sjeff* [in] Pointer to a cl_qlist_t structure. 666219820Sjeff* 667219820Sjeff* RETURN VALUES 668219820Sjeff* Pointer to the list item at the tail of the quick list. 669219820Sjeff* 670219820Sjeff* Pointer to the list end if the list was empty. 671219820Sjeff* 672219820Sjeff* NOTES 673219820Sjeff* cl_qlist_tail does not remove the item from the list. 674219820Sjeff* 675219820Sjeff* SEE ALSO 676219820Sjeff* Quick List, cl_qlist_head, cl_qlist_next, cl_qlist_prev, cl_qlist_end, 677219820Sjeff* cl_list_item_t 678219820Sjeff*********/ 679219820Sjeff 680219820Sjeff/****f* Component Library: Quick List/cl_qlist_end 681219820Sjeff* NAME 682219820Sjeff* cl_qlist_end 683219820Sjeff* 684219820Sjeff* DESCRIPTION 685219820Sjeff* The cl_qlist_end function returns the end of a quick list. 686219820Sjeff* 687219820Sjeff* SYNOPSIS 688219820Sjeff*/ 689219820Sjeffstatic inline const cl_list_item_t *cl_qlist_end(IN const cl_qlist_t * 690219820Sjeff const p_list) 691219820Sjeff{ 692219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 693219820Sjeff CL_ASSERT(p_list); 694219820Sjeff /* CL_ASSERT that the list was initialized. */ 695219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 696219820Sjeff 697219820Sjeff return (&p_list->end); 698219820Sjeff} 699219820Sjeff 700219820Sjeff/* 701219820Sjeff* PARAMETERS 702219820Sjeff* p_list 703219820Sjeff* [in] Pointer to a cl_qlist_t structure. 704219820Sjeff* 705219820Sjeff* RETURN VALUE 706219820Sjeff* Pointer to the end of the list. 707219820Sjeff* 708219820Sjeff* NOTES 709219820Sjeff* cl_qlist_end is useful for determining the validity of list items returned 710219820Sjeff* by cl_qlist_head, cl_qlist_tail, cl_qlist_next, cl_qlist_prev, as well as 711219820Sjeff* the cl_qlist_find functions. If the list item pointer returned by any of 712219820Sjeff* these functions compares to the end, the end of the list was encoutered. 713219820Sjeff* When using cl_qlist_head or cl_qlist_tail, this condition indicates that 714219820Sjeff* the list is empty. 715219820Sjeff* 716219820Sjeff* SEE ALSO 717219820Sjeff* Quick List, cl_qlist_head, cl_qlist_tail, cl_qlist_next, cl_qlist_prev, 718219820Sjeff* cl_list_item_t 719219820Sjeff*********/ 720219820Sjeff 721219820Sjeff/****f* Component Library: Quick List/cl_qlist_insert_head 722219820Sjeff* NAME 723219820Sjeff* cl_qlist_insert_head 724219820Sjeff* 725219820Sjeff* DESCRIPTION 726219820Sjeff* The cl_qlist_insert_head function inserts a list item at the 727219820Sjeff* head of a quick list. 728219820Sjeff* 729219820Sjeff* SYNOPSIS 730219820Sjeff*/ 731219820Sjeffstatic inline void 732219820Sjeffcl_qlist_insert_head(IN cl_qlist_t * const p_list, 733219820Sjeff IN cl_list_item_t * const p_list_item) 734219820Sjeff{ 735219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 736219820Sjeff CL_ASSERT(p_list); 737219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 738219820Sjeff CL_ASSERT(p_list_item); 739219820Sjeff /* CL_ASSERT that the list was initialized. */ 740219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 741219820Sjeff 742219820Sjeff /* 743219820Sjeff * The list item must not already be part of the list. Note that this 744219820Sjeff * assertion may fail if an uninitialized list item happens to have its 745219820Sjeff * list pointer equal to the specified list. The chances of this 746219820Sjeff * happening are acceptable in light of the value of this check. 747219820Sjeff */ 748219820Sjeff CL_ASSERT(p_list_item->p_list != p_list); 749219820Sjeff 750219820Sjeff#if defined( _DEBUG_ ) 751219820Sjeff p_list_item->p_list = p_list; 752219820Sjeff#endif 753219820Sjeff 754219820Sjeff /* Insert before the head. */ 755219820Sjeff __cl_primitive_insert(cl_qlist_head(p_list), p_list_item); 756219820Sjeff 757219820Sjeff p_list->count++; 758219820Sjeff} 759219820Sjeff 760219820Sjeff/* 761219820Sjeff* PARAMETERS 762219820Sjeff* p_list 763219820Sjeff* [in] Pointer to a cl_qlist_t structure into which to insert the object. 764219820Sjeff* 765219820Sjeff* p_list_item 766219820Sjeff* [in] Pointer to a cl_list_item_t structure to add. 767219820Sjeff* 768219820Sjeff* RETURN VALUE 769219820Sjeff* This function does not return a value. 770219820Sjeff* 771219820Sjeff* NOTES 772219820Sjeff* In debug builds, cl_qlist_insert_head asserts that the specified list item 773219820Sjeff* is not already in the list. 774219820Sjeff* 775219820Sjeff* SEE ALSO 776219820Sjeff* Quick List, cl_qlist_insert_tail, cl_qlist_insert_list_head, 777219820Sjeff* cl_qlist_insert_list_tail, cl_qlist_insert_array_head, 778219820Sjeff* cl_qlist_insert_array_tail, cl_qlist_insert_prev, cl_qlist_insert_next, 779219820Sjeff* cl_qlist_remove_head, cl_list_item_t 780219820Sjeff*********/ 781219820Sjeff 782219820Sjeff/****f* Component Library: Quick List/cl_qlist_insert_tail 783219820Sjeff* NAME 784219820Sjeff* cl_qlist_insert_tail 785219820Sjeff* 786219820Sjeff* DESCRIPTION 787219820Sjeff* The cl_qlist_insert_tail function inserts a list item at the tail 788219820Sjeff* of a quick list. 789219820Sjeff* 790219820Sjeff* SYNOPSIS 791219820Sjeff*/ 792219820Sjeffstatic inline void 793219820Sjeffcl_qlist_insert_tail(IN cl_qlist_t * const p_list, 794219820Sjeff IN cl_list_item_t * const p_list_item) 795219820Sjeff{ 796219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 797219820Sjeff CL_ASSERT(p_list); 798219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 799219820Sjeff CL_ASSERT(p_list_item); 800219820Sjeff /* CL_ASSERT that the list was initialized. */ 801219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 802219820Sjeff 803219820Sjeff /* 804219820Sjeff * The list item must not already be part of the list. Note that this 805219820Sjeff * assertion may fail if an uninitialized list item happens to have its 806219820Sjeff * list pointer equal to the specified list. The chances of this 807219820Sjeff * happening are acceptable in light of the value of this check. 808219820Sjeff */ 809219820Sjeff CL_ASSERT(p_list_item->p_list != p_list); 810219820Sjeff 811219820Sjeff#if defined( _DEBUG_ ) 812219820Sjeff p_list_item->p_list = p_list; 813219820Sjeff#endif 814219820Sjeff 815219820Sjeff /* 816219820Sjeff * Put the new element in front of the end which is the same 817219820Sjeff * as being at the tail 818219820Sjeff */ 819219820Sjeff __cl_primitive_insert(&p_list->end, p_list_item); 820219820Sjeff 821219820Sjeff p_list->count++; 822219820Sjeff} 823219820Sjeff 824219820Sjeff/* 825219820Sjeff* PARAMETERS 826219820Sjeff* p_list 827219820Sjeff* [in] Pointer to a cl_qlist_t structure into which to insert the object. 828219820Sjeff* 829219820Sjeff* p_list_item 830219820Sjeff* [in] Pointer to cl_list_item_t structure to add. 831219820Sjeff* 832219820Sjeff* RETURN VALUE 833219820Sjeff* This function does not return a value. 834219820Sjeff* 835219820Sjeff* NOTES 836219820Sjeff* In debug builds, cl_qlist_insert_tail asserts that the specified list item 837219820Sjeff* is not already in the list. 838219820Sjeff* 839219820Sjeff* SEE ALSO 840219820Sjeff* Quick List, cl_qlist_insert_head, cl_qlist_insert_list_head, 841219820Sjeff* cl_qlist_insert_list_tail, cl_qlist_insert_array_head, 842219820Sjeff* cl_qlist_insert_array_tail, cl_qlist_insert_prev, cl_qlist_insert_next, 843219820Sjeff* cl_qlist_remove_tail, cl_list_item_t 844219820Sjeff*********/ 845219820Sjeff 846219820Sjeff/****f* Component Library: Quick List/cl_qlist_insert_list_head 847219820Sjeff* NAME 848219820Sjeff* cl_qlist_insert_list_head 849219820Sjeff* 850219820Sjeff* DESCRIPTION 851219820Sjeff* The cl_qlist_insert_list_head function merges two quick lists by 852219820Sjeff* inserting one at the head of the other. 853219820Sjeff* 854219820Sjeff* SYNOPSIS 855219820Sjeff*/ 856219820Sjeffvoid 857219820Sjeffcl_qlist_insert_list_head(IN cl_qlist_t * const p_dest_list, 858219820Sjeff IN cl_qlist_t * const p_src_list); 859219820Sjeff/* 860219820Sjeff* PARAMETERS 861219820Sjeff* p_dest_list 862219820Sjeff* [in] Pointer to destination quicklist object. 863219820Sjeff* 864219820Sjeff* p_src_list 865219820Sjeff* [in] Pointer to quicklist to add. 866219820Sjeff* 867219820Sjeff* RETURN VALUE 868219820Sjeff* This function does not return a value. 869219820Sjeff* 870219820Sjeff* NOTES 871219820Sjeff* Inserts all list items in the source list to the head of the 872219820Sjeff* destination list. The ordering of the list items is preserved. 873219820Sjeff* 874219820Sjeff* The list pointed to by the p_src_list parameter is empty when 875219820Sjeff* the call returns. 876219820Sjeff* 877219820Sjeff* SEE ALSO 878219820Sjeff* Quick List, cl_qlist_insert_list_tail, cl_qlist_insert_head, 879219820Sjeff* cl_qlist_insert_tail, cl_qlist_insert_array_head, 880219820Sjeff* cl_qlist_insert_array_tail, cl_qlist_insert_prev, cl_qlist_insert_next, 881219820Sjeff* cl_list_item_t 882219820Sjeff*********/ 883219820Sjeff 884219820Sjeff/****f* Component Library: Quick List/cl_qlist_insert_list_tail 885219820Sjeff* NAME 886219820Sjeff* cl_qlist_insert_list_tail 887219820Sjeff* 888219820Sjeff* DESCRIPTION 889219820Sjeff* The cl_qlist_insert_list_tail function merges two quick lists by 890219820Sjeff* inserting one at the tail of the other. 891219820Sjeff* 892219820Sjeff* SYNOPSIS 893219820Sjeff*/ 894219820Sjeffvoid 895219820Sjeffcl_qlist_insert_list_tail(IN cl_qlist_t * const p_dest_list, 896219820Sjeff IN cl_qlist_t * const p_src_list); 897219820Sjeff/* 898219820Sjeff* PARAMETERS 899219820Sjeff* p_dest_list 900219820Sjeff* [in] Pointer to destination quicklist object 901219820Sjeff* 902219820Sjeff* p_src_list 903219820Sjeff* [in] Pointer to quicklist to add 904219820Sjeff* 905219820Sjeff* RETURN VALUE 906219820Sjeff* This function does not return a value. 907219820Sjeff* 908219820Sjeff* NOTES 909219820Sjeff* Inserts all list items in the source list to the tail of the 910219820Sjeff* destination list. The ordering of the list items is preserved. 911219820Sjeff* 912219820Sjeff* The list pointed to by the p_src_list parameter is empty when 913219820Sjeff* the call returns. 914219820Sjeff* 915219820Sjeff* SEE ALSO 916219820Sjeff* Quick List, cl_qlist_insert_list_head, cl_qlist_insert_head, 917219820Sjeff* cl_qlist_insert_tail, cl_qlist_insert_array_head, 918219820Sjeff* cl_qlist_insert_array_tail, cl_qlist_insert_prev, cl_qlist_insert_next, 919219820Sjeff* cl_list_item_t 920219820Sjeff*********/ 921219820Sjeff 922219820Sjeff/****f* Component Library: Quick List/cl_qlist_insert_array_head 923219820Sjeff* NAME 924219820Sjeff* cl_qlist_insert_array_head 925219820Sjeff* 926219820Sjeff* DESCRIPTION 927219820Sjeff* The cl_qlist_insert_array_head function inserts an array of list items 928219820Sjeff* at the head of a quick list. 929219820Sjeff* 930219820Sjeff* SYNOPSIS 931219820Sjeff*/ 932219820Sjeffvoid 933219820Sjeffcl_qlist_insert_array_head(IN cl_qlist_t * const p_list, 934219820Sjeff IN cl_list_item_t * const p_array, 935219820Sjeff IN uint32_t item_count, IN const uint32_t item_size); 936219820Sjeff/* 937219820Sjeff* PARAMETERS 938219820Sjeff* p_list 939219820Sjeff* [in] Pointer to a cl_qlist_t structure into which to insert 940219820Sjeff* the objects. 941219820Sjeff* 942219820Sjeff* p_array 943219820Sjeff* [in] Pointer to the first list item in an array of cl_list_item_t 944219820Sjeff* structures. 945219820Sjeff* 946219820Sjeff* item_count 947219820Sjeff* [in] Number of cl_list_item_t structures in the array. 948219820Sjeff* 949219820Sjeff* item_size 950219820Sjeff* [in] Size of the items added to the list. This is the stride in the 951219820Sjeff* array from one cl_list_item_t structure to the next. 952219820Sjeff* 953219820Sjeff* RETURN VALUE 954219820Sjeff* This function does not return a value. 955219820Sjeff* 956219820Sjeff* NOTES 957219820Sjeff* Inserts all the list items in the array specified by the p_array parameter 958219820Sjeff* to the head of the quick list specified by the p_list parameter, 959219820Sjeff* preserving ordering of the list items. 960219820Sjeff* 961219820Sjeff* The array pointer passed into the function points to the cl_list_item_t 962219820Sjeff* in the first element of the caller's element array. There is no 963219820Sjeff* restriction on where the element is stored in the parent structure. 964219820Sjeff* 965219820Sjeff* SEE ALSO 966219820Sjeff* Quick List, cl_qlist_insert_array_tail, cl_qlist_insert_head, 967219820Sjeff* cl_qlist_insert_tail, cl_qlist_insert_list_head, cl_qlist_insert_list_tail, 968219820Sjeff* cl_qlist_insert_prev, cl_qlist_insert_next, cl_list_item_t 969219820Sjeff*********/ 970219820Sjeff 971219820Sjeff/****f* Component Library: Quick List/cl_qlist_insert_array_tail 972219820Sjeff* NAME 973219820Sjeff* cl_qlist_insert_array_tail 974219820Sjeff* 975219820Sjeff* DESCRIPTION 976219820Sjeff* The cl_qlist_insert_array_tail function inserts an array of list items 977219820Sjeff* at the tail of a quick list. 978219820Sjeff* 979219820Sjeff* SYNOPSIS 980219820Sjeff*/ 981219820Sjeffvoid 982219820Sjeffcl_qlist_insert_array_tail(IN cl_qlist_t * const p_list, 983219820Sjeff IN cl_list_item_t * const p_array, 984219820Sjeff IN uint32_t item_count, IN const uint32_t item_size); 985219820Sjeff/* 986219820Sjeff* PARAMETERS 987219820Sjeff* p_list 988219820Sjeff* [in] Pointer to a cl_qlist_t structure into which to insert 989219820Sjeff* the objects. 990219820Sjeff* 991219820Sjeff* p_array 992219820Sjeff* [in] Pointer to the first list item in an array of cl_list_item_t 993219820Sjeff* structures. 994219820Sjeff* 995219820Sjeff* item_count 996219820Sjeff* [in] Number of cl_list_item_t structures in the array. 997219820Sjeff* 998219820Sjeff* item_size 999219820Sjeff* [in] Size of the items added to the list. This is the stride in the 1000219820Sjeff* array from one cl_list_item_t structure to the next. 1001219820Sjeff* 1002219820Sjeff* RETURN VALUE 1003219820Sjeff* This function does not return a value. 1004219820Sjeff* 1005219820Sjeff* NOTES 1006219820Sjeff* Inserts all the list items in the array specified by the p_array parameter 1007219820Sjeff* to the tail of the quick list specified by the p_list parameter, 1008219820Sjeff* preserving ordering of the list items. 1009219820Sjeff* 1010219820Sjeff* The array pointer passed into the function points to the cl_list_item_t 1011219820Sjeff* in the first element of the caller's element array. There is no 1012219820Sjeff* restriction on where the element is stored in the parent structure. 1013219820Sjeff* 1014219820Sjeff* SEE ALSO 1015219820Sjeff* Quick List, cl_qlist_insert_array_head, cl_qlist_insert_head, 1016219820Sjeff* cl_qlist_insert_tail, cl_qlist_insert_list_head, cl_qlist_insert_list_tail, 1017219820Sjeff* cl_qlist_insert_prev, cl_qlist_insert_next, cl_list_item_t 1018219820Sjeff*********/ 1019219820Sjeff 1020219820Sjeff/****f* Component Library: Quick List/cl_qlist_insert_prev 1021219820Sjeff* NAME 1022219820Sjeff* cl_qlist_insert_prev 1023219820Sjeff* 1024219820Sjeff* DESCRIPTION 1025219820Sjeff* The cl_qlist_insert_prev function inserts a list item before a 1026219820Sjeff* specified list item in a quick list. 1027219820Sjeff* 1028219820Sjeff* SYNOPSIS 1029219820Sjeff*/ 1030219820Sjeffstatic inline void 1031219820Sjeffcl_qlist_insert_prev(IN cl_qlist_t * const p_list, 1032219820Sjeff IN cl_list_item_t * const p_list_item, 1033219820Sjeff IN cl_list_item_t * const p_new_item) 1034219820Sjeff{ 1035219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1036219820Sjeff CL_ASSERT(p_list); 1037219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1038219820Sjeff CL_ASSERT(p_list_item); 1039219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1040219820Sjeff CL_ASSERT(p_new_item); 1041219820Sjeff /* CL_ASSERT that the list was initialized. */ 1042219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 1043219820Sjeff 1044219820Sjeff /* 1045219820Sjeff * The list item must not already be part of the list. Note that this 1046219820Sjeff * assertion may fail if an uninitialized list item happens to have its 1047219820Sjeff * list pointer equal to the specified list. The chances of this 1048219820Sjeff * happening are acceptable in light of the value of this check. 1049219820Sjeff */ 1050219820Sjeff CL_ASSERT(p_new_item->p_list != p_list); 1051219820Sjeff 1052219820Sjeff#if defined( _DEBUG_ ) 1053219820Sjeff p_new_item->p_list = p_list; 1054219820Sjeff#endif 1055219820Sjeff 1056219820Sjeff __cl_primitive_insert(p_list_item, p_new_item); 1057219820Sjeff 1058219820Sjeff p_list->count++; 1059219820Sjeff} 1060219820Sjeff 1061219820Sjeff/* 1062219820Sjeff* PARAMETERS 1063219820Sjeff* p_list 1064219820Sjeff* [in] Pointer to a cl_qlist_t structure into which to add the new item. 1065219820Sjeff* 1066219820Sjeff* p_list_item 1067219820Sjeff* [in] Pointer to a cl_list_item_t structure. 1068219820Sjeff* 1069219820Sjeff* p_new_item 1070219820Sjeff* [in] Pointer to a cl_list_item_t structure to add to the quick list. 1071219820Sjeff* 1072219820Sjeff* RETURN VALUE 1073219820Sjeff* This function does not return a value. 1074219820Sjeff* 1075219820Sjeff* NOTES 1076219820Sjeff* Inserts the new list item before the list item specified by p_list_item. 1077219820Sjeff* 1078219820Sjeff* SEE ALSO 1079219820Sjeff* Quick List, cl_qlist_insert_next, cl_qlist_insert_head, 1080219820Sjeff* cl_qlist_insert_tail, cl_qlist_insert_list_head, cl_qlist_insert_list_tail, 1081219820Sjeff* cl_qlist_insert_array_head, cl_qlist_insert_array_tail, cl_list_item_t 1082219820Sjeff*********/ 1083219820Sjeff 1084219820Sjeff/****f* Component Library: Quick List/cl_qlist_insert_next 1085219820Sjeff* NAME 1086219820Sjeff* cl_qlist_insert_next 1087219820Sjeff* 1088219820Sjeff* DESCRIPTION 1089219820Sjeff* The cl_qlist_insert_next function inserts a list item after a specified 1090219820Sjeff* list item in a quick list. 1091219820Sjeff* 1092219820Sjeff* SYNOPSIS 1093219820Sjeff*/ 1094219820Sjeffstatic inline void 1095219820Sjeffcl_qlist_insert_next(IN cl_qlist_t * const p_list, 1096219820Sjeff IN cl_list_item_t * const p_list_item, 1097219820Sjeff IN cl_list_item_t * const p_new_item) 1098219820Sjeff{ 1099219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1100219820Sjeff CL_ASSERT(p_list); 1101219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1102219820Sjeff CL_ASSERT(p_list_item); 1103219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1104219820Sjeff CL_ASSERT(p_new_item); 1105219820Sjeff /* CL_ASSERT that the list was initialized. */ 1106219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 1107219820Sjeff 1108219820Sjeff /* 1109219820Sjeff * The list item must not already be part of the list. Note that this 1110219820Sjeff * assertion may fail if an uninitialized list item happens to have its 1111219820Sjeff * list pointer equal to the specified list. The chances of this 1112219820Sjeff * happening are acceptable in light of the value of this check. 1113219820Sjeff */ 1114219820Sjeff CL_ASSERT(p_new_item->p_list != p_list); 1115219820Sjeff 1116219820Sjeff#if defined( _DEBUG_ ) 1117219820Sjeff p_new_item->p_list = p_list; 1118219820Sjeff#endif 1119219820Sjeff 1120219820Sjeff __cl_primitive_insert(cl_qlist_next(p_list_item), p_new_item); 1121219820Sjeff 1122219820Sjeff p_list->count++; 1123219820Sjeff} 1124219820Sjeff 1125219820Sjeff/* 1126219820Sjeff* PARAMETERS 1127219820Sjeff* p_list 1128219820Sjeff* [in] Pointer to a cl_qlist_t structure into which to add the new item. 1129219820Sjeff* 1130219820Sjeff* p_list_item 1131219820Sjeff* [in] Pointer to a cl_list_item_t structure. 1132219820Sjeff* 1133219820Sjeff* p_new_item 1134219820Sjeff* [in] Pointer to a cl_list_item_t structure to add to the quick list. 1135219820Sjeff* 1136219820Sjeff* RETURN VALUE 1137219820Sjeff* This function does not return a value. 1138219820Sjeff* 1139219820Sjeff* NOTES 1140219820Sjeff* Inserts the new list item after the list item specified by p_list_item. 1141219820Sjeff* The list item specified by p_list_item must be in the quick list. 1142219820Sjeff* 1143219820Sjeff* SEE ALSO 1144219820Sjeff* Quick List, cl_qlist_insert_prev, cl_qlist_insert_head, 1145219820Sjeff* cl_qlist_insert_tail, cl_qlist_insert_list_head, cl_qlist_insert_list_tail, 1146219820Sjeff* cl_qlist_insert_array_head, cl_qlist_insert_array_tail, cl_list_item_t 1147219820Sjeff*********/ 1148219820Sjeff 1149219820Sjeff/****f* Component Library: Quick List/cl_qlist_remove_head 1150219820Sjeff* NAME 1151219820Sjeff* cl_qlist_remove_head 1152219820Sjeff* 1153219820Sjeff* DESCRIPTION 1154219820Sjeff* The cl_qlist_remove_head function removes and returns the list item 1155219820Sjeff* at the head of a quick list. 1156219820Sjeff* 1157219820Sjeff* SYNOPSIS 1158219820Sjeff*/ 1159219820Sjeffstatic inline cl_list_item_t *cl_qlist_remove_head(IN cl_qlist_t * const p_list) 1160219820Sjeff{ 1161219820Sjeff cl_list_item_t *p_item; 1162219820Sjeff 1163219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1164219820Sjeff CL_ASSERT(p_list); 1165219820Sjeff /* CL_ASSERT that the list was initialized. */ 1166219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 1167219820Sjeff 1168219820Sjeff p_item = cl_qlist_head(p_list); 1169219820Sjeff /* CL_ASSERT that the list item is part of the list. */ 1170219820Sjeff CL_ASSERT(p_item->p_list == p_list); 1171219820Sjeff 1172219820Sjeff if (p_item == cl_qlist_end(p_list)) 1173219820Sjeff return (p_item); 1174219820Sjeff 1175219820Sjeff#if defined( _DEBUG_ ) 1176219820Sjeff /* Clear the item's link to the list. */ 1177219820Sjeff p_item->p_list = NULL; 1178219820Sjeff#endif 1179219820Sjeff 1180219820Sjeff __cl_primitive_remove(p_item); 1181219820Sjeff 1182219820Sjeff p_list->count--; 1183219820Sjeff 1184219820Sjeff return (p_item); 1185219820Sjeff} 1186219820Sjeff 1187219820Sjeff/* 1188219820Sjeff* PARAMETERS 1189219820Sjeff* p_list 1190219820Sjeff* [in] Pointer to a cl_qlist_t structure. 1191219820Sjeff* 1192219820Sjeff* RETURN VALUES 1193219820Sjeff* Returns a pointer to the list item formerly at the head of the quick list. 1194219820Sjeff* 1195219820Sjeff* Pointer to the list end if the list was empty. 1196219820Sjeff* 1197219820Sjeff* SEE ALSO 1198219820Sjeff* Quick List, cl_qlist_remove_tail, cl_qlist_remove_all, cl_qlist_remove_item, 1199219820Sjeff* cl_qlist_end, cl_qlist_head, cl_list_item_t 1200219820Sjeff*********/ 1201219820Sjeff 1202219820Sjeff/****f* Component Library: Quick List/cl_qlist_remove_tail 1203219820Sjeff* NAME 1204219820Sjeff* cl_qlist_remove_tail 1205219820Sjeff* 1206219820Sjeff* DESCRIPTION 1207219820Sjeff* The cl_qlist_remove_tail function removes and returns the list item 1208219820Sjeff* at the tail of a quick list. 1209219820Sjeff* 1210219820Sjeff* SYNOPSIS 1211219820Sjeff*/ 1212219820Sjeffstatic inline cl_list_item_t *cl_qlist_remove_tail(IN cl_qlist_t * const p_list) 1213219820Sjeff{ 1214219820Sjeff cl_list_item_t *p_item; 1215219820Sjeff 1216219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1217219820Sjeff CL_ASSERT(p_list); 1218219820Sjeff /* CL_ASSERT that the list was initialized. */ 1219219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 1220219820Sjeff 1221219820Sjeff p_item = cl_qlist_tail(p_list); 1222219820Sjeff /* CL_ASSERT that the list item is part of the list. */ 1223219820Sjeff CL_ASSERT(p_item->p_list == p_list); 1224219820Sjeff 1225219820Sjeff if (p_item == cl_qlist_end(p_list)) 1226219820Sjeff return (p_item); 1227219820Sjeff 1228219820Sjeff#if defined( _DEBUG_ ) 1229219820Sjeff /* Clear the item's link to the list. */ 1230219820Sjeff p_item->p_list = NULL; 1231219820Sjeff#endif 1232219820Sjeff 1233219820Sjeff __cl_primitive_remove(p_item); 1234219820Sjeff 1235219820Sjeff p_list->count--; 1236219820Sjeff 1237219820Sjeff return (p_item); 1238219820Sjeff} 1239219820Sjeff 1240219820Sjeff/* 1241219820Sjeff* PARAMETERS 1242219820Sjeff* p_list 1243219820Sjeff* [in] Pointer to a cl_qlist_t structure. 1244219820Sjeff* 1245219820Sjeff* RETURN VALUES 1246219820Sjeff* Returns a pointer to the list item formerly at the tail of the quick list. 1247219820Sjeff* 1248219820Sjeff* Pointer to the list end if the list was empty. 1249219820Sjeff* 1250219820Sjeff* SEE ALSO 1251219820Sjeff* Quick List, cl_qlist_remove_head, cl_qlist_remove_all, cl_qlist_remove_item, 1252219820Sjeff* cl_qlist_end, cl_qlist_tail, cl_list_item_t 1253219820Sjeff*********/ 1254219820Sjeff 1255219820Sjeff/****f* Component Library: Quick List/cl_qlist_remove_item 1256219820Sjeff* NAME 1257219820Sjeff* cl_qlist_remove_item 1258219820Sjeff* 1259219820Sjeff* DESCRIPTION 1260219820Sjeff* The cl_qlist_remove_item function removes a specific list item from a quick list. 1261219820Sjeff* 1262219820Sjeff* SYNOPSIS 1263219820Sjeff*/ 1264219820Sjeffstatic inline void 1265219820Sjeffcl_qlist_remove_item(IN cl_qlist_t * const p_list, 1266219820Sjeff IN cl_list_item_t * const p_list_item) 1267219820Sjeff{ 1268219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1269219820Sjeff CL_ASSERT(p_list); 1270219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1271219820Sjeff CL_ASSERT(p_list_item); 1272219820Sjeff /* CL_ASSERT that the list was initialized. */ 1273219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 1274219820Sjeff /* CL_ASSERT that the list item is part of the list. */ 1275219820Sjeff CL_ASSERT(p_list_item->p_list == p_list); 1276219820Sjeff 1277219820Sjeff if (p_list_item == cl_qlist_end(p_list)) 1278219820Sjeff return; 1279219820Sjeff 1280219820Sjeff#if defined( _DEBUG_ ) 1281219820Sjeff /* Clear the item's link to the list. */ 1282219820Sjeff p_list_item->p_list = NULL; 1283219820Sjeff#endif 1284219820Sjeff 1285219820Sjeff __cl_primitive_remove(p_list_item); 1286219820Sjeff 1287219820Sjeff p_list->count--; 1288219820Sjeff} 1289219820Sjeff 1290219820Sjeff/* 1291219820Sjeff* PARAMETERS 1292219820Sjeff* p_list 1293219820Sjeff* [in] Pointer to a cl_qlist_t structure from which to remove the item. 1294219820Sjeff* 1295219820Sjeff* p_list_item 1296219820Sjeff* [in] Pointer to a cl_list_item_t structure to remove. 1297219820Sjeff* 1298219820Sjeff* RETURN VALUE 1299219820Sjeff* This function does not return a value. 1300219820Sjeff* 1301219820Sjeff* NOTES 1302219820Sjeff* Removes the list item pointed to by the p_list_item parameter from 1303219820Sjeff* its list. 1304219820Sjeff* 1305219820Sjeff* SEE ALSO 1306219820Sjeff* Quick List, cl_qlist_remove_head, cl_qlist_remove_tail, cl_qlist_remove_all, 1307219820Sjeff* cl_list_item_t 1308219820Sjeff*********/ 1309219820Sjeff 1310219820Sjeff/****f* Component Library: Quick List/cl_qlist_remove_all 1311219820Sjeff* NAME 1312219820Sjeff* cl_qlist_remove_all 1313219820Sjeff* 1314219820Sjeff* DESCRIPTION 1315219820Sjeff* The cl_qlist_remove_all function removes all items from a quick list. 1316219820Sjeff* 1317219820Sjeff* SYNOPSIS 1318219820Sjeff*/ 1319219820Sjeffstatic inline void cl_qlist_remove_all(IN cl_qlist_t * const p_list) 1320219820Sjeff{ 1321219820Sjeff#if defined( _DEBUG_ ) 1322219820Sjeff cl_list_item_t *p_list_item; 1323219820Sjeff 1324219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1325219820Sjeff CL_ASSERT(p_list); 1326219820Sjeff /* CL_ASSERT that the list was initialized. */ 1327219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 1328219820Sjeff p_list_item = cl_qlist_head(p_list); 1329219820Sjeff while (p_list_item != cl_qlist_end(p_list)) { 1330219820Sjeff p_list_item = cl_qlist_next(p_list_item); 1331219820Sjeff cl_qlist_prev(p_list_item)->p_list = NULL; 1332219820Sjeff } 1333219820Sjeff#endif 1334219820Sjeff 1335219820Sjeff __cl_qlist_reset(p_list); 1336219820Sjeff} 1337219820Sjeff 1338219820Sjeff/* 1339219820Sjeff* PARAMETERS 1340219820Sjeff* p_list 1341219820Sjeff* [in] Pointer to a cl_qlist_t structure. 1342219820Sjeff* 1343219820Sjeff* RETURN VALUE 1344219820Sjeff* This function does not return a value. 1345219820Sjeff* 1346219820Sjeff* SEE ALSO 1347219820Sjeff* Quick List, cl_qlist_remove_head, cl_qlist_remove_tail, 1348219820Sjeff* cl_qlist_remove_item, cl_list_item_t 1349219820Sjeff*********/ 1350219820Sjeff 1351219820Sjeff/****f* Component Library: Quick List/cl_is_item_in_qlist 1352219820Sjeff* NAME 1353219820Sjeff* cl_is_item_in_qlist 1354219820Sjeff* 1355219820Sjeff* DESCRIPTION 1356219820Sjeff* The cl_is_item_in_qlist function checks for the presence of a 1357219820Sjeff* list item in a quick list. 1358219820Sjeff* 1359219820Sjeff* SYNOPSIS 1360219820Sjeff*/ 1361219820Sjeffboolean_t 1362219820Sjeffcl_is_item_in_qlist(IN const cl_qlist_t * const p_list, 1363219820Sjeff IN const cl_list_item_t * const p_list_item); 1364219820Sjeff/* 1365219820Sjeff* PARAMETERS 1366219820Sjeff* p_list 1367219820Sjeff* [in] Pointer to a cl_qlist_t structure. 1368219820Sjeff* 1369219820Sjeff* p_list_item 1370219820Sjeff* [in] Pointer to the cl_list_item_t to find. 1371219820Sjeff* 1372219820Sjeff* RETURN VALUES 1373219820Sjeff* TRUE if the list item was found in the quick list. 1374219820Sjeff* 1375219820Sjeff* FALSE otherwise. 1376219820Sjeff* 1377219820Sjeff* SEE ALSO 1378219820Sjeff* Quick List, cl_qlist_remove_item, cl_list_item_t 1379219820Sjeff*********/ 1380219820Sjeff 1381219820Sjeff/****f* Component Library: Quick List/cl_qlist_find_next 1382219820Sjeff* NAME 1383219820Sjeff* cl_qlist_find_next 1384219820Sjeff* 1385219820Sjeff* DESCRIPTION 1386219820Sjeff* The cl_qlist_find_next function invokes a specified function to 1387219820Sjeff* search for an item, starting from a given list item. 1388219820Sjeff* 1389219820Sjeff* SYNOPSIS 1390219820Sjeff*/ 1391219820Sjeffcl_list_item_t *cl_qlist_find_next(IN const cl_qlist_t * const p_list, 1392219820Sjeff IN const cl_list_item_t * const p_list_item, 1393219820Sjeff IN cl_pfn_qlist_find_t pfn_func, 1394219820Sjeff IN const void *const context); 1395219820Sjeff/* 1396219820Sjeff* PARAMETERS 1397219820Sjeff* p_list 1398219820Sjeff* [in] Pointer to a cl_qlist_t structure in which to search. 1399219820Sjeff* 1400219820Sjeff* p_list_item 1401219820Sjeff* [in] Pointer to a cl_list_item_t structure from which to start the search. 1402219820Sjeff* 1403219820Sjeff* pfn_func 1404219820Sjeff* [in] Function invoked to determine if a match was found. 1405219820Sjeff* See the cl_pfn_qlist_find_t function type declaration for details 1406219820Sjeff* about the callback function. 1407219820Sjeff* 1408219820Sjeff* context 1409219820Sjeff* [in] Value to pass to the callback functions to provide context if a 1410219820Sjeff* callback function is provided, or value compared to the quick list's 1411219820Sjeff* list items. 1412219820Sjeff* 1413219820Sjeff* Returns: 1414219820Sjeff* Pointer to the list item, if found. 1415219820Sjeff* 1416219820Sjeff* p_list_item if not found. 1417219820Sjeff* 1418219820Sjeff* NOTES 1419219820Sjeff* cl_qlist_find_next does not remove list items from the list. 1420219820Sjeff* The list item is returned when the function specified by the pfn_func 1421219820Sjeff* parameter returns CL_SUCCESS. The list item from which the search starts is 1422219820Sjeff* excluded from the search. 1423219820Sjeff* 1424219820Sjeff* The function provided by the pfn_func must not perform any list operations, 1425219820Sjeff* as these would corrupt the list. 1426219820Sjeff* 1427219820Sjeff* SEE ALSO 1428219820Sjeff* Quick List, cl_qlist_find_prev, cl_qlist_find_from_head, 1429219820Sjeff* cl_qlist_find_from_tail, cl_qlist_end, cl_qlist_apply_func, 1430219820Sjeff* cl_qlist_move_items, cl_list_item_t, cl_pfn_qlist_find_t 1431219820Sjeff*********/ 1432219820Sjeff 1433219820Sjeff/****f* Component Library: Quick List/cl_qlist_find_prev 1434219820Sjeff* NAME 1435219820Sjeff* cl_qlist_find_prev 1436219820Sjeff* 1437219820Sjeff* DESCRIPTION 1438219820Sjeff* The cl_qlist_find_prev function invokes a specified function to 1439219820Sjeff* search backward for an item, starting from a given list item. 1440219820Sjeff* 1441219820Sjeff* SYNOPSIS 1442219820Sjeff*/ 1443219820Sjeffcl_list_item_t *cl_qlist_find_prev(IN const cl_qlist_t * const p_list, 1444219820Sjeff IN const cl_list_item_t * const p_list_item, 1445219820Sjeff IN cl_pfn_qlist_find_t pfn_func, 1446219820Sjeff IN const void *const context); 1447219820Sjeff/* 1448219820Sjeff* PARAMETERS 1449219820Sjeff* p_list 1450219820Sjeff* [in] Pointer to a cl_qlist_t structure in which to search. 1451219820Sjeff* 1452219820Sjeff* p_list_item 1453219820Sjeff* [in] Pointer to a cl_list_item_t structure from which to start the search. 1454219820Sjeff* 1455219820Sjeff* pfn_func 1456219820Sjeff* [in] Function invoked to determine if a match was found. 1457219820Sjeff* See the cl_pfn_qlist_find_t function type declaration for details 1458219820Sjeff* about the callback function. 1459219820Sjeff* 1460219820Sjeff* context 1461219820Sjeff* [in] Value to pass to the callback functions to provide context if a 1462219820Sjeff* callback function is provided, or value compared to the quick list's 1463219820Sjeff* list items. 1464219820Sjeff* 1465219820Sjeff* Returns: 1466219820Sjeff* Pointer to the list item, if found. 1467219820Sjeff* 1468219820Sjeff* p_list_item if not found. 1469219820Sjeff* 1470219820Sjeff* NOTES 1471219820Sjeff* cl_qlist_find_prev does not remove list items from the list. 1472219820Sjeff* The list item is returned when the function specified by the pfn_func 1473219820Sjeff* parameter returns CL_SUCCESS. The list item from which the search starts is 1474219820Sjeff* excluded from the search. 1475219820Sjeff* 1476219820Sjeff* The function provided by the pfn_func must not perform any list operations, 1477219820Sjeff* as these would corrupt the list. 1478219820Sjeff* 1479219820Sjeff* SEE ALSO 1480219820Sjeff* Quick List, cl_qlist_find_next, cl_qlist_find_from_head, 1481219820Sjeff* cl_qlist_find_from_tail, cl_qlist_end, cl_qlist_apply_func, 1482219820Sjeff* cl_qlist_move_items, cl_list_item_t, cl_pfn_qlist_find_t 1483219820Sjeff*********/ 1484219820Sjeff 1485219820Sjeff/****f* Component Library: Quick List/cl_qlist_find_from_head 1486219820Sjeff* NAME 1487219820Sjeff* cl_qlist_find_from_head 1488219820Sjeff* 1489219820Sjeff* DESCRIPTION 1490219820Sjeff* The cl_qlist_find_from_head function invokes a specified function to 1491219820Sjeff* search for an item, starting at the head of a quick list. 1492219820Sjeff* 1493219820Sjeff* SYNOPSIS 1494219820Sjeff*/ 1495219820Sjeffstatic inline cl_list_item_t *cl_qlist_find_from_head(IN const cl_qlist_t * 1496219820Sjeff const p_list, 1497219820Sjeff IN cl_pfn_qlist_find_t 1498219820Sjeff pfn_func, 1499219820Sjeff IN const void *const 1500219820Sjeff context) 1501219820Sjeff{ 1502219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1503219820Sjeff CL_ASSERT(p_list); 1504219820Sjeff /* CL_ASSERT that the list was initialized. */ 1505219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 1506219820Sjeff /* CL_ASSERT that a find function is provided. */ 1507219820Sjeff CL_ASSERT(pfn_func); 1508219820Sjeff 1509219820Sjeff return (cl_qlist_find_next(p_list, cl_qlist_end(p_list), pfn_func, 1510219820Sjeff context)); 1511219820Sjeff} 1512219820Sjeff 1513219820Sjeff/* 1514219820Sjeff* PARAMETERS 1515219820Sjeff* p_list 1516219820Sjeff* [in] Pointer to a cl_qlist_t structure. 1517219820Sjeff* 1518219820Sjeff* pfn_func 1519219820Sjeff* [in] Function invoked to determine if a match was found. 1520219820Sjeff* See the cl_pfn_qlist_find_t function type declaration for details 1521219820Sjeff* about the callback function. 1522219820Sjeff* 1523219820Sjeff* context 1524219820Sjeff* [in] Value to pass to the callback functions to provide context if a 1525219820Sjeff* callback function is provided, or value compared to the quick list's 1526219820Sjeff* list items. 1527219820Sjeff* 1528219820Sjeff* Returns: 1529219820Sjeff* Pointer to the list item, if found. 1530219820Sjeff* 1531219820Sjeff* Pointer to the list end otherwise 1532219820Sjeff* 1533219820Sjeff* NOTES 1534219820Sjeff* cl_qlist_find_from_head does not remove list items from the list. 1535219820Sjeff* The list item is returned when the function specified by the pfn_func 1536219820Sjeff* parameter returns CL_SUCCESS. 1537219820Sjeff* 1538219820Sjeff* The function provided by the pfn_func parameter must not perform any list 1539219820Sjeff* operations, as these would corrupt the list. 1540219820Sjeff* 1541219820Sjeff* SEE ALSO 1542219820Sjeff* Quick List, cl_qlist_find_from_tail, cl_qlist_find_next, cl_qlist_find_prev, 1543219820Sjeff* cl_qlist_end, cl_qlist_apply_func, cl_qlist_move_items, cl_list_item_t, 1544219820Sjeff* cl_pfn_qlist_find_t 1545219820Sjeff*********/ 1546219820Sjeff 1547219820Sjeff/****f* Component Library: Quick List/cl_qlist_find_from_tail 1548219820Sjeff* NAME 1549219820Sjeff* cl_qlist_find_from_tail 1550219820Sjeff* 1551219820Sjeff* DESCRIPTION 1552219820Sjeff* The cl_qlist_find_from_tail function invokes a specified function to 1553219820Sjeff* search for an item, starting at the tail of a quick list. 1554219820Sjeff* 1555219820Sjeff* SYNOPSIS 1556219820Sjeff*/ 1557219820Sjeffstatic inline cl_list_item_t *cl_qlist_find_from_tail(IN const cl_qlist_t * 1558219820Sjeff const p_list, 1559219820Sjeff IN cl_pfn_qlist_find_t 1560219820Sjeff pfn_func, 1561219820Sjeff IN const void *const 1562219820Sjeff context) 1563219820Sjeff{ 1564219820Sjeff /* CL_ASSERT that a non-null pointer is provided. */ 1565219820Sjeff CL_ASSERT(p_list); 1566219820Sjeff /* CL_ASSERT that the list was initialized. */ 1567219820Sjeff CL_ASSERT(p_list->state == CL_INITIALIZED); 1568219820Sjeff /* CL_ASSERT that a find function is provided. */ 1569219820Sjeff CL_ASSERT(pfn_func); 1570219820Sjeff 1571219820Sjeff return (cl_qlist_find_prev(p_list, cl_qlist_end(p_list), pfn_func, 1572219820Sjeff context)); 1573219820Sjeff} 1574219820Sjeff 1575219820Sjeff/* 1576219820Sjeff* PARAMETERS 1577219820Sjeff* p_list 1578219820Sjeff* [in] Pointer to a cl_qlist_t structure. 1579219820Sjeff* 1580219820Sjeff* pfn_func 1581219820Sjeff* [in] Function invoked to determine if a match was found. 1582219820Sjeff* See the cl_pfn_qlist_find_t function type declaration for details 1583219820Sjeff* about the callback function. 1584219820Sjeff* 1585219820Sjeff* context 1586219820Sjeff* [in] Value to pass to the callback functions to provide context if a 1587219820Sjeff* callback function is provided, or value compared to the quick list's 1588219820Sjeff* list items. 1589219820Sjeff* 1590219820Sjeff* Returns: 1591219820Sjeff* Pointer to the list item, if found. 1592219820Sjeff* 1593219820Sjeff* Pointer to the list end otherwise 1594219820Sjeff* 1595219820Sjeff* NOTES 1596219820Sjeff* cl_qlist_find_from_tail does not remove list items from the list. 1597219820Sjeff* The list item is returned when the function specified by the pfn_func 1598219820Sjeff* parameter returns CL_SUCCESS. 1599219820Sjeff* 1600219820Sjeff* The function provided by the pfn_func parameter must not perform any list 1601219820Sjeff* operations, as these would corrupt the list. 1602219820Sjeff* 1603219820Sjeff* SEE ALSO 1604219820Sjeff* Quick List, cl_qlist_find_from_head, cl_qlist_find_next, cl_qlist_find_prev, 1605219820Sjeff* cl_qlist_apply_func, cl_qlist_end, cl_qlist_move_items, cl_list_item_t, 1606219820Sjeff* cl_pfn_qlist_find_t 1607219820Sjeff*********/ 1608219820Sjeff 1609219820Sjeff/****f* Component Library: Quick List/cl_qlist_apply_func 1610219820Sjeff* NAME 1611219820Sjeff* cl_qlist_apply_func 1612219820Sjeff* 1613219820Sjeff* DESCRIPTION 1614219820Sjeff* The cl_qlist_apply_func function executes a specified function 1615219820Sjeff* for every list item stored in a quick list. 1616219820Sjeff* 1617219820Sjeff* SYNOPSIS 1618219820Sjeff*/ 1619219820Sjeffvoid 1620219820Sjeffcl_qlist_apply_func(IN const cl_qlist_t * const p_list, 1621219820Sjeff IN cl_pfn_qlist_apply_t pfn_func, 1622219820Sjeff IN const void *const context); 1623219820Sjeff/* 1624219820Sjeff* PARAMETERS 1625219820Sjeff* p_list 1626219820Sjeff* [in] Pointer to a cl_qlist_t structure. 1627219820Sjeff* 1628219820Sjeff* pfn_func 1629219820Sjeff* [in] Function invoked for every item in the quick list. 1630219820Sjeff* See the cl_pfn_qlist_apply_t function type declaration for details 1631219820Sjeff* about the callback function. 1632219820Sjeff* 1633219820Sjeff* context 1634219820Sjeff* [in] Value to pass to the callback functions to provide context. 1635219820Sjeff* 1636219820Sjeff* RETURN VALUE 1637219820Sjeff* This function does not return a value. 1638219820Sjeff* 1639219820Sjeff* NOTES 1640219820Sjeff* The function provided must not perform any list operations, as these 1641219820Sjeff* would corrupt the quick list. 1642219820Sjeff* 1643219820Sjeff* SEE ALSO 1644219820Sjeff* Quick List, cl_qlist_find_from_head, cl_qlist_find_from_tail, 1645219820Sjeff* cl_qlist_move_items, cl_pfn_qlist_apply_t 1646219820Sjeff*********/ 1647219820Sjeff 1648219820Sjeff/****f* Component Library: Quick List/cl_qlist_move_items 1649219820Sjeff* NAME 1650219820Sjeff* cl_qlist_move_items 1651219820Sjeff* 1652219820Sjeff* DESCRIPTION 1653219820Sjeff* The cl_qlist_move_items function moves list items from one list to 1654219820Sjeff* another based on the return value of a user supplied function. 1655219820Sjeff* 1656219820Sjeff* SYNOPSIS 1657219820Sjeff*/ 1658219820Sjeffvoid 1659219820Sjeffcl_qlist_move_items(IN cl_qlist_t * const p_src_list, 1660219820Sjeff IN cl_qlist_t * const p_dest_list, 1661219820Sjeff IN cl_pfn_qlist_find_t pfn_func, 1662219820Sjeff IN const void *const context); 1663219820Sjeff/* 1664219820Sjeff* PARAMETERS 1665219820Sjeff* p_src_list 1666219820Sjeff* [in] Pointer to a cl_qlist_t structure from which 1667219820Sjeff* list items are removed. 1668219820Sjeff* 1669219820Sjeff* p_dest_list 1670219820Sjeff* [in] Pointer to a cl_qlist_t structure to which the source 1671219820Sjeff* list items are added. 1672219820Sjeff* 1673219820Sjeff* pfn_func 1674219820Sjeff* [in] Function invoked to determine if a match was found. 1675219820Sjeff* See the cl_pfn_qlist_find_t function type declaration for details 1676219820Sjeff* about the callback function. 1677219820Sjeff* 1678219820Sjeff* context 1679219820Sjeff* [in] Value to pass to the callback functions to provide context. 1680219820Sjeff* 1681219820Sjeff* RETURN VALUE 1682219820Sjeff* This function does not return a value. 1683219820Sjeff* 1684219820Sjeff* NOTES 1685219820Sjeff* If the function specified by the pfn_func parameter returns CL_SUCCESS, 1686219820Sjeff* the related list item is removed from p_src_list and inserted at the tail 1687219820Sjeff* of the p_dest_list. 1688219820Sjeff* 1689219820Sjeff* The cl_qlist_move_items function continues iterating through p_src_list 1690219820Sjeff* from the last item moved, allowing multiple items to be located and moved 1691219820Sjeff* in a single list iteration. 1692219820Sjeff* 1693219820Sjeff* The function specified by pfn_func must not perform any list operations, 1694219820Sjeff* as these would corrupt the list. 1695219820Sjeff* 1696219820Sjeff* SEE ALSO 1697219820Sjeff* Quick List, cl_qlist_find_from_head, cl_qlist_find_from_tail, 1698219820Sjeff* cl_qlist_apply_func, cl_pfn_qlist_find_t 1699219820Sjeff*********/ 1700219820Sjeff 1701219820SjeffEND_C_DECLS 1702219820Sjeff#endif /* _CL_QUICK_LIST_H_ */ 1703