aboutsummaryrefslogtreecommitdiffstats
path: root/difftimeval.c
blob: 9ba06c53512c4625d75190c9a32993e33454cee5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* See LICENSE file for copyright and license details. */
#include "libsimple.h"


int
libsimple_difftimeval(struct timeval *diff, const struct timeval *minuend, const struct timeval *subtrahend) /* TODO test */
{
	struct timespec a, b, d;
	int r;
	libsimple_timeval2timespec(&a, minuend);
	libsimple_timeval2timespec(&b, subtrahend);
	r = libsimple_difftimespec(&d, &a, &b);
	if (r && errno != ERANGE)
		return r;
	return r | libsimple_timespec2timeval(diff, &d);
}