summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/timersettime.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2008-08-19 14:45:15 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2008-08-19 14:45:15 +0000
commit753c05ab0263ec6a73bfb96b95d26f4d8b0971e1 (patch)
treeba505f8a67e787fc93b4c30968f1ecc3949539e3 /cpukit/posix/src/timersettime.c
parent2008-08-19 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-753c05ab0263ec6a73bfb96b95d26f4d8b0971e1.tar.bz2
2008-08-19 Tim FitzGeorge <tim.fitzgeorge@astrium.eads.net>
PR 1296/cpukit. * posix/src/timersettime.c: POSIX timers use incorrect repeat interval. This patch fixes the following problems in timer_settime: 1) Uses value.it_interval for repeat period. 2) Corrects test for incorrect value of it_value.tv_nsec (should reject 1000000000).
Diffstat (limited to 'cpukit/posix/src/timersettime.c')
-rw-r--r--cpukit/posix/src/timersettime.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/cpukit/posix/src/timersettime.c b/cpukit/posix/src/timersettime.c
index bbac472aa6..2a4a90e345 100644
--- a/cpukit/posix/src/timersettime.c
+++ b/cpukit/posix/src/timersettime.c
@@ -36,14 +36,17 @@ int timer_settime(
POSIX_Timer_Control *ptimer;
Objects_Locations location;
boolean activated;
+ uint32_t initial_period;
struct itimerspec normalize;
if ( !value )
rtems_set_errno_and_return_minus_one( EINVAL );
/* First, it verifies if the structure "value" is correct */
- if ( ( value->it_value.tv_nsec > TOD_NANOSECONDS_PER_SECOND ) ||
- ( value->it_value.tv_nsec < 0 ) ) {
+ if ( ( value->it_value.tv_nsec >= TOD_NANOSECONDS_PER_SECOND ) ||
+ ( value->it_value.tv_nsec < 0 ) ||
+ ( value->it_interval.tv_nsec >= TOD_NANOSECONDS_PER_SECOND) ||
+ ( value->it_interval.tv_nsec < 0 )) {
/* The number of nanoseconds is not correct */
rtems_set_errno_and_return_minus_one( EINVAL );
}
@@ -57,7 +60,7 @@ int timer_settime(
/* Convert absolute to relative time */
if (flags == TIMER_ABSTIME) {
/* Check for seconds in the past */
- if ( _Timespec_Greater_than( &normalize.it_value, &_TOD_Now ) )
+ if ( _Timespec_Greater_than( &_TOD_Now, &normalize.it_value ) )
rtems_set_errno_and_return_minus_one( EINVAL );
_Timespec_Subtract( &_TOD_Now, &normalize.it_value, &normalize.it_value );
}
@@ -88,11 +91,13 @@ int timer_settime(
}
/* Convert from seconds and nanoseconds to ticks */
- ptimer->ticks = _Timespec_To_ticks( &normalize.it_value );
+ ptimer->ticks = _Timespec_To_ticks( &value->it_interval );
+ initial_period = _Timespec_To_ticks( &normalize.it_value );
+
activated = _POSIX_Timer_Insert_helper(
&ptimer->Timer,
- ptimer->ticks,
+ initial_period,
ptimer->Object.id,
_POSIX_Timer_TSR,
ptimer