change log for rtems (2010-11-25)

rtems-vc at rtems.org rtems-vc at rtems.org
Thu Nov 25 06:10:29 CST 2010


 *sh*:
2010-11-25	Sebastian Huber <sebastian.huber at embedded-brains.de>

	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.

M 1.2657  cpukit/ChangeLog
M   1.26  cpukit/score/include/rtems/score/chain.h
M   1.23  cpukit/score/inline/rtems/score/chain.inl

diff -u rtems/cpukit/ChangeLog:1.2656 rtems/cpukit/ChangeLog:1.2657
--- rtems/cpukit/ChangeLog:1.2656	Thu Nov 25 03:27:05 2010
+++ rtems/cpukit/ChangeLog	Thu Nov 25 05:48:10 2010
@@ -1,5 +1,14 @@
 2010-11-25	Sebastian Huber <sebastian.huber at embedded-brains.de>
 
+	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.
+
+2010-11-25	Sebastian Huber <sebastian.huber at embedded-brains.de>
+
 	* libfs/src/dosfs/fat_file.c, libfs/src/imfs/imfs_debug.c,
 	libfs/src/imfs/imfs_directory.c, libfs/src/imfs/imfs_getchild.c,
 	posix/src/killinfo.c, score/inline/rtems/score/schedulerpriority.inl,

diff -u rtems/cpukit/score/include/rtems/score/chain.h:1.25 rtems/cpukit/score/include/rtems/score/chain.h:1.26
--- rtems/cpukit/score/include/rtems/score/chain.h:1.25	Mon Aug 23 11:10:53 2010
+++ rtems/cpukit/score/include/rtems/score/chain.h	Thu Nov 25 05:48:11 2010
@@ -83,30 +83,24 @@
  *   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.

diff -u rtems/cpukit/score/inline/rtems/score/chain.inl:1.22 rtems/cpukit/score/inline/rtems/score/chain.inl:1.23
--- rtems/cpukit/score/inline/rtems/score/chain.inl:1.22	Mon Aug 23 11:10:53 2010
+++ rtems/cpukit/score/inline/rtems/score/chain.inl	Thu Nov 25 05:48:11 2010
@@ -122,7 +122,22 @@
   Chain_Control *the_chain
 )
 {
-   return (Chain_Node *) the_chain;
+  return &the_chain->Head.Node;
+}
+
+/** @brief Return pointer to immutable Chain Head
+ *
+ *  This function returns a pointer to the head node on the chain.
+ *
+ *  @param[in] the_chain is the chain to be operated upon.
+ *
+ *  @return This method returns the permanent head node of the chain.
+ */
+RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_head(
+  const Chain_Control *the_chain
+)
+{
+  return &the_chain->Head.Node;
 }
 
 /** @brief Return pointer to Chain Tail
@@ -137,7 +152,22 @@
   Chain_Control *the_chain
 )
 {
-   return (Chain_Node *) &the_chain->permanent_null;
+  return &the_chain->Tail.Node;
+}
+
+/** @brief Return pointer to immutable Chain Tail
+ *
+ *  This function returns a pointer to the last node on the chain.
+ *
+ *  @param[in] the_chain is the chain to be operated upon.
+ *
+ *  @return This method returns the permanent tail node of the chain.
+ */
+RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_tail(
+  const Chain_Control *the_chain
+)
+{
+  return &the_chain->Tail.Node;
 }
 
 /** @brief Return pointer to Chain's First node
@@ -153,7 +183,23 @@
   Chain_Control *the_chain
 )
 {
-  return the_chain->first;
+  return _Chain_Head( the_chain )->next;
+}
+
+/** @brief Return pointer to immutable Chain's First node
+ *
+ *  This function returns a pointer to the first node on the chain after the
+ *  head.
+ *
+ *  @param[in] the_chain is the chain to be operated upon.
+ *
+ *  @return This method returns the first node of the chain.
+ */
+RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_first(
+  const Chain_Control *the_chain
+)
+{
+  return _Chain_Immutable_head( the_chain )->next;
 }
 
 /** @brief Return pointer to Chain's Last node
@@ -169,7 +215,23 @@
   Chain_Control *the_chain
 )
 {
-  return the_chain->last;
+  return _Chain_Tail( the_chain )->previous;
+}
+
+/** @brief Return pointer to immutable Chain's Last node
+ *
+ *  This function returns a pointer to the last node on the chain just before
+ *  the tail.
+ *
+ *  @param[in] the_chain is the chain to be operated upon.
+ *
+ *  @return This method returns the last node of the chain.
+ */
+RTEMS_INLINE_ROUTINE const Chain_Node *_Chain_Immutable_last(
+  const Chain_Control *the_chain
+)
+{
+  return _Chain_Immutable_tail( the_chain )->previous;
 }
 
 /** @brief Return pointer the next node from this node
@@ -213,10 +275,11 @@
  *  false otherwise.
  */
 RTEMS_INLINE_ROUTINE bool _Chain_Is_empty(
-  Chain_Control *the_chain
+  const Chain_Control *the_chain
 )
 {
-  return (the_chain->first == _Chain_Tail(the_chain));
+  return _Chain_Immutable_first( the_chain )
+    == _Chain_Immutable_tail( the_chain );
 }
 
 /** @brief Is this the First Node on the Chain
@@ -268,7 +331,8 @@
   const Chain_Control *the_chain
 )
 {
-  return (the_chain->first == the_chain->last);
+  return _Chain_Immutable_first( the_chain )
+    == _Chain_Immutable_last( the_chain );
 }
 
 /** @brief Is this Node the Chain Head
@@ -287,7 +351,7 @@
   const Chain_Node    *the_node
 )
 {
-   return (the_node == _Chain_Head(the_chain));
+  return (the_node == _Chain_Head(the_chain));
 }
 
 /** @brief Is this Node the Chail Tail
@@ -303,7 +367,7 @@
   const Chain_Node    *the_node
 )
 {
-   return (the_node == _Chain_Tail(the_chain));
+  return (the_node == _Chain_Tail(the_chain));
 }
 
 /** @brief Initialize this Chain as Empty
@@ -316,9 +380,12 @@
   Chain_Control *the_chain
 )
 {
-  the_chain->first          = _Chain_Tail(the_chain);
-  the_chain->permanent_null = NULL;
-  the_chain->last           = _Chain_Head(the_chain);
+  Chain_Node *head = _Chain_Head( the_chain );
+  Chain_Node *tail = _Chain_Tail( the_chain );
+
+  head->next = tail;
+  head->previous = NULL;
+  tail->previous = head;
 }
 
 /** @brief Extract this Node (unprotected)
@@ -360,15 +427,14 @@
   Chain_Control *the_chain
 )
 {
-  Chain_Node  *return_node;
-  Chain_Node  *new_first;
+  Chain_Node *head = _Chain_Head( the_chain );
+  Chain_Node *old_first = head->next;
+  Chain_Node *new_first = old_first->next;
 
-  return_node         = the_chain->first;
-  new_first           = return_node->next;
-  the_chain->first    = new_first;
-  new_first->previous = _Chain_Head(the_chain);
+  head->next = new_first;
+  new_first->previous = head;
 
-  return return_node;
+  return old_first;
 }
 
 /** @brief Get the First Node (unprotected)
@@ -435,13 +501,13 @@
   Chain_Node    *the_node
 )
 {
-  Chain_Node *old_last_node;
+  Chain_Node *tail = _Chain_Tail( the_chain );
+  Chain_Node *old_last = tail->previous;
 
-  the_node->next      = _Chain_Tail(the_chain);
-  old_last_node       = the_chain->last;
-  the_chain->last     = the_node;
-  old_last_node->next = the_node;
-  the_node->previous  = old_last_node;
+  the_node->next = tail;
+  tail->previous = the_node;
+  old_last->next = the_node;
+  the_node->previous = old_last;
 }
 
 /** @brief Prepend a Node (unprotected)
@@ -556,17 +622,19 @@
 )
 {
   bool is_empty_now = true;
-  Chain_Node *first = the_chain->first;
+  Chain_Node *head = _Chain_Head( the_chain );
+  Chain_Node *tail = _Chain_Tail( the_chain );
+  Chain_Node *old_first = head->next;
 
-  if ( first != _Chain_Tail( the_chain ) ) {
-    Chain_Node *new_first = first->next;
+  if ( old_first != tail ) {
+    Chain_Node *new_first = old_first->next;
 
-    the_chain->first = new_first;
-    new_first->previous = _Chain_Head( the_chain );
+    head->next = new_first;
+    new_first->previous = head;
 
-    *the_node = first;
+    *the_node = old_first;
 
-    is_empty_now = new_first == _Chain_Tail( the_chain );
+    is_empty_now = new_first == tail;
   } else
     *the_node = NULL;
 



--

Generated by Deluxe Loginfo [http://www.codewiz.org/projects/index.html#loginfo] 2.122 by Bernardo Innocenti <bernie at develer.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.rtems.org/pipermail/rtems-vc/attachments/20101125/97af117a/attachment.html>


More information about the rtems-vc mailing list