| 124 | } |
| 125 | |
| 126 | Timer * |
| 127 | tmr_create(struct timeval *nowP, TimerProc *timer_proc, ClientData client_data, long msecs, int periodic) |
| 128 | { |
| 129 | Timer *t; |
| 130 | |
| 131 | if (free_timers != (Timer *)0) { |
| 132 | t = free_timers; |
| 133 | free_timers = t->next; |
| 134 | } else { |
| 135 | t = (Timer *)malloc(sizeof(Timer)); |
| 136 | if (t == (Timer *)0) |
| 137 | return (Timer *)0; |
| 138 | } |
| 139 | |
| 140 | mstimeout_cache = -1; |
| 141 | t->timer_proc = timer_proc; |
| 142 | t->client_data = client_data; |
| 143 | t->msecs = msecs; |
| 144 | t->periodic = periodic; |
| 145 | if (nowP != (struct timeval *)0) |
| 146 | t->time = *nowP; |
| 147 | else |
| 148 | (void)gettimeofday(&t->time, (struct timezone *)0); |
| 149 | t->time.tv_sec += msecs / 1000L; |
| 150 | t->time.tv_usec += (msecs % 1000L) * 1000L; |
| 151 | if (t->time.tv_usec >= 1000000L) { |
| 152 | t->time.tv_sec += t->time.tv_usec / 1000000L; |
| 153 | t->time.tv_usec %= 1000000L; |
| 154 | } |
| 155 | t->hash = hash(t); |
| 156 | /* Add the new timer to the proper active list. */ |
| 157 | l_add(t); |
| 158 | |
| 159 | return t; |
| 160 | } |
| 161 | |
| 162 | struct timeval * |
| 163 | tmr_timeout(struct timeval *nowP) |
no test coverage detected