src/timer.c
changeset 629 b9274b595650
parent 576 b4bc22764a39
child 801 32d146b64a35
equal deleted inserted replaced
628:9e496a2aadca 629:b9274b595650
   122 {
   122 {
   123 	TIMER_HANDLE i;
   123 	TIMER_HANDLE i;
   124 	TIMEVAL next_wakeup = TIMEVAL_MAX; /* used to compute when should normaly occur next wakeup */
   124 	TIMEVAL next_wakeup = TIMEVAL_MAX; /* used to compute when should normaly occur next wakeup */
   125 	/* First run : change timer state depending on time */
   125 	/* First run : change timer state depending on time */
   126 	/* Get time since timer signal */
   126 	/* Get time since timer signal */
   127 	TIMEVAL overrun = getElapsedTime();
   127 	UNS32 overrun = (UNS32)getElapsedTime();
   128 
   128 
   129 	TIMEVAL real_total_sleep_time = total_sleep_time + overrun;
   129 	TIMEVAL real_total_sleep_time = total_sleep_time + overrun;
   130 
   130 
   131 	s_timer_entry *row;
   131 	s_timer_entry *row;
   132 
   132 
   140 				{
   140 				{
   141 					row->state = TIMER_TRIG; /* ask for trig */
   141 					row->state = TIMER_TRIG; /* ask for trig */
   142 				}
   142 				}
   143 				else /* or period have expired */
   143 				else /* or period have expired */
   144 				{
   144 				{
   145 					/* set val as interval, with overrun correction */
   145 					/* set val as interval, with 32 bit overrun correction, */
   146 					row->val = row->interval - (overrun % row->interval);
   146 					/* modulo for 64 bit not available on all platforms     */
       
   147 					row->val = row->interval - (overrun % (UNS32)row->interval);
   147 					row->state = TIMER_TRIG_PERIOD; /* ask for trig, periodic */
   148 					row->state = TIMER_TRIG_PERIOD; /* ask for trig, periodic */
   148 					/* Check if this new timer value is the soonest */
   149 					/* Check if this new timer value is the soonest */
   149 					if(row->val < next_wakeup)
   150 					if(row->val < next_wakeup)
   150 						next_wakeup = row->val;
   151 						next_wakeup = row->val;
   151 				}
   152 				}