[rtems commit] posix: Statically init _POSIX_signals_Alarm_timer

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


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Jul 22 13:48:51 2013 +0200

posix: Statically init _POSIX_signals_Alarm_timer

---

 cpukit/posix/include/rtems/posix/psignalimpl.h |    2 -
 cpukit/posix/src/alarm.c                       |   35 +++++++++++-------------
 cpukit/posix/src/psignal.c                     |    2 -
 3 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/psignalimpl.h b/cpukit/posix/include/rtems/posix/psignalimpl.h
index 481a7ea..957daf3 100644
--- a/cpukit/posix/include/rtems/posix/psignalimpl.h
+++ b/cpukit/posix/include/rtems/posix/psignalimpl.h
@@ -59,8 +59,6 @@ extern const struct sigaction _POSIX_signals_Default_vectors[ SIG_ARRAY_MAX ];
 
 extern struct sigaction _POSIX_signals_Vectors[ SIG_ARRAY_MAX ];
 
-extern Watchdog_Control _POSIX_signals_Alarm_timer;
-
 extern Watchdog_Control _POSIX_signals_Ualarm_timer;
 
 extern Thread_queue_Control _POSIX_signals_Wait_queue;
diff --git a/cpukit/posix/src/alarm.c b/cpukit/posix/src/alarm.c
index 190a7fb..c671b9e 100644
--- a/cpukit/posix/src/alarm.c
+++ b/cpukit/posix/src/alarm.c
@@ -41,35 +41,32 @@ static void _POSIX_signals_Alarm_TSR(
   /* XXX can't print from an ISR, should this be fatal? */
 }
 
+static Watchdog_Control _POSIX_signals_Alarm_timer = WATCHDOG_INITIALIZER(
+  _POSIX_signals_Alarm_TSR,
+  0,
+  NULL
+);
+
 unsigned int alarm(
   unsigned int seconds
 )
 {
   unsigned int      remaining = 0;
   Watchdog_Control *the_timer;
+  Watchdog_States   state;
 
   the_timer = &_POSIX_signals_Alarm_timer;
 
-  /*
-   *  Initialize the timer used to implement alarm().
-   */
-
-  if ( !the_timer->routine ) {
-    _Watchdog_Initialize( the_timer, _POSIX_signals_Alarm_TSR, 0, NULL );
-  } else {
-    Watchdog_States state;
-
-    state = _Watchdog_Remove( the_timer );
-    if ( (state == WATCHDOG_ACTIVE) || (state == WATCHDOG_REMOVE_IT) ) {
-      /*
-       *  The stop_time and start_time fields are snapshots of ticks since
-       *  boot.  Since alarm() is dealing in seconds, we must account for
-       *  this.
-       */
+  state = _Watchdog_Remove( the_timer );
+  if ( (state == WATCHDOG_ACTIVE) || (state == WATCHDOG_REMOVE_IT) ) {
+    /*
+     *  The stop_time and start_time fields are snapshots of ticks since
+     *  boot.  Since alarm() is dealing in seconds, we must account for
+     *  this.
+     */
 
-      remaining = the_timer->initial -
-        ((the_timer->stop_time - the_timer->start_time) / TOD_TICKS_PER_SECOND);
-    }
+    remaining = the_timer->initial -
+      ((the_timer->stop_time - the_timer->start_time) / TOD_TICKS_PER_SECOND);
   }
 
   if ( seconds )
diff --git a/cpukit/posix/src/psignal.c b/cpukit/posix/src/psignal.c
index a8f1a28..71c5fc9 100644
--- a/cpukit/posix/src/psignal.c
+++ b/cpukit/posix/src/psignal.c
@@ -95,7 +95,6 @@ Thread_queue_Control _POSIX_signals_Wait_queue;
 Chain_Control _POSIX_signals_Inactive_siginfo;
 Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ];
 
-Watchdog_Control _POSIX_signals_Alarm_timer;
 Watchdog_Control _POSIX_signals_Ualarm_timer;
 
 /*
@@ -234,6 +233,5 @@ void _POSIX_signals_Manager_Initialization(void)
   /*
    *  Initialize the Alarm Timer
    */
-  _Watchdog_Initialize( &_POSIX_signals_Alarm_timer, NULL, 0, NULL );
   _Watchdog_Initialize( &_POSIX_signals_Ualarm_timer, NULL, 0, NULL );
 }




More information about the vc mailing list