aboutsummaryrefslogblamecommitdiffstats
path: root/difftimeval.c
blob: b4c34512fddf1c579b9b44fe973abd342ecf09cb (plain) (tree)
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)
{
	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);
}