![]() |
|
|||
File indexing completed on 2025-05-11 08:24:13
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSAPIClassicChains 0007 * 0008 * @brief This header file provides the Chains API. 0009 */ 0010 0011 /* 0012 * Copyright (C) 2010, 2014 embedded brains GmbH & Co. KG 0013 * 0014 * COPYRIGHT (c) 1989-2008. 0015 * On-Line Applications Research Corporation (OAR). 0016 * 0017 * Redistribution and use in source and binary forms, with or without 0018 * modification, are permitted provided that the following conditions 0019 * are met: 0020 * 1. Redistributions of source code must retain the above copyright 0021 * notice, this list of conditions and the following disclaimer. 0022 * 2. Redistributions in binary form must reproduce the above copyright 0023 * notice, this list of conditions and the following disclaimer in the 0024 * documentation and/or other materials provided with the distribution. 0025 * 0026 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0027 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0028 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0029 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0030 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0031 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0032 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0033 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0034 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0035 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0036 * POSSIBILITY OF SUCH DAMAGE. 0037 */ 0038 0039 #ifndef _RTEMS_CHAIN_H 0040 #define _RTEMS_CHAIN_H 0041 0042 #include <rtems/score/chainimpl.h> 0043 #include <rtems/rtems/event.h> 0044 0045 #ifdef __cplusplus 0046 extern "C" { 0047 #endif 0048 0049 /** 0050 * @defgroup RTEMSAPIClassicChains Chains 0051 * 0052 * @ingroup RTEMSAPIClassic 0053 * 0054 * @brief The chain container provides data structures and directives to manage 0055 * user-defined data structures in doubly-linked lists. 0056 * 0057 * @{ 0058 */ 0059 0060 typedef Chain_Node rtems_chain_node; 0061 0062 typedef Chain_Control rtems_chain_control; 0063 0064 /** 0065 * @brief Chain initializer for an empty chain with designator @a name. 0066 */ 0067 #define RTEMS_CHAIN_INITIALIZER_EMPTY( name ) \ 0068 CHAIN_INITIALIZER_EMPTY( name ) 0069 0070 /** 0071 * @brief Chain initializer for a chain with one @a node. 0072 * 0073 * @see RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN(). 0074 */ 0075 #define RTEMS_CHAIN_INITIALIZER_ONE_NODE( node ) \ 0076 CHAIN_INITIALIZER_ONE_NODE( node ) 0077 0078 /** 0079 * @brief Chain node initializer for a @a chain containing exactly this node. 0080 * 0081 * @see RTEMS_CHAIN_INITIALIZER_ONE_NODE(). 0082 */ 0083 #define RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) \ 0084 CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) 0085 0086 /** 0087 * @brief Chain definition for an empty chain with designator @a name. 0088 */ 0089 #define RTEMS_CHAIN_DEFINE_EMPTY( name ) \ 0090 rtems_chain_control name = RTEMS_CHAIN_INITIALIZER_EMPTY( name ) 0091 0092 /** 0093 * @brief Appends the @a node to the @a chain and sends the @a events to the 0094 * @a task if the @a chain was empty before the append. 0095 * 0096 * @see rtems_chain_append_with_empty_check() and rtems_event_send(). 0097 * 0098 * @retval RTEMS_SUCCESSFUL Successful operation. 0099 * @retval RTEMS_INVALID_ID No such task. 0100 */ 0101 rtems_status_code rtems_chain_append_with_notification( 0102 rtems_chain_control *chain, 0103 rtems_chain_node *node, 0104 rtems_id task, 0105 rtems_event_set events 0106 ); 0107 0108 /** 0109 * @brief Prepends the @a node to the @a chain and sends the @a events to the 0110 * @a task if the @a chain was empty before the prepend. 0111 * 0112 * @see rtems_chain_prepend_with_empty_check() and rtems_event_send(). 0113 * 0114 * @retval RTEMS_SUCCESSFUL Successful operation. 0115 * @retval RTEMS_INVALID_ID No such task. 0116 */ 0117 rtems_status_code rtems_chain_prepend_with_notification( 0118 rtems_chain_control *chain, 0119 rtems_chain_node *node, 0120 rtems_id task, 0121 rtems_event_set events 0122 ); 0123 0124 /** 0125 * @brief Gets the first @a node of the @a chain and sends the @a events to the 0126 * @a task if the @a chain is empty after the get. 0127 * 0128 * @see rtems_chain_get_with_empty_check() and rtems_event_send(). 0129 * 0130 * @retval RTEMS_SUCCESSFUL Successful operation. 0131 * @retval RTEMS_INVALID_ID No such task. 0132 */ 0133 rtems_status_code rtems_chain_get_with_notification( 0134 rtems_chain_control *chain, 0135 rtems_id task, 0136 rtems_event_set events, 0137 rtems_chain_node **node 0138 ); 0139 0140 /** 0141 * @brief Gets the first @a node of the @a chain and sends the @a events to the 0142 * @a task if the @a chain is empty afterwards. 0143 * 0144 * @see rtems_chain_get() and rtems_event_receive(). 0145 * 0146 * @retval RTEMS_SUCCESSFUL Successful operation. 0147 * @retval RTEMS_TIMEOUT Timeout. 0148 */ 0149 rtems_status_code rtems_chain_get_with_wait( 0150 rtems_chain_control *chain, 0151 rtems_event_set events, 0152 rtems_interval timeout, 0153 rtems_chain_node **node 0154 ); 0155 0156 /** 0157 * @brief Initialize a chain Header. 0158 * 0159 * This routine initializes @a the_chain structure to manage the 0160 * contiguous array of @a number_nodes nodes which starts at 0161 * @a starting_address. Each node is of @a node_size bytes. 0162 * 0163 * @param[in] the_chain specifies the chain to initialize 0164 * @param[in] starting_address is the starting address of the array 0165 * of elements 0166 * @param[in] number_nodes is the number of nodes that will be in the chain 0167 * @param[in] node_size is the size of each node 0168 */ 0169 static inline void rtems_chain_initialize( 0170 rtems_chain_control *the_chain, 0171 void *starting_address, 0172 size_t number_nodes, 0173 size_t node_size 0174 ) 0175 { 0176 _Chain_Initialize( 0177 the_chain, 0178 starting_address, 0179 number_nodes, 0180 node_size 0181 ); 0182 } 0183 0184 /** 0185 * @brief Initialize this chain as empty. 0186 * 0187 * This routine initializes the specified chain to contain zero nodes. 0188 * 0189 * @param[in] the_chain is the chain to be initialized. 0190 */ 0191 static inline void rtems_chain_initialize_empty( 0192 rtems_chain_control *the_chain 0193 ) 0194 { 0195 _Chain_Initialize_empty( the_chain ); 0196 } 0197 0198 /** 0199 * @brief Set off chain. 0200 * 0201 * This function sets the next and previous fields of the @a node to NULL 0202 * indicating the @a node is not part of a chain. 0203 * 0204 * @param[in] node the node set to off chain. 0205 */ 0206 static inline void rtems_chain_set_off_chain( 0207 rtems_chain_node *node 0208 ) 0209 { 0210 _Chain_Set_off_chain( node ); 0211 } 0212 0213 /** 0214 * @brief Initializes a chain node. 0215 * 0216 * In debug configurations, the node is set off chain. In all other 0217 * configurations, this function does nothing. 0218 * 0219 * @param[in] the_node The chain node to initialize. 0220 */ 0221 static inline void rtems_chain_initialize_node( 0222 rtems_chain_node *node 0223 ) 0224 { 0225 _Chain_Initialize_node( node ); 0226 } 0227 0228 /** 0229 * @brief Is the node off chain. 0230 * 0231 * This function returns true if the @a node is not on a chain. A @a node is 0232 * off chain if the next and previous fields are set to NULL. 0233 * 0234 * @param[in] node is the node off chain. 0235 * 0236 * @retval true The node is off chain. 0237 * @retval false The node is not off chain. 0238 */ 0239 static inline bool rtems_chain_is_node_off_chain( 0240 const rtems_chain_node *node 0241 ) 0242 { 0243 return _Chain_Is_node_off_chain( node ); 0244 } 0245 0246 /** 0247 * @brief Is the chain node pointer NULL. 0248 * 0249 * This function returns true if the_node is NULL and false otherwise. 0250 * 0251 * @param[in] the_node is the node pointer to check. 0252 * 0253 * @retval true The chain node pointer is NULL. 0254 * @retval false The chain node pointer is not NULL. 0255 */ 0256 static inline bool rtems_chain_is_null_node( 0257 const rtems_chain_node *the_node 0258 ) 0259 { 0260 return the_node == NULL; 0261 } 0262 0263 /** 0264 * @brief Return pointer to Chain Head 0265 * 0266 * This function returns a pointer to the first node on the chain. 0267 * 0268 * @param[in] the_chain is the chain to be operated upon. 0269 * 0270 * @return This method returns the permanent node of the chain. 0271 */ 0272 static inline rtems_chain_node *rtems_chain_head( 0273 rtems_chain_control *the_chain 0274 ) 0275 { 0276 return _Chain_Head( the_chain ); 0277 } 0278 0279 /** 0280 * @brief Return pointer to immutable Chain Head 0281 * 0282 * This function returns a pointer to the head node on the chain. 0283 * 0284 * @param[in] the_chain is the chain to be operated upon. 0285 * 0286 * @return This method returns the permanent head node of the chain. 0287 */ 0288 static inline const rtems_chain_node *rtems_chain_immutable_head( 0289 const rtems_chain_control *the_chain 0290 ) 0291 { 0292 return _Chain_Immutable_head( the_chain ); 0293 } 0294 0295 /** 0296 * @brief Return pointer to Chain Tail 0297 * 0298 * This function returns a pointer to the tail node on the chain. 0299 * 0300 * @param[in] the_chain is the chain to be operated upon. 0301 * 0302 * @return This method returns the permanent tail node of the chain. 0303 */ 0304 static inline rtems_chain_node *rtems_chain_tail( 0305 rtems_chain_control *the_chain 0306 ) 0307 { 0308 return _Chain_Tail( the_chain ); 0309 } 0310 0311 /** 0312 * @brief Return pointer to immutable Chain Tail 0313 * 0314 * This function returns a pointer to the tail node on the chain. 0315 * 0316 * @param[in] the_chain is the chain to be operated upon. 0317 * 0318 * @return This method returns the permanent tail node of the chain. 0319 */ 0320 static inline const rtems_chain_node *rtems_chain_immutable_tail( 0321 const rtems_chain_control *the_chain 0322 ) 0323 { 0324 return _Chain_Immutable_tail( the_chain ); 0325 } 0326 0327 /** 0328 * @brief Return pointer to Chain's First node after the permanent head. 0329 * 0330 * This function returns a pointer to the first node on the chain after the 0331 * head. 0332 * 0333 * @param[in] the_chain is the chain to be operated upon. 0334 * 0335 * @return This method returns the first node of the chain. 0336 */ 0337 static inline rtems_chain_node *rtems_chain_first( 0338 const rtems_chain_control *the_chain 0339 ) 0340 { 0341 return _Chain_First( the_chain ); 0342 } 0343 0344 /** 0345 * @brief Return pointer to immutable Chain's First node 0346 * 0347 * This function returns a pointer to the first node on the chain after the 0348 * head. 0349 * 0350 * @param[in] the_chain is the chain to be operated upon. 0351 * 0352 * @return This method returns the first node of the chain. 0353 */ 0354 static inline const rtems_chain_node *rtems_chain_immutable_first( 0355 const rtems_chain_control *the_chain 0356 ) 0357 { 0358 return _Chain_Immutable_first( the_chain ); 0359 } 0360 0361 /** 0362 * @brief Return pointer to Chain's Last node before the permanent tail. 0363 * 0364 * This function returns a pointer to the last node on the chain just before 0365 * the tail. 0366 * 0367 * @param[in] the_chain is the chain to be operated upon. 0368 * 0369 * @return This method returns the last node of the chain. 0370 */ 0371 static inline rtems_chain_node *rtems_chain_last( 0372 const rtems_chain_control *the_chain 0373 ) 0374 { 0375 return _Chain_Last( the_chain ); 0376 } 0377 0378 /** 0379 * @brief Return pointer to immutable Chain's Last node 0380 * 0381 * This function returns a pointer to the last node on the chain just before 0382 * the tail. 0383 * 0384 * @param[in] the_chain is the chain to be operated upon. 0385 * 0386 * @return This method returns the last node of the chain. 0387 */ 0388 static inline const rtems_chain_node *rtems_chain_immutable_last( 0389 const rtems_chain_control *the_chain 0390 ) 0391 { 0392 return _Chain_Immutable_last( the_chain ); 0393 } 0394 0395 /** 0396 * @brief Return pointer the next node from this node 0397 * 0398 * This function returns a pointer to the next node after this node. 0399 * 0400 * @param[in] the_node is the node to be operated upon. 0401 * 0402 * @return This method returns the next node on the chain. 0403 */ 0404 static inline rtems_chain_node *rtems_chain_next( 0405 const rtems_chain_node *the_node 0406 ) 0407 { 0408 return _Chain_Next( the_node ); 0409 } 0410 0411 /** 0412 * @brief Return pointer the immutable next node from this node 0413 * 0414 * This function returns a pointer to the next node after this node. 0415 * 0416 * @param[in] the_node is the node to be operated upon. 0417 * 0418 * @return This method returns the next node on the chain. 0419 */ 0420 static inline const rtems_chain_node *rtems_chain_immutable_next( 0421 const rtems_chain_node *the_node 0422 ) 0423 { 0424 return _Chain_Immutable_next( the_node ); 0425 } 0426 0427 /** 0428 * @brief Return pointer the previous node from this node 0429 * 0430 * This function returns a pointer to the previous node on this chain. 0431 * 0432 * @param[in] the_node is the node to be operated upon. 0433 * 0434 * @return This method returns the previous node on the chain. 0435 */ 0436 static inline rtems_chain_node *rtems_chain_previous( 0437 const rtems_chain_node *the_node 0438 ) 0439 { 0440 return _Chain_Previous( the_node ); 0441 } 0442 0443 /** 0444 * @brief Return pointer the immutable previous node from this node. 0445 * 0446 * This function returns a pointer to the previous node on this chain. 0447 * 0448 * @param[in] the_node is the node to be operated upon. 0449 * 0450 * @return This method returns the previous node on the chain. 0451 */ 0452 static inline const rtems_chain_node *rtems_chain_immutable_previous( 0453 const rtems_chain_node *the_node 0454 ) 0455 { 0456 return _Chain_Immutable_previous( the_node ); 0457 } 0458 0459 /** 0460 * @brief Are Two nodes equal. 0461 * 0462 * This function returns true if @a left and @a right are equal, 0463 * and false otherwise. 0464 * 0465 * @param[in] left is the node on the left hand side of the comparison. 0466 * @param[in] right is the node on the left hand side of the comparison. 0467 * 0468 * @retval true @a left is equal to @a right. 0469 * @retval false @a left is not equal to @a right 0470 */ 0471 static inline bool rtems_chain_are_nodes_equal( 0472 const rtems_chain_node *left, 0473 const rtems_chain_node *right 0474 ) 0475 { 0476 return _Chain_Are_nodes_equal( left, right ); 0477 } 0478 0479 /** 0480 * @brief Is the chain empty 0481 * 0482 * This function returns true if there a no nodes on @a the_chain and 0483 * false otherwise. 0484 * 0485 * @param[in] the_chain is the chain to be operated upon. 0486 * 0487 * @retval true The chain is empty. 0488 * @retval false The chain is not empty. 0489 */ 0490 static inline bool rtems_chain_is_empty( 0491 const rtems_chain_control *the_chain 0492 ) 0493 { 0494 return _Chain_Is_empty( the_chain ); 0495 } 0496 0497 /** 0498 * @brief Is this the first node on the chain. 0499 * 0500 * This function returns true if the_node is the first node on a chain and 0501 * false otherwise. 0502 * 0503 * @param[in] the_node is the node the caller wants to know if it is 0504 * the first node on a chain. 0505 * 0506 * @retval true @a the_node is the first node on a chain. 0507 * @retval false @a the_node is not the first node on a chain. 0508 */ 0509 static inline bool rtems_chain_is_first( 0510 const rtems_chain_node *the_node 0511 ) 0512 { 0513 return _Chain_Is_first( the_node ); 0514 } 0515 0516 /** 0517 * @brief Is this the last node on the chain. 0518 * 0519 * This function returns true if @a the_node is the last node on a chain and 0520 * false otherwise. 0521 * 0522 * @param[in] the_node is the node to check as the last node. 0523 * 0524 * @retval true @a the_node is the last node on a chain. 0525 * @retval false @a the_node is not the last node on a chain 0526 */ 0527 static inline bool rtems_chain_is_last( 0528 const rtems_chain_node *the_node 0529 ) 0530 { 0531 return _Chain_Is_last( the_node ); 0532 } 0533 0534 /** 0535 * @brief Does this chain have only one node. 0536 * 0537 * This function returns true if there is only one node on @a the_chain and 0538 * false otherwise. 0539 * 0540 * @param[in] the_chain is the chain to be operated upon. 0541 * 0542 * @retval true The chain has only one node. 0543 * @retval false The chain has more than one nodes. 0544 */ 0545 static inline bool rtems_chain_has_only_one_node( 0546 const rtems_chain_control *the_chain 0547 ) 0548 { 0549 return _Chain_Has_only_one_node( the_chain ); 0550 } 0551 0552 /** 0553 * @brief Is this node the chain head. 0554 * 0555 * This function returns true if @a the_node is the head of the_chain and 0556 * false otherwise. 0557 * 0558 * @param[in] the_chain is the chain to be operated upon. 0559 * @param[in] the_node is the node to check for being the Chain Head. 0560 * 0561 * @retval true @a the_node is the head of @a the_chain. 0562 * @retval false @a the_node is not the head of @a the_chain. 0563 */ 0564 static inline bool rtems_chain_is_head( 0565 const rtems_chain_control *the_chain, 0566 const rtems_chain_node *the_node 0567 ) 0568 { 0569 return _Chain_Is_head( the_chain, the_node ); 0570 } 0571 0572 /** 0573 * @brief Is this node the chain tail. 0574 * 0575 * This function returns true if the_node is the tail of the_chain and 0576 * false otherwise. 0577 * 0578 * @param[in] the_chain is the chain to be operated upon. 0579 * @param[in] the_node is the node to check for being the Chain Tail. 0580 * 0581 * @retval true @a the_node is the tail of @a the_chain. 0582 * @retval false @a the_node is not the tail of @a the_chain. 0583 */ 0584 static inline bool rtems_chain_is_tail( 0585 const rtems_chain_control *the_chain, 0586 const rtems_chain_node *the_node 0587 ) 0588 { 0589 return _Chain_Is_tail( the_chain, the_node ); 0590 } 0591 0592 /** 0593 * @brief Extract the specified node from a chain. 0594 * 0595 * This routine extracts @a the_node from the chain on which it resides. 0596 * It disables interrupts to ensure the atomicity of the 0597 * extract operation. 0598 * 0599 * @arg the_node specifies the node to extract 0600 */ 0601 void rtems_chain_extract( 0602 rtems_chain_node *the_node 0603 ); 0604 0605 /** 0606 * @brief Extract the specified node from a chain (unprotected). 0607 * 0608 * This routine extracts @a the_node from the chain on which it resides. 0609 * 0610 * NOTE: It does NOT disable interrupts to ensure the atomicity of the 0611 * append operation. 0612 */ 0613 static inline void rtems_chain_extract_unprotected( 0614 rtems_chain_node *the_node 0615 ) 0616 { 0617 _Chain_Extract_unprotected( the_node ); 0618 } 0619 0620 /** 0621 * @brief Obtain the first node on a chain. 0622 * 0623 * This function removes the first node from @a the_chain and returns 0624 * a pointer to that node. If @a the_chain is empty, then NULL is returned. 0625 * 0626 * @return This method returns a pointer a node. If a node was removed, 0627 * then a pointer to that node is returned. If @a the_chain was 0628 * empty, then NULL is returned. 0629 * 0630 * NOTE: It disables interrupts to ensure the atomicity of the get operation. 0631 */ 0632 rtems_chain_node *rtems_chain_get( 0633 rtems_chain_control *the_chain 0634 ); 0635 0636 /** 0637 * @brief See _Chain_Get_unprotected(). 0638 */ 0639 static inline rtems_chain_node *rtems_chain_get_unprotected( 0640 rtems_chain_control *the_chain 0641 ) 0642 { 0643 return _Chain_Get_unprotected( the_chain ); 0644 } 0645 0646 /** 0647 * @brief See _Chain_Get_first_unprotected(). 0648 */ 0649 static inline rtems_chain_node *rtems_chain_get_first_unprotected( 0650 rtems_chain_control *the_chain 0651 ) 0652 { 0653 return _Chain_Get_first_unprotected( the_chain ); 0654 } 0655 0656 /** 0657 * @brief Insert a node on a chain 0658 * 0659 * This routine inserts @a the_node on a chain immediately following 0660 * @a after_node. 0661 * 0662 * NOTE: It disables interrupts to ensure the atomicity 0663 * of the extract operation. 0664 */ 0665 void rtems_chain_insert( 0666 rtems_chain_node *after_node, 0667 rtems_chain_node *the_node 0668 ); 0669 0670 /** 0671 * @brief See _Chain_Insert_unprotected(). 0672 */ 0673 static inline void rtems_chain_insert_unprotected( 0674 rtems_chain_node *after_node, 0675 rtems_chain_node *the_node 0676 ) 0677 { 0678 _Chain_Insert_unprotected( after_node, the_node ); 0679 } 0680 0681 /** 0682 * @brief Append a node on the end of a chain. 0683 * 0684 * This routine appends @a the_node onto the end of @a the_chain. 0685 * 0686 * NOTE: It disables interrupts to ensure the atomicity of the 0687 * append operation. 0688 */ 0689 void rtems_chain_append( 0690 rtems_chain_control *the_chain, 0691 rtems_chain_node *the_node 0692 ); 0693 0694 /** 0695 * @brief Append a node on the end of a chain (unprotected). 0696 * 0697 * This routine appends @a the_node onto the end of @a the_chain. 0698 * 0699 * NOTE: It does NOT disable interrupts to ensure the atomicity of the 0700 * append operation. 0701 */ 0702 static inline void rtems_chain_append_unprotected( 0703 rtems_chain_control *the_chain, 0704 rtems_chain_node *the_node 0705 ) 0706 { 0707 _Chain_Append_unprotected( the_chain, the_node ); 0708 } 0709 0710 /** 0711 * @brief Prepend a node. 0712 * 0713 * This routine prepends the_node onto the front of the_chain. 0714 * 0715 * @param[in] the_chain is the chain to be operated upon. 0716 * @param[in] the_node is the node to be prepended. 0717 * 0718 * NOTE: It disables interrupts to ensure the atomicity of the 0719 * prepend operation. 0720 */ 0721 void rtems_chain_prepend( 0722 rtems_chain_control *the_chain, 0723 rtems_chain_node *the_node 0724 ); 0725 0726 /** 0727 * @brief Prepend a node (unprotected). 0728 * 0729 * This routine prepends the_node onto the front of the_chain. 0730 * 0731 * @param[in] the_chain is the chain to be operated upon. 0732 * @param[in] the_node is the node to be prepended. 0733 * 0734 * NOTE: It does NOT disable interrupts to ensure the atomicity of the 0735 * prepend operation. 0736 */ 0737 static inline void rtems_chain_prepend_unprotected( 0738 rtems_chain_control *the_chain, 0739 rtems_chain_node *the_node 0740 ) 0741 { 0742 _Chain_Prepend_unprotected( the_chain, the_node ); 0743 } 0744 0745 /** 0746 * @brief Checks if the @a chain is empty and appends the @a node. 0747 * 0748 * Interrupts are disabled to ensure the atomicity of the operation. 0749 * 0750 * @retval true The chain was empty before the append. 0751 * @retval false The chain contained at least one node before the append. 0752 */ 0753 bool rtems_chain_append_with_empty_check( 0754 rtems_chain_control *chain, 0755 rtems_chain_node *node 0756 ); 0757 0758 /** 0759 * @brief Checks if the @a chain is empty and prepends the @a node. 0760 * 0761 * Interrupts are disabled to ensure the atomicity of the operation. 0762 * 0763 * @retval true The chain was empty before the prepend. 0764 * @retval false The chain contained at least one node before the prepend. 0765 */ 0766 bool rtems_chain_prepend_with_empty_check( 0767 rtems_chain_control *chain, 0768 rtems_chain_node *node 0769 ); 0770 0771 /** 0772 * @brief Tries to get the first @a node and check if the @a chain is empty 0773 * afterwards. 0774 * 0775 * This function removes the first node from the @a chain and returns a pointer 0776 * to that node in @a node. If the @a chain is empty, then @c NULL is returned. 0777 * 0778 * Interrupts are disabled to ensure the atomicity of the operation. 0779 * 0780 * @retval true The chain is empty after the node removal. 0781 * @retval false The chain contained at least one node after the node removal. 0782 */ 0783 bool rtems_chain_get_with_empty_check( 0784 rtems_chain_control *chain, 0785 rtems_chain_node **node 0786 ); 0787 0788 /** 0789 * @brief Returns the node count of the chain. 0790 * 0791 * @param[in] chain The chain. 0792 * 0793 * @note It does NOT disable interrupts to ensure the atomicity of the 0794 * operation. 0795 * 0796 * @return The node count of the chain. 0797 */ 0798 static inline size_t rtems_chain_node_count_unprotected( 0799 const rtems_chain_control *chain 0800 ) 0801 { 0802 return _Chain_Node_count_unprotected( chain ); 0803 } 0804 0805 /** @} */ 0806 0807 #ifdef __cplusplus 0808 } 0809 #endif 0810 0811 #endif 0812 /* end of include file */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |