1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

lib/util: add nsec_time_diff to calulate diffs from timespecs

This commit is contained in:
Björn Jacke 2010-08-30 17:56:37 +02:00
parent 0ca6a73d01
commit 73ad77f20a
2 changed files with 14 additions and 0 deletions

View File

@ -409,6 +409,15 @@ _PUBLIC_ int64_t usec_time_diff(const struct timeval *tv1, const struct timeval
return (sec_diff * 1000000) + (int64_t)(tv1->tv_usec - tv2->tv_usec);
}
/**
return (tp1 - tp2) in microseconds
*/
_PUBLIC_ int64_t nsec_time_diff(const struct timespec *tp1, const struct timespec *tp2)
{
int64_t sec_diff = tp1->tv_sec - tp2->tv_sec;
return (sec_diff * 1000000000) + (int64_t)(tp1->tv_nsec - tp2->tv_nsec);
}
/**
return a zero timeval

View File

@ -148,6 +148,11 @@ _PUBLIC_ NTTIME nttime_from_string(const char *s);
*/
_PUBLIC_ int64_t usec_time_diff(const struct timeval *tv1, const struct timeval *tv2);
/**
return (tp1 - tp2) in nanoseconds
*/
_PUBLIC_ int64_t nsec_time_diff(const struct timespec *tp1, const struct timespec *tp2);
/**
return a zero timeval
*/