1 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
2 <link rel="stylesheet" href="style.css" type="text/css"/>
3 <script src="code.js" type="text/javascript"></script>
5 <h1>nbdkit tvdiff_usec</h1>
8 <span class="comment">/*@
9 predicate valid_timeval (struct timeval tv) =
10 tv.tv_sec >= 0 && tv.tv_usec >= 0 && tv.tv_usec < 1000000;
11 logic integer tv_to_microseconds (struct timeval tv) =
12 tv.tv_sec * 1000000 + tv.tv_usec;
15 /* Return the number of µs (microseconds) in y - x. */
16 <span class="comment">/*@
17 requires \valid_read (x) && \valid_read (y);
18 requires valid_timeval (*x) && valid_timeval (*y);
19 ensures \result == tv_to_microseconds (*y) - tv_to_microseconds (*x);
22 tvdiff_usec (const struct timeval *x, const struct timeval *y)
26 usec = (y->tv_sec - x->tv_sec) * 1000000;
27 usec += y->tv_usec - x->tv_usec;