From 76da5fa89ddef402f680ce222416fb4be17df89f Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 25 Nov 2010 11:48:11 +0000 Subject: 2010-11-25 Sebastian Huber PR 1711/cpukit * score/inline/rtems/score/chain.inl, score/src/chain.c: New functions _Chain_Immutable_head(), _Chain_Immutable_tail(), _Chain_Immutable_first(), and _Chain_Immutable_last(). The Chain_Control is now a union to avoid casts. The function _Chain_Is_empty() takes now a const pointer parameter. --- cpukit/score/include/rtems/score/chain.h | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'cpukit/score/include') diff --git a/cpukit/score/include/rtems/score/chain.h b/cpukit/score/include/rtems/score/chain.h index 4d298b3cd2..187a466c90 100644 --- a/cpukit/score/include/rtems/score/chain.h +++ b/cpukit/score/include/rtems/score/chain.h @@ -83,30 +83,24 @@ struct Chain_Node_struct { * manipulating the first and last elements on the chain. * To accomplish this the @a Chain_Control structure is * treated as two overlapping @ref Chain_Node structures. - * The permanent head of the chain overlays a node structure on the - * @a first and @a permanent_null fields. The permanent tail - * of the chain overlays a node structure on the - * @a permanent_null and @a last elements of the structure. - * */ -typedef struct { - /** This points to the first node on this chain. */ - Chain_Node *first; - /** This field is always 0. */ - Chain_Node *permanent_null; - /** This points to the last node on this chain. */ - Chain_Node *last; +typedef union { + struct { + Chain_Node Node; + Chain_Node *fill; + } Head; + + struct { + Chain_Node *fill; + Chain_Node Node; + } Tail; } Chain_Control; /** * @brief Chain initializer for an empty chain with designator @a name. */ #define CHAIN_INITIALIZER_EMPTY(name) \ - { \ - (Chain_Node *) &(name).permanent_null, \ - NULL, \ - (Chain_Node *) &(name) \ - } + { { { &(name).Tail.Node, NULL }, &(name).Head.Node } } /** * @brief Chain definition for an empty chain with designator @a name. -- cgit v1.2.3