2 * Copyright (C) 2005-2010 Andre Noll <maan@tuebingen.mpg.de>
4 * Licensed under the GPL v2. For licencing details see COPYING.
13 #include "gcc-compat.h"
20 * Compute the difference of two time values.
23 * \param a Subtrahend.
24 * \param diff Result pointer.
26 * If \a diff is not \p NULL, it contains the absolute value |\a b - \a a| on
29 * \return If \a b < \a a, this function returns -1, otherwise it returns 1.
31 int tv_diff(const struct timeval *b, const struct timeval *a, struct timeval *diff)
35 if ((b->tv_sec < a->tv_sec) ||
36 ((b->tv_sec == a->tv_sec) && (b->tv_usec < a->tv_usec))) {
37 const struct timeval *tmp = a;
44 diff->tv_sec = b->tv_sec - a->tv_sec;
45 if (b->tv_usec < a->tv_usec) {
47 diff->tv_usec = 1000 * 1000 - a->tv_usec + b->tv_usec;
49 diff->tv_usec = b->tv_usec - a->tv_usec;
53 int64_t get_current_time(void)
57 DSS_DEBUG_LOG(("now: %jd\n", (intmax_t)now));