version 1.2, 2006/08/09 21:12:42
|
version 1.3, 2006/11/10 18:14:58
|
|
|
int Time::subtract(timeval* result, timeval* x, timeval* y) | int Time::subtract(timeval* result, timeval* x, timeval* y) |
{ | { |
/* Perform the carry for the later subtraction by updating Y. */ | /* Perform the carry for the later subtraction by updating Y. */ |
if (x->tv_usec < y->tv_usec) { |
if (x->tv_usec < y->tv_usec) |
|
{ |
int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1; | int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1; |
y->tv_usec -= 1000000 * nsec; | y->tv_usec -= 1000000 * nsec; |
y->tv_sec += nsec; | y->tv_sec += nsec; |
} | } |
if (x->tv_usec - y->tv_usec > 1000000) { |
if (x->tv_usec - y->tv_usec > 1000000) |
|
{ |
int nsec = (x->tv_usec - y->tv_usec) / 1000000; | int nsec = (x->tv_usec - y->tv_usec) / 1000000; |
y->tv_usec += 1000000 * nsec; | y->tv_usec += 1000000 * nsec; |
y->tv_sec -= nsec; | y->tv_sec -= nsec; |