Commit 4ad9b25e authored by David Lawrence's avatar David Lawrence
Browse files

new function isc_time_microdiff

parent d3e7d196
......@@ -184,6 +184,16 @@ isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result);
* t >= epoch + i (comparing times, not pointers)
*/
isc_uint64_t
isc_time_microdiff(isc_time_t *t1, isc_time_t *t2) {
/*
* Find the difference in milliseconds between time t1 and time t2.
* t2 is the subtrahend of t1; ie, difference = t1 - t2.
*
* Requires:
* No formal requirements are asserted.
*/
ISC_LANG_ENDDECLS
#endif /* ISC_TIME_H */
......@@ -205,3 +205,25 @@ isc_time_subtract(isc_time_t *t, isc_interval_t *i, isc_time_t *result) {
result->seconds--;
}
}
isc_uint64_t
isc_time_microdiff(isc_time_t *t1, isc_time_t *t2) {
isc_uint64_t i1, i2, i3;
REQUIRE(t1 != NULL && t2 != NULL);
i1 = t1->seconds * 1000000000 + t1->nanoseconds;
i2 = t2->seconds * 1000000000 + t2->nanoseconds;
if (i1 <= i2)
return (0);
i3 = i1 - i2;
/*
* Convert to microseconds.
*/
i3 = (i1 - i2) / 10000;
return (i3);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment