[PATCH 08/45] score: Move _Watchdog_Tickle()

Sebastian Huber sebastian.huber at embedded-brains.de
Fri May 15 11:41:08 UTC 2015


Make internal function _Watchdog_Remove_it() static to avoid accidental
usage.

Update #2307.
---
 cpukit/score/Makefile.am                        |  3 +-
 cpukit/score/include/rtems/score/watchdogimpl.h | 10 ---
 cpukit/score/src/watchdogremove.c               | 67 ++++++++++++++++++-
 cpukit/score/src/watchdogtickle.c               | 86 -------------------------
 4 files changed, 67 insertions(+), 99 deletions(-)
 delete mode 100644 cpukit/score/src/watchdogtickle.c

diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index f8ad60d..af7da2a 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -324,8 +324,7 @@ libscore_a_SOURCES += src/coretod.c src/coretodset.c src/coretodget.c \
 
 ## WATCHDOG_C_FILES
 libscore_a_SOURCES += src/watchdog.c src/watchdogadjust.c \
-    src/watchdogadjusttochain.c src/watchdoginsert.c src/watchdogremove.c \
-    src/watchdogtickle.c
+    src/watchdogadjusttochain.c src/watchdoginsert.c src/watchdogremove.c
 libscore_a_SOURCES += src/watchdogtickssinceboot.c
 
 ## USEREXT_C_FILES
diff --git a/cpukit/score/include/rtems/score/watchdogimpl.h b/cpukit/score/include/rtems/score/watchdogimpl.h
index 304392b..dfe50e6 100644
--- a/cpukit/score/include/rtems/score/watchdogimpl.h
+++ b/cpukit/score/include/rtems/score/watchdogimpl.h
@@ -153,16 +153,6 @@ Watchdog_States _Watchdog_Remove (
 );
 
 /**
- * @brief Actually removes an WATCHDOG_ACTIVE or WATCHDOG_REMOVE_IT watchdog.
- *
- * @see _Watchdog_Remove() and _Watchdog_Tickle().
- */
-void _Watchdog_Remove_it(
-  Watchdog_Header  *header,
-  Watchdog_Control *the_watchdog
-);
-
-/**
  *  @brief Adjusts the header watchdog chain in the backward direction for
  *  units ticks.
  *
diff --git a/cpukit/score/src/watchdogremove.c b/cpukit/score/src/watchdogremove.c
index c896fbb..2ac63fe 100644
--- a/cpukit/score/src/watchdogremove.c
+++ b/cpukit/score/src/watchdogremove.c
@@ -21,7 +21,7 @@
 #include <rtems/score/watchdogimpl.h>
 #include <rtems/score/assert.h>
 
-void _Watchdog_Remove_it(
+static void _Watchdog_Remove_it(
   Watchdog_Header   *header,
   Watchdog_Control  *the_watchdog
 )
@@ -107,3 +107,68 @@ Watchdog_States _Watchdog_Remove(
   _Watchdog_Release( header, &lock_context );
   return( previous_state );
 }
+
+void _Watchdog_Tickle(
+  Watchdog_Header *header
+)
+{
+  ISR_lock_Context lock_context;
+
+  _Watchdog_Acquire( header, &lock_context );
+
+  if ( !_Watchdog_Is_empty( header ) ) {
+    Watchdog_Control  *first;
+    Watchdog_Interval  delta;
+
+    first = _Watchdog_First( header );
+    delta = first->delta_interval;
+
+    /*
+     * Although it is forbidden to insert watchdogs with a delta interval of
+     * zero it is possible to observe watchdogs with a delta interval of zero
+     * at this point.  For example lets have a watchdog chain of one watchdog
+     * with a delta interval of one and insert a new one with an initial value
+     * of one.  At the start of the insert procedure it will advance one step
+     * and reduce its delta interval by one yielding zero.  Now a tick happens.
+     * This will remove the watchdog on the chain and update the insert
+     * iterator.  Now the insert operation continues and will insert the new
+     * watchdog with a delta interval of zero.
+     */
+    if ( delta > 0 ) {
+      --delta;
+      first->delta_interval = delta;
+    }
+
+    while ( delta == 0 ) {
+      bool                            run;
+      Watchdog_Service_routine_entry  routine;
+      Objects_Id                      id;
+      void                           *user_data;
+
+      run = ( first->state == WATCHDOG_ACTIVE );
+
+      _Watchdog_Remove_it( header, first );
+
+      routine = first->routine;
+      id = first->id;
+      user_data = first->user_data;
+
+      _Watchdog_Release( header, &lock_context );
+
+      if ( run ) {
+        (*routine)( id, user_data );
+      }
+
+      _Watchdog_Acquire( header, &lock_context );
+
+      if ( _Watchdog_Is_empty( header ) ) {
+        break;
+      }
+
+      first = _Watchdog_First( header );
+      delta = first->delta_interval;
+    }
+  }
+
+  _Watchdog_Release( header, &lock_context );
+}
diff --git a/cpukit/score/src/watchdogtickle.c b/cpukit/score/src/watchdogtickle.c
deleted file mode 100644
index 7a80008..0000000
--- a/cpukit/score/src/watchdogtickle.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * @file
- *
- * @ingroup ScoreWatchdog
- * @brief Watchdog Tickle
- */
- 
-/*
- *  COPYRIGHT (c) 1989-1999.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <rtems/score/watchdogimpl.h>
-
-void _Watchdog_Tickle(
-  Watchdog_Header *header
-)
-{
-  ISR_lock_Context lock_context;
-
-  _Watchdog_Acquire( header, &lock_context );
-
-  if ( !_Watchdog_Is_empty( header ) ) {
-    Watchdog_Control  *first;
-    Watchdog_Interval  delta;
-
-    first = _Watchdog_First( header );
-    delta = first->delta_interval;
-
-    /*
-     * Although it is forbidden to insert watchdogs with a delta interval of
-     * zero it is possible to observe watchdogs with a delta interval of zero
-     * at this point.  For example lets have a watchdog chain of one watchdog
-     * with a delta interval of one and insert a new one with an initial value
-     * of one.  At the start of the insert procedure it will advance one step
-     * and reduce its delta interval by one yielding zero.  Now a tick happens.
-     * This will remove the watchdog on the chain and update the insert
-     * iterator.  Now the insert operation continues and will insert the new
-     * watchdog with a delta interval of zero.
-     */
-    if ( delta > 0 ) {
-      --delta;
-      first->delta_interval = delta;
-    }
-
-    while ( delta == 0 ) {
-      bool                            run;
-      Watchdog_Service_routine_entry  routine;
-      Objects_Id                      id;
-      void                           *user_data;
-
-      run = ( first->state == WATCHDOG_ACTIVE );
-
-      _Watchdog_Remove_it( header, first );
-
-      routine = first->routine;
-      id = first->id;
-      user_data = first->user_data;
-
-      _Watchdog_Release( header, &lock_context );
-
-      if ( run ) {
-        (*routine)( id, user_data );
-      }
-
-      _Watchdog_Acquire( header, &lock_context );
-
-      if ( _Watchdog_Is_empty( header ) ) {
-        break;
-      }
-
-      first = _Watchdog_First( header );
-      delta = first->delta_interval;
-    }
-  }
-
-  _Watchdog_Release( header, &lock_context );
-}
-- 
1.8.4.5



More information about the devel mailing list