summaryrefslogtreecommitdiff
path: root/tools/time_ms.h
blob: 1bbd129f32ea76feca2ebdd401244afa2701bdcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * time_ms.h: simple current time interface
 *
 * See the main source file 'xineliboutput.c' for copyright information and
 * how to reach the author.
 *
 * $Id: time_ms.h,v 1.2 2012-03-20 09:10:33 phintuka Exp $
 *
 */

#ifndef XINELIBOUTPUT_TIME_MS_H_
#define XINELIBOUTPUT_TIME_MS_H_

#include <sys/time.h>

static uint64_t time_ms(void)
{
  struct timeval t;
#ifdef XINEUTILS_H
  if (xine_monotonic_clock(&t, NULL) == 0)
#else
  if (gettimeofday(&t, NULL) == 0)
#endif
     return ((uint64_t)t.tv_sec) * 1000ULL + t.tv_usec / 1000ULL;
  return 0;
}

static uint64_t elapsed(uint64_t t)
{
  return time_ms() - t;
}

#endif /* XINELIBOUTPUT_TIME_MS_H_ */