/* Note: The tv_nsec part is always in the range of 0 <= tv_nsec < NSEC_PER_SEC For negative values only the tv_sec field is negative !  */
void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec)
/* Note: The tv_nsec part is always in the range of 0 <= tv_nsec < NSEC_PER_SEC For negative values only the tv_sec field is negative !  */
void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec)
{
	while (nsec >= NSEC_PER_SEC) {
		asm("" : "+rm"(nsec));
		nsec -= NSEC_PER_SEC;
		++sec;
	}
	while (nsec < 0) {
		asm("" : "+rm"(nsec));
		nsec += NSEC_PER_SEC;
		--sec;
	}
	ts->tv_sec = sec;
	ts->tv_nsec = nsec;
}