Return microseconds instead of nanoseconds. Also return value is now
delta from the first call to gettime instead of the absolute value of
the monotonic clock.
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
/* Return time in microseconds */
-static unsigned long long gettime(void)
+static unsigned long gettime(void)
{
struct timespec tp;
- unsigned long long ret;
+ unsigned long ret;
+ static unsigned long start = 0;
clock_gettime(CLOCK_MONOTONIC, &tp);
ret = tp.tv_sec * 1000 * 1000;
- ret += tp.tv_nsec;
+ ret += tp.tv_nsec / 1000;
- return ret;
+ if (!start)
+ start = ret;
+
+ return ret - start;
}
static int poll_events(SDL_Surface **screen, struct camera *cam,