aboutsummaryrefslogblamecommitdiffstats
path: root/sumtimeval.c
blob: 409500dcca12e344dabf8f396cffd7c1302d7a92 (plain) (tree)
1
2
3
4
5
6




                                                         
                                                                                                                     









                                                       
/* 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) /* TODO test */
{
	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);
}