aboutsummaryrefslogblamecommitdiffstats
path: root/sumtimeval.c
blob: 04746aa58a2d08c405177fc0e6a221d1195ac7c0 (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_sumtimeval(struct timeval *sum, const struct timeval *augend, const struct timeval *addend)
{
	struct timespec a, b, s;
	int r;
	libsimple_timeval2timespec(&a, augend);
	libsimple_timeval2timespec(&b, addend);
	r = libsimple_sumtimespec(&s, &a, &b);
	if (r && errno != ERANGE)
		return r;
	return r | libsimple_timespec2timeval(sum, &s);
}