219
hfp_gettimeofday (struct timeval *t)
219
hfp_clock_gettime (struct timespec *t)
223
223
assert(t != NULL);
225
status = gettimeofday(t, NULL);
225
#ifdef CLOCK_MONOTONIC_FAST
226
status = clock_gettime(CLOCK_MONOTONIC_FAST, t);
228
status = clock_gettime(CLOCK_MONOTONIC, t);
226
230
assert(status == 0);
229
/* timeval functions from sys/kern/kern_time.c */
233
/* timespec functions from sys/kern/kern_time.c */
232
hfp_timevalfix (struct timeval *t)
236
hfp_timespecfix (struct timespec *t)
234
238
assert(t != NULL);
239
t->tv_usec += 1000000;
243
t->tv_nsec += 1000000000;
241
if (t->tv_usec >= 1000000)
245
if (t->tv_nsec >= 1000000000)
244
t->tv_usec -= 1000000;
248
t->tv_nsec -= 1000000000;
249
hfp_timevaladd (struct timeval *t1, const struct timeval *t2)
253
hfp_timespecadd (struct timespec *t1, const struct timespec *t2)
251
255
assert(t1 != NULL);
252
256
assert(t2 != NULL);
254
258
t1->tv_sec += t2->tv_sec;
255
t1->tv_usec += t2->tv_usec;
259
t1->tv_nsec += t2->tv_nsec;
261
hfp_timevalsub (struct timeval *t1, const struct timeval *t2)
265
hfp_timespecsub (struct timespec *t1, const struct timespec *t2)
263
267
assert(t1 != NULL);
264
268
assert(t2 != NULL);
266
270
t1->tv_sec -= t2->tv_sec;
267
t1->tv_usec -= t2->tv_usec;
271
t1->tv_nsec -= t2->tv_nsec;