Andreas Eversberg wrote:
+/* add sec,usec to tv */ +static void tv_add(struct timeval *tv, int sec, int usec) +{
- if (usec < 0)
usec += USEC_1S;
Doesn't this also need to do sec--; ?
- tv->tv_sec += sec;
- tv->tv_usec += usec;
- if (tv->tv_usec >= USEC_1S) {
tv->tv_sec++;tv->tv_usec -= USEC_1S;- }
+}
Consider changing the second if() to while(), so that the function works correctly also when adding several seconds using only the usec parameter.
Very nice use of defines! They make for excellent readability.
//Peter