diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-07 16:01:57 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-03-14 09:06:27 +0100 |
commit | 77e6eba7146ba2e2074b719eec01cc7c40bbe98b (patch) | |
tree | ec87c51ccd9c53cb65067a2a06a75d29b32387f3 /cpukit/posix/src/timersettime.c | |
parent | pc386: Fix linker usage issues with -r and function sections (diff) | |
download | rtems-77e6eba7146ba2e2074b719eec01cc7c40bbe98b.tar.bz2 |
score: Add and use _Objects_Get_local()
This simplifies the handling with local-only objects.
Update #2555.
Diffstat (limited to 'cpukit/posix/src/timersettime.c')
-rw-r--r-- | cpukit/posix/src/timersettime.c | 78 |
1 files changed, 35 insertions, 43 deletions
diff --git a/cpukit/posix/src/timersettime.c b/cpukit/posix/src/timersettime.c index ac5c258eda..51678ca5cb 100644 --- a/cpukit/posix/src/timersettime.c +++ b/cpukit/posix/src/timersettime.c @@ -107,9 +107,7 @@ int timer_settime( ) { POSIX_Timer_Control *ptimer; - Objects_Locations location; ISR_lock_Context lock_context; - Per_CPU_Control *cpu; uint32_t initial_period; struct itimerspec normalize; @@ -148,53 +146,47 @@ int timer_settime( * or start it again */ - ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context ); - switch ( location ) { - - case OBJECTS_LOCAL: - cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context ); - - /* Stop the timer */ - _Watchdog_Remove( - &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ], - &ptimer->Timer - ); - - /* First, it verifies if the timer must be stopped */ - if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) { - /* The old data of the timer are returned */ - if ( ovalue ) - *ovalue = ptimer->timer_data; - /* The new data are set */ - ptimer->timer_data = normalize; - /* Indicates that the timer is created and stopped */ - ptimer->state = POSIX_TIMER_STATE_CREATE_STOP; - /* Returns with success */ - _POSIX_Timer_Release( cpu, &lock_context ); - return 0; - } - - /* Convert from seconds and nanoseconds to ticks */ - ptimer->ticks = _Timespec_To_ticks( &value->it_interval ); - initial_period = _Timespec_To_ticks( &normalize.it_value ); - - _POSIX_Timer_Insert( ptimer, cpu, initial_period ); - - /* - * The timer has been started and is running. So we return the - * old ones in "ovalue" - */ + ptimer = _POSIX_Timer_Get( timerid, &lock_context ); + if ( ptimer != NULL ) { + Per_CPU_Control *cpu; + + cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context ); + + /* Stop the timer */ + _Watchdog_Remove( + &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ], + &ptimer->Timer + ); + + /* First, it verifies if the timer must be stopped */ + if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) { + /* The old data of the timer are returned */ if ( ovalue ) *ovalue = ptimer->timer_data; + /* The new data are set */ ptimer->timer_data = normalize; + /* Indicates that the timer is created and stopped */ + ptimer->state = POSIX_TIMER_STATE_CREATE_STOP; + /* Returns with success */ _POSIX_Timer_Release( cpu, &lock_context ); return 0; + } -#if defined(RTEMS_MULTIPROCESSING) - case OBJECTS_REMOTE: -#endif - case OBJECTS_ERROR: - break; + /* Convert from seconds and nanoseconds to ticks */ + ptimer->ticks = _Timespec_To_ticks( &value->it_interval ); + initial_period = _Timespec_To_ticks( &normalize.it_value ); + + _POSIX_Timer_Insert( ptimer, cpu, initial_period ); + + /* + * The timer has been started and is running. So we return the + * old ones in "ovalue" + */ + if ( ovalue ) + *ovalue = ptimer->timer_data; + ptimer->timer_data = normalize; + _POSIX_Timer_Release( cpu, &lock_context ); + return 0; } rtems_set_errno_and_return_minus_one( EINVAL ); |