[rtems commit] posix: Statically init _POSIX_signals_Ualarm_timer
Sebastian Huber
sebh at rtems.org
Mon Jul 22 14:51:44 UTC 2013
Module: rtems
Branch: master
Commit: 43f97f1de96a55deceb474d414a2185fdb07c5ab
Changeset: http://git.rtems.org/rtems/commit/?id=43f97f1de96a55deceb474d414a2185fdb07c5ab
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Jul 22 15:03:04 2013 +0200
posix: Statically init _POSIX_signals_Ualarm_timer
---
cpukit/posix/include/rtems/posix/psignalimpl.h | 2 -
cpukit/posix/src/psignal.c | 7 ---
cpukit/posix/src/ualarm.c | 49 ++++++++++++------------
3 files changed, 24 insertions(+), 34 deletions(-)
diff --git a/cpukit/posix/include/rtems/posix/psignalimpl.h b/cpukit/posix/include/rtems/posix/psignalimpl.h
index 957daf3..7425935 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_Ualarm_timer;
-
extern Thread_queue_Control _POSIX_signals_Wait_queue;
extern Chain_Control _POSIX_signals_Inactive_siginfo;
diff --git a/cpukit/posix/src/psignal.c b/cpukit/posix/src/psignal.c
index 71c5fc9..fc9400d 100644
--- a/cpukit/posix/src/psignal.c
+++ b/cpukit/posix/src/psignal.c
@@ -95,8 +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_Ualarm_timer;
-
/*
* XXX - move these
*/
@@ -229,9 +227,4 @@ void _POSIX_signals_Manager_Initialization(void)
} else {
_Chain_Initialize_empty( &_POSIX_signals_Inactive_siginfo );
}
-
- /*
- * Initialize the Alarm Timer
- */
- _Watchdog_Initialize( &_POSIX_signals_Ualarm_timer, NULL, 0, NULL );
}
diff --git a/cpukit/posix/src/ualarm.c b/cpukit/posix/src/ualarm.c
index 74bfe8f..c893800 100644
--- a/cpukit/posix/src/ualarm.c
+++ b/cpukit/posix/src/ualarm.c
@@ -27,6 +27,14 @@
#include <rtems/posix/psignalimpl.h>
#include <rtems/posix/time.h>
+static void _POSIX_signals_Ualarm_TSR( Objects_Id id, void *argument );
+
+static Watchdog_Control _POSIX_signals_Ualarm_timer = WATCHDOG_INITIALIZER(
+ _POSIX_signals_Ualarm_TSR,
+ 0,
+ NULL
+);
+
/*
* _POSIX_signals_Ualarm_TSR
*/
@@ -56,35 +64,26 @@ useconds_t ualarm(
useconds_t remaining = 0;
Watchdog_Control *the_timer;
Watchdog_Interval ticks;
+ Watchdog_States state;
struct timespec tp;
the_timer = &_POSIX_signals_Ualarm_timer;
- /*
- * Initialize the timer used to implement alarm().
- */
-
- if ( !the_timer->routine ) {
- _Watchdog_Initialize( the_timer, _POSIX_signals_Ualarm_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.
- */
-
- ticks = the_timer->initial;
- ticks -= (the_timer->stop_time - the_timer->start_time);
- /* remaining is now in ticks */
-
- _Timespec_From_ticks( ticks, &tp );
- remaining = tp.tv_sec * TOD_MICROSECONDS_PER_SECOND;
- remaining += tp.tv_nsec / 1000;
- }
+ 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.
+ */
+
+ ticks = the_timer->initial;
+ ticks -= (the_timer->stop_time - the_timer->start_time);
+ /* remaining is now in ticks */
+
+ _Timespec_From_ticks( ticks, &tp );
+ remaining = tp.tv_sec * TOD_MICROSECONDS_PER_SECOND;
+ remaining += tp.tv_nsec / 1000;
}
/*
More information about the vc
mailing list