2 * UCW Library -- A Simple Millisecond Timer
4 * (c) 2007 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
20 gettimeofday(&tv, NULL);
21 return (timestamp_t)tv.tv_sec * 1000 + tv.tv_usec / 1000;
25 init_timer(timestamp_t *timer)
27 *timer = get_timestamp();
31 get_timer(timestamp_t *timer)
33 timestamp_t t = *timer;
34 *timer = get_timestamp();
35 return MIN(*timer-t, ~0U);
39 switch_timer(timestamp_t *old, timestamp_t *new)
41 *new = get_timestamp();
42 return MIN(*new-*old, ~0U);