Changeset 77e6eba7 in rtems for cpukit/posix/src/timersettime.c


Ignore:
Timestamp:
Mar 7, 2016, 3:01:57 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
62d2540
Parents:
5e368e84
git-author:
Sebastian Huber <sebastian.huber@…> (03/07/16 15:01:57)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/14/16 08:06:27)
Message:

score: Add and use _Objects_Get_local()

This simplifies the handling with local-only objects.

Update #2555.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/src/timersettime.c

    r5e368e84 r77e6eba7  
    108108{
    109109  POSIX_Timer_Control *ptimer;
    110   Objects_Locations    location;
    111110  ISR_lock_Context     lock_context;
    112   Per_CPU_Control     *cpu;
    113111  uint32_t             initial_period;
    114112  struct itimerspec    normalize;
     
    149147   */
    150148
    151   ptimer = _POSIX_Timer_Get( timerid, &location, &lock_context );
    152   switch ( location ) {
     149  ptimer = _POSIX_Timer_Get( timerid, &lock_context );
     150  if ( ptimer != NULL ) {
     151    Per_CPU_Control *cpu;
    153152
    154     case OBJECTS_LOCAL:
    155       cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
     153    cpu = _POSIX_Timer_Acquire_critical( ptimer, &lock_context );
    156154
    157       /* Stop the timer */
    158       _Watchdog_Remove(
    159         &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
    160         &ptimer->Timer
    161       );
     155    /* Stop the timer */
     156    _Watchdog_Remove(
     157      &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_RELATIVE ],
     158      &ptimer->Timer
     159    );
    162160
    163       /* First, it verifies if the timer must be stopped */
    164       if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) {
    165         /* The old data of the timer are returned */
    166         if ( ovalue )
    167           *ovalue = ptimer->timer_data;
    168         /* The new data are set */
    169         ptimer->timer_data = normalize;
    170         /* Indicates that the timer is created and stopped */
    171         ptimer->state = POSIX_TIMER_STATE_CREATE_STOP;
    172         /* Returns with success */
    173         _POSIX_Timer_Release( cpu, &lock_context );
    174         return 0;
    175       }
    176 
    177       /* Convert from seconds and nanoseconds to ticks */
    178       ptimer->ticks  = _Timespec_To_ticks( &value->it_interval );
    179       initial_period = _Timespec_To_ticks( &normalize.it_value );
    180 
    181       _POSIX_Timer_Insert( ptimer, cpu, initial_period );
    182 
    183       /*
    184        * The timer has been started and is running.  So we return the
    185        * old ones in "ovalue"
    186        */
     161    /* First, it verifies if the timer must be stopped */
     162    if ( normalize.it_value.tv_sec == 0 && normalize.it_value.tv_nsec == 0 ) {
     163      /* The old data of the timer are returned */
    187164      if ( ovalue )
    188165        *ovalue = ptimer->timer_data;
     166      /* The new data are set */
    189167      ptimer->timer_data = normalize;
     168      /* Indicates that the timer is created and stopped */
     169      ptimer->state = POSIX_TIMER_STATE_CREATE_STOP;
     170      /* Returns with success */
    190171      _POSIX_Timer_Release( cpu, &lock_context );
    191172      return 0;
     173    }
    192174
    193 #if defined(RTEMS_MULTIPROCESSING)
    194     case OBJECTS_REMOTE:
    195 #endif
    196     case OBJECTS_ERROR:
    197       break;
     175    /* Convert from seconds and nanoseconds to ticks */
     176    ptimer->ticks  = _Timespec_To_ticks( &value->it_interval );
     177    initial_period = _Timespec_To_ticks( &normalize.it_value );
     178
     179    _POSIX_Timer_Insert( ptimer, cpu, initial_period );
     180
     181    /*
     182     * The timer has been started and is running.  So we return the
     183     * old ones in "ovalue"
     184     */
     185    if ( ovalue )
     186      *ovalue = ptimer->timer_data;
     187    ptimer->timer_data = normalize;
     188    _POSIX_Timer_Release( cpu, &lock_context );
     189    return 0;
    198190  }
    199191
Note: See TracChangeset for help on using the changeset viewer.