RTEMS 6.1-rc2
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
150 rtems_chain_control *chain,
151 rtems_event_set events,
152 rtems_interval timeout,
153 rtems_chain_node **node
154);
155
169static inline void rtems_chain_initialize(
170 rtems_chain_control *the_chain,
171 void *starting_address,
172 size_t number_nodes,
173 size_t node_size
174)
175{
177 the_chain,
178 starting_address,
179 number_nodes,
180 node_size
181 );
182}
183
191static inline void rtems_chain_initialize_empty(
192 rtems_chain_control *the_chain
193)
194{
195 _Chain_Initialize_empty( the_chain );
196}
197
206static inline void rtems_chain_set_off_chain(
207 rtems_chain_node *node
208)
209{
210 _Chain_Set_off_chain( node );
211}
212
221static inline void rtems_chain_initialize_node(
222 rtems_chain_node *node
223)
224{
225 _Chain_Initialize_node( node );
226}
227
239static inline bool rtems_chain_is_node_off_chain(
240 const rtems_chain_node *node
241)
242{
243 return _Chain_Is_node_off_chain( node );
244}
245
256static inline bool rtems_chain_is_null_node(
257 const rtems_chain_node *the_node
258)
259{
260 return the_node == NULL;
261}
262
272static inline rtems_chain_node *rtems_chain_head(
273 rtems_chain_control *the_chain
274)
275{
276 return _Chain_Head( the_chain );
277}
278
288static inline const rtems_chain_node *rtems_chain_immutable_head(
289 const rtems_chain_control *the_chain
290)
291{
292 return _Chain_Immutable_head( the_chain );
293}
294
304static inline rtems_chain_node *rtems_chain_tail(
305 rtems_chain_control *the_chain
306)
307{
308 return _Chain_Tail( the_chain );
309}
310
320static inline const rtems_chain_node *rtems_chain_immutable_tail(
321 const rtems_chain_control *the_chain
322)
323{
324 return _Chain_Immutable_tail( the_chain );
325}
326
337static inline rtems_chain_node *rtems_chain_first(
338 const rtems_chain_control *the_chain
339)
340{
341 return _Chain_First( the_chain );
342}
343
354static inline const rtems_chain_node *rtems_chain_immutable_first(
355 const rtems_chain_control *the_chain
356)
357{
358 return _Chain_Immutable_first( the_chain );
359}
360
371static inline rtems_chain_node *rtems_chain_last(
372 const rtems_chain_control *the_chain
373)
374{
375 return _Chain_Last( the_chain );
376}
377
388static inline const rtems_chain_node *rtems_chain_immutable_last(
389 const rtems_chain_control *the_chain
390)
391{
392 return _Chain_Immutable_last( the_chain );
393}
394
404static inline rtems_chain_node *rtems_chain_next(
405 const rtems_chain_node *the_node
406)
407{
408 return _Chain_Next( the_node );
409}
410
420static inline const rtems_chain_node *rtems_chain_immutable_next(
421 const rtems_chain_node *the_node
422)
423{
424 return _Chain_Immutable_next( the_node );
425}
426
436static inline rtems_chain_node *rtems_chain_previous(
437 const rtems_chain_node *the_node
438)
439{
440 return _Chain_Previous( the_node );
441}
442
452static inline const rtems_chain_node *rtems_chain_immutable_previous(
453 const rtems_chain_node *the_node
454)
455{
456 return _Chain_Immutable_previous( the_node );
457}
458
471static inline bool rtems_chain_are_nodes_equal(
472 const rtems_chain_node *left,
473 const rtems_chain_node *right
474)
475{
476 return _Chain_Are_nodes_equal( left, right );
477}
478
490static inline bool rtems_chain_is_empty(
491 const rtems_chain_control *the_chain
492)
493{
494 return _Chain_Is_empty( the_chain );
495}
496
509static inline bool rtems_chain_is_first(
510 const rtems_chain_node *the_node
511)
512{
513 return _Chain_Is_first( the_node );
514}
515
527static inline bool rtems_chain_is_last(
528 const rtems_chain_node *the_node
529)
530{
531 return _Chain_Is_last( the_node );
532}
533
545static inline bool rtems_chain_has_only_one_node(
546 const rtems_chain_control *the_chain
547)
548{
549 return _Chain_Has_only_one_node( the_chain );
550}
551
564static inline bool rtems_chain_is_head(
565 const rtems_chain_control *the_chain,
566 const rtems_chain_node *the_node
567)
568{
569 return _Chain_Is_head( the_chain, the_node );
570}
571
584static inline bool rtems_chain_is_tail(
585 const rtems_chain_control *the_chain,
586 const rtems_chain_node *the_node
587)
588{
589 return _Chain_Is_tail( the_chain, the_node );
590}
591
602 rtems_chain_node *the_node
603);
604
613static inline void rtems_chain_extract_unprotected(
614 rtems_chain_node *the_node
615)
616{
617 _Chain_Extract_unprotected( the_node );
618}
619
633 rtems_chain_control *the_chain
634);
635
639static inline rtems_chain_node *rtems_chain_get_unprotected(
640 rtems_chain_control *the_chain
641)
642{
643 return _Chain_Get_unprotected( the_chain );
644}
645
649static inline rtems_chain_node *rtems_chain_get_first_unprotected(
650 rtems_chain_control *the_chain
651)
652{
653 return _Chain_Get_first_unprotected( the_chain );
654}
655
666 rtems_chain_node *after_node,
667 rtems_chain_node *the_node
668);
669
673static inline void rtems_chain_insert_unprotected(
674 rtems_chain_node *after_node,
675 rtems_chain_node *the_node
676)
677{
678 _Chain_Insert_unprotected( after_node, the_node );
679}
680
690 rtems_chain_control *the_chain,
691 rtems_chain_node *the_node
692);
693
702static inline void rtems_chain_append_unprotected(
703 rtems_chain_control *the_chain,
704 rtems_chain_node *the_node
705)
706{
707 _Chain_Append_unprotected( the_chain, the_node );
708}
709
722 rtems_chain_control *the_chain,
723 rtems_chain_node *the_node
724);
725
737static inline void rtems_chain_prepend_unprotected(
738 rtems_chain_control *the_chain,
739 rtems_chain_node *the_node
740)
741{
742 _Chain_Prepend_unprotected( the_chain, the_node );
743}
744
754 rtems_chain_control *chain,
755 rtems_chain_node *node
756);
757
767 rtems_chain_control *chain,
768 rtems_chain_node *node
769);
770
784 rtems_chain_control *chain,
785 rtems_chain_node **node
786);
787
798static inline size_t rtems_chain_node_count_unprotected(
799 const rtems_chain_control *chain
800)
801{
802 return _Chain_Node_count_unprotected( chain );
803}
804
807#ifdef __cplusplus
808}
809#endif
810
811#endif
812/* 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 of the chain and sends the events to the task if the chain is empty afterwards.
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
#define NULL
Requests a GPIO pin group configuration.
Definition: xil_types.h:54
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