[rtems commit] score: Add WATCHDOG_INITIALIZER()

Sebastian Huber sebh at rtems.org
Mon Jul 22 14:51:44 UTC 2013


Module:    rtems
Branch:    master
Commit:    0eae7ba9ba8c6c60e0718e364a37081b290cc457
Changeset: http://git.rtems.org/rtems/commit/?id=0eae7ba9ba8c6c60e0718e364a37081b290cc457

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Jul 22 11:10:43 2013 +0200

score: Add WATCHDOG_INITIALIZER()

---

 cpukit/score/include/rtems/score/watchdogimpl.h |   13 ++++++++++++
 testsuites/sptests/spwatchdog/init.c            |   24 +++++++++++++++++++++++
 2 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/cpukit/score/include/rtems/score/watchdogimpl.h b/cpukit/score/include/rtems/score/watchdogimpl.h
index e0324ff..3085a44 100644
--- a/cpukit/score/include/rtems/score/watchdogimpl.h
+++ b/cpukit/score/include/rtems/score/watchdogimpl.h
@@ -40,6 +40,19 @@ extern "C" {
 #define WATCHDOG_MAXIMUM_INTERVAL ((Watchdog_Interval) 0xffffffff)
 
 /**
+ * @brief Watchdog initializer for static initialization.
+ *
+ * @see _Watchdog_Initialize().
+ */
+#define WATCHDOG_INITIALIZER( routine, id, user_data ) \
+  { \
+    { NULL, NULL }, \
+    WATCHDOG_INACTIVE, \
+    0, 0, 0, 0, \
+    ( routine ), ( id ), ( user_data ) \
+  }
+
+/**
  *  @brief the manner in which a watchdog chain may
  *  be adjusted by the @ref _Watchdog_Adjust routine.
  *
diff --git a/testsuites/sptests/spwatchdog/init.c b/testsuites/sptests/spwatchdog/init.c
index a7a332a..6dae9e4 100644
--- a/testsuites/sptests/spwatchdog/init.c
+++ b/testsuites/sptests/spwatchdog/init.c
@@ -24,6 +24,27 @@
 
 #include <rtems/score/watchdogimpl.h>
 
+static void test_watchdog_routine( Objects_Id id, void *arg )
+{
+  (void) id;
+  (void) arg;
+
+  rtems_test_assert( 0 );
+}
+
+static void test_watchdog_static_init( void )
+{
+  Objects_Id id = 0x12345678;
+  void *arg = (void *) 0xdeadbeef;
+  Watchdog_Control a = WATCHDOG_INITIALIZER( test_watchdog_routine, id, arg );
+  Watchdog_Control b;
+
+  memset( &b, 0, sizeof( b ) );
+  _Watchdog_Initialize( &b, test_watchdog_routine, id, arg );
+
+  rtems_test_assert( memcmp( &a, &b, sizeof( a ) ) == 0 );
+}
+
 rtems_task Init(
   rtems_task_argument argument
 )
@@ -35,6 +56,9 @@ rtems_task Init(
    puts( "\n*** RTEMS WATCHDOG ***" );
 
   puts( "INIT - report on empty watchdog chain" );
+
+  test_watchdog_static_init();
+
   _Chain_Initialize_empty( &empty );
   _Watchdog_Report_chain( "Empty Chain", &empty );
 




More information about the vc mailing list