RTEMS 7.0-rc1
Loading...
Searching...
No Matches
chain.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2010, 2014 embedded brains GmbH & Co. KG
13 *
14 * COPYRIGHT (c) 1989-2008.
15 * On-Line Applications Research Corporation (OAR).
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
30 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#ifndef _RTEMS_CHAIN_H
40#define _RTEMS_CHAIN_H
41
43#include <rtems/rtems/event.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
61
63
67#define RTEMS_CHAIN_INITIALIZER_EMPTY( name ) \
68 CHAIN_INITIALIZER_EMPTY( name )
69
75#define RTEMS_CHAIN_INITIALIZER_ONE_NODE( node ) \
76 CHAIN_INITIALIZER_ONE_NODE( node )
77
83#define RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain ) \
84 CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( chain )
85
89#define RTEMS_CHAIN_DEFINE_EMPTY( name ) \
90 rtems_chain_control name = RTEMS_CHAIN_INITIALIZER_EMPTY( name )
91
102 rtems_chain_control *chain,
103 rtems_chain_node *node,
104 rtems_id task,
105 rtems_event_set events
106);
107
118 rtems_chain_control *chain,
119 rtems_chain_node *node,
120 rtems_id task,
121 rtems_event_set events
122);
123
134 rtems_chain_control *chain,
135 rtems_id task,
136 rtems_event_set events,
137 rtems_chain_node **node
138);
139
157 rtems_chain_control *chain,
158 rtems_event_set events,
159 rtems_interval timeout,
160 rtems_chain_node **node
161);
162
176static inline void rtems_chain_initialize(
177 rtems_chain_control *the_chain,
178 void *starting_address,
179 size_t number_nodes,
180 size_t node_size
181)
182{
184 the_chain,
185 starting_address,
186 number_nodes,
187 node_size
188 );
189}
190
198static inline void rtems_chain_initialize_empty(
199 rtems_chain_control *the_chain
200)
201{
202 _Chain_Initialize_empty( the_chain );
203}
204
213static inline void rtems_chain_set_off_chain(
214 rtems_chain_node *node
215)
216{
217 _Chain_Set_off_chain( node );
218}
219
228static inline void rtems_chain_initialize_node(
229 rtems_chain_node *node
230)
231{
232 _Chain_Initialize_node( node );
233}
234
246static inline bool rtems_chain_is_node_off_chain(
247 const rtems_chain_node *node
248)
249{
250 return _Chain_Is_node_off_chain( node );
251}
252
263static inline bool rtems_chain_is_null_node(
264 const rtems_chain_node *the_node
265)
266{
267 return the_node == NULL;
268}
269
279static inline rtems_chain_node *rtems_chain_head(
280 rtems_chain_control *the_chain
281)
282{
283 return _Chain_Head( the_chain );
284}
285
295static inline const rtems_chain_node *rtems_chain_immutable_head(
296 const rtems_chain_control *the_chain
297)
298{
299 return _Chain_Immutable_head( the_chain );
300}
301
311static inline rtems_chain_node *rtems_chain_tail(
312 rtems_chain_control *the_chain
313)
314{
315 return _Chain_Tail( the_chain );
316}
317
327static inline const rtems_chain_node *rtems_chain_immutable_tail(
328 const rtems_chain_control *the_chain
329)
330{
331 return _Chain_Immutable_tail( the_chain );
332}
333
344static inline rtems_chain_node *rtems_chain_first(
345 const rtems_chain_control *the_chain
346)
347{
348 return _Chain_First( the_chain );
349}
350
361static inline const rtems_chain_node *rtems_chain_immutable_first(
362 const rtems_chain_control *the_chain
363)
364{
365 return _Chain_Immutable_first( the_chain );
366}
367
378static inline rtems_chain_node *rtems_chain_last(
379 const rtems_chain_control *the_chain
380)
381{
382 return _Chain_Last( the_chain );
383}
384
395static inline const rtems_chain_node *rtems_chain_immutable_last(
396 const rtems_chain_control *the_chain
397)
398{
399 return _Chain_Immutable_last( the_chain );
400}
401
411static inline rtems_chain_node *rtems_chain_next(
412 const rtems_chain_node *the_node
413)
414{
415 return _Chain_Next( the_node );
416}
417
427static inline const rtems_chain_node *rtems_chain_immutable_next(
428 const rtems_chain_node *the_node
429)
430{
431 return _Chain_Immutable_next( the_node );
432}
433
443static inline rtems_chain_node *rtems_chain_previous(
444 const rtems_chain_node *the_node
445)
446{
447 return _Chain_Previous( the_node );
448}
449
459static inline const rtems_chain_node *rtems_chain_immutable_previous(
460 const rtems_chain_node *the_node
461)
462{
463 return _Chain_Immutable_previous( the_node );
464}
465
478static inline bool rtems_chain_are_nodes_equal(
479 const rtems_chain_node *left,
480 const rtems_chain_node *right
481)
482{
483 return _Chain_Are_nodes_equal( left, right );
484}
485
497static inline bool rtems_chain_is_empty(
498 const rtems_chain_control *the_chain
499)
500{
501 return _Chain_Is_empty( the_chain );
502}
503
516static inline bool rtems_chain_is_first(
517 const rtems_chain_node *the_node
518)
519{
520 return _Chain_Is_first( the_node );
521}
522
534static inline bool rtems_chain_is_last(
535 const rtems_chain_node *the_node
536)
537{
538 return _Chain_Is_last( the_node );
539}
540
552static inline bool rtems_chain_has_only_one_node(
553 const rtems_chain_control *the_chain
554)
555{
556 return _Chain_Has_only_one_node( the_chain );
557}
558
571static inline bool rtems_chain_is_head(
572 const rtems_chain_control *the_chain,
573 const rtems_chain_node *the_node
574)
575{
576 return _Chain_Is_head( the_chain, the_node );
577}
578
591static inline bool rtems_chain_is_tail(
592 const rtems_chain_control *the_chain,
593 const rtems_chain_node *the_node
594)
595{
596 return _Chain_Is_tail( the_chain, the_node );
597}
598
609 rtems_chain_node *the_node
610);
611
620static inline void rtems_chain_extract_unprotected(
621 rtems_chain_node *the_node
622)
623{
624 _Chain_Extract_unprotected( the_node );
625}
626
640 rtems_chain_control *the_chain
641);
642
646static inline rtems_chain_node *rtems_chain_get_unprotected(
647 rtems_chain_control *the_chain
648)
649{
650 return _Chain_Get_unprotected( the_chain );
651}
652
656static inline rtems_chain_node *rtems_chain_get_first_unprotected(
657 rtems_chain_control *the_chain
658)
659{
660 return _Chain_Get_first_unprotected( the_chain );
661}
662
673 rtems_chain_node *after_node,
674 rtems_chain_node *the_node
675);
676
680static inline void rtems_chain_insert_unprotected(
681 rtems_chain_node *after_node,
682 rtems_chain_node *the_node
683)
684{
685 _Chain_Insert_unprotected( after_node, the_node );
686}
687
697 rtems_chain_control *the_chain,
698 rtems_chain_node *the_node
699);
700
709static inline void rtems_chain_append_unprotected(
710 rtems_chain_control *the_chain,
711 rtems_chain_node *the_node
712)
713{
714 _Chain_Append_unprotected( the_chain, the_node );
715}
716
729 rtems_chain_control *the_chain,
730 rtems_chain_node *the_node
731);
732
744static inline void rtems_chain_prepend_unprotected(
745 rtems_chain_control *the_chain,
746 rtems_chain_node *the_node
747)
748{
749 _Chain_Prepend_unprotected( the_chain, the_node );
750}
751
761 rtems_chain_control *chain,
762 rtems_chain_node *node
763);
764
774 rtems_chain_control *chain,
775 rtems_chain_node *node
776);
777
791 rtems_chain_control *chain,
792 rtems_chain_node **node
793);
794
805static inline size_t rtems_chain_node_count_unprotected(
806 const rtems_chain_control *chain
807)
808{
809 return _Chain_Node_count_unprotected( chain );
810}
811
814#ifdef __cplusplus
815}
816#endif
817
818#endif
819/* end of include file */
This header file provides interfaces of the Chain Handler which are only used by the implementation.
rtems_status_code rtems_chain_get_with_wait(rtems_chain_control *chain, rtems_event_set events, rtems_interval timeout, rtems_chain_node **node)
Gets the first node from the chain with an events wait if empty.
Definition: chaingetwait.c:43
bool rtems_chain_append_with_empty_check(rtems_chain_control *chain, rtems_chain_node *node)
Checks if the chain is empty and appends the node.
Definition: chainprotected.c:113
void rtems_chain_insert(rtems_chain_node *after_node, rtems_chain_node *the_node)
Insert a node on a chain.
Definition: chainprotected.c:80
void rtems_chain_prepend(rtems_chain_control *the_chain, rtems_chain_node *the_node)
Prepend a node.
Definition: chainprotected.c:101
rtems_status_code rtems_chain_prepend_with_notification(rtems_chain_control *chain, rtems_chain_node *node, rtems_id task, rtems_event_set events)
Prepends the node to the chain and sends the events to the task if the chain was empty before the pre...
Definition: chainprependnotify.c:43
rtems_chain_node * rtems_chain_get(rtems_chain_control *the_chain)
Obtain the first node on a chain.
Definition: chainprotected.c:68
void rtems_chain_append(rtems_chain_control *the_chain, rtems_chain_node *the_node)
Append a node on the end of a chain.
Definition: chainprotected.c:89
rtems_status_code rtems_chain_append_with_notification(rtems_chain_control *chain, rtems_chain_node *node, rtems_id task, rtems_event_set events)
Appends the node to the chain and sends the events to the task if the chain was empty before the appe...
Definition: chainappendnotify.c:43
bool rtems_chain_prepend_with_empty_check(rtems_chain_control *chain, rtems_chain_node *node)
Checks if the chain is empty and prepends the node.
Definition: chainprotected.c:128
bool rtems_chain_get_with_empty_check(rtems_chain_control *chain, rtems_chain_node **node)
Tries to get the first node and check if the chain is empty afterwards.
Definition: chainprotected.c:143
rtems_status_code rtems_chain_get_with_notification(rtems_chain_control *chain, rtems_id task, rtems_event_set events, rtems_chain_node **node)
Gets the first node of the chain and sends the events to the task if the chain is empty after the get...
Definition: chaingetnotify.c:43
void rtems_chain_extract(rtems_chain_node *the_node)
Extract the specified node from a chain.
Definition: chainprotected.c:59
uint32_t rtems_event_set
This integer type represents a bit field which can hold exactly 32 individual events.
Definition: event.h:436
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
Objects_Id rtems_id
This type represents RTEMS object identifiers.
Definition: types.h:94
Watchdog_Interval rtems_interval
This type represents clock tick intervals.
Definition: types.h:114
size_t _Chain_Node_count_unprotected(const Chain_Control *chain)
Returns the node count of the chain.
Definition: chainnodecount.c:42
void _Chain_Initialize(Chain_Control *the_chain, void *starting_address, size_t number_nodes, size_t node_size)
Initializes a chain header.
Definition: chain.c:46
This header file provides the Event Manager API.
This structure represents a chain node.
Definition: chain.h:78
This union represents a chain control block.
Definition: chain.h:96