/* For both inputs and outputs tv_nsec must be in the range [0, NSEC_PER_SEC). tv_sec may be negative, zero, or positive.  */
void timespec_subtract(struct timespec *amb, const struct timespec *a, const struct timespec *b)
/* For both inputs and outputs tv_nsec must be in the range [0, NSEC_PER_SEC). tv_sec may be negative, zero, or positive.  */
void timespec_subtract(struct timespec *amb, const struct timespec *a, const struct timespec *b)
{
	if (a->tv_nsec >= b->tv_nsec) {
		amb->tv_nsec = a->tv_nsec - b->tv_nsec;
		amb->tv_sec = a->tv_sec - b->tv_sec;
	} else {
		amb->tv_nsec = NSEC_PER_SEC + a->tv_nsec - b->tv_nsec;
		amb->tv_sec = a->tv_sec - b->tv_sec - 1;
	}
}