64  */
  65 
  66 void 
  67 catch_alarm(int sig)
  68 {
  69         elapsed++;
  70         /* be sure to NOT call DBG in asynchronous handlers! */
  71 }
  72 
  73 void 
  74 initTimer(void)
  75 {
  76         struct itimerval itimer;
  77 
  78         DBG("initTimer\n");
  79 
  80         signal(SIGALRM, SIG_IGN);
  81 
  82         elapsed = 0;
  83         itimer.it_value.tv_sec = itimer.it_interval.tv_sec = 0;
  84         itimer.it_value.tv_usec = itimer.it_interval.tv_usec = US_TIMER_INTERVAL;
  85 
  86         signal(SIGALRM, catch_alarm);
  87         setitimer(ITIMER_REAL, &itimer, 0);
  88 }
  89 
  90 void 
  91 timerUpdate(IntervalTimer * itimer)
  92 {
  93 
  94         int i, delta;
  95 
  96         /*
  97          * latch how many ticks we got since we were last called
  98          * remember that catch_alarm() is totally asynchronous to this timerUpdate()
  99          */
 100         delta = elapsed;
 101         elapsed = 0;
 102 
 103         if (delta <= 0)
 104                 return;
 105 
 106         /*
 
 | 
 
 
  64  */
  65 
  66 void 
  67 catch_alarm(int sig)
  68 {
  69         elapsed++;
  70         /* be sure to NOT call DBG in asynchronous handlers! */
  71 }
  72 
  73 void 
  74 initTimer(void)
  75 {
  76         struct itimerval itimer;
  77 
  78         DBG("initTimer\n");
  79 
  80         signal(SIGALRM, SIG_IGN);
  81 
  82         elapsed = 0;
  83         itimer.it_value.tv_sec = itimer.it_interval.tv_sec = 0;
  84         itimer.it_value.tv_usec = itimer.it_interval.tv_usec =
  85             US_TIMER_INTERVAL;
  86 
  87 #ifdef __sun
  88         sigset(SIGALRM, catch_alarm);
  89 #else
  90         signal(SIGALRM, catch_alarm);
  91 #endif
  92         setitimer(ITIMER_REAL, &itimer, 0);
  93 }
  94 
  95 void 
  96 timerUpdate(IntervalTimer * itimer)
  97 {
  98 
  99         int i, delta;
 100 
 101         /*
 102          * latch how many ticks we got since we were last called
 103          * remember that catch_alarm() is totally asynchronous to this timerUpdate()
 104          */
 105         delta = elapsed;
 106         elapsed = 0;
 107 
 108         if (delta <= 0)
 109                 return;
 110 
 111         /*
 
 |