From 753c05ab0263ec6a73bfb96b95d26f4d8b0971e1 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 19 Aug 2008 14:45:15 +0000 Subject: 2008-08-19 Tim FitzGeorge 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). --- cpukit/posix/src/timersettime.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'cpukit/posix/src/timersettime.c') 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 -- cgit v1.2.3