--- hald/freebsd/libprobe/hfp.c.orig 2008-03-17 17:25:17.000000000 -0400 +++ hald/freebsd/libprobe/hfp.c 2008-03-26 12:07:32.000000000 -0400 @@ -216,55 +216,59 @@ hfp_getenv_bool (const char *variable) } void -hfp_gettimeofday (struct timeval *t) +hfp_clock_gettime (struct timespec *t) { int status; assert(t != NULL); - status = gettimeofday(t, NULL); +#ifdef CLOCK_MONOTONIC_FAST + status = clock_gettime(CLOCK_MONOTONIC_FAST, t); +#else + status = clock_gettime(CLOCK_MONOTONIC, t); +#endif assert(status == 0); } -/* timeval functions from sys/kern/kern_time.c */ +/* timespec functions from sys/kern/kern_time.c */ static void -hfp_timevalfix (struct timeval *t) +hfp_timespecfix (struct timespec *t) { assert(t != NULL); - if (t->tv_usec < 0) + if (t->tv_nsec < 0) { t->tv_sec--; - t->tv_usec += 1000000; + t->tv_nsec += 1000000000; } - if (t->tv_usec >= 1000000) + if (t->tv_nsec >= 1000000000) { t->tv_sec++; - t->tv_usec -= 1000000; + t->tv_nsec -= 1000000000; } } void -hfp_timevaladd (struct timeval *t1, const struct timeval *t2) +hfp_timespecadd (struct timespec *t1, const struct timespec *t2) { assert(t1 != NULL); assert(t2 != NULL); t1->tv_sec += t2->tv_sec; - t1->tv_usec += t2->tv_usec; + t1->tv_nsec += t2->tv_nsec; - hfp_timevalfix(t1); + hfp_timespecfix(t1); } void -hfp_timevalsub (struct timeval *t1, const struct timeval *t2) +hfp_timespecsub (struct timespec *t1, const struct timespec *t2) { assert(t1 != NULL); assert(t2 != NULL); t1->tv_sec -= t2->tv_sec; - t1->tv_usec -= t2->tv_usec; + t1->tv_nsec -= t2->tv_nsec; - hfp_timevalfix(t1); + hfp_timespecfix(t1); } --- hald/freebsd/libprobe/hfp.h.orig 2008-03-17 17:25:17.000000000 -0400 +++ hald/freebsd/libprobe/hfp.h 2008-04-02 14:35:50.000000000 -0400 @@ -29,8 +29,12 @@ #endif #include +#include #include +#include +#if __FreeBSD_version < 600000 #include +#endif #include "libhal/libhal.h" @@ -84,14 +88,14 @@ void volume_id_log (const char *format, boolean hfp_getenv_bool (const char *variable); -void hfp_gettimeofday (struct timeval *t); -void hfp_timevaladd (struct timeval *t1, const struct timeval *t2); -void hfp_timevalsub (struct timeval *t1, const struct timeval *t2); +void hfp_clock_gettime (struct timespec *t); +void hfp_timespecadd (struct timespec *t1, const struct timespec *t2); +void hfp_timespecsub (struct timespec *t1, const struct timespec *t2); /* from sys/time.h (_KERNEL) */ -#define hfp_timevalcmp(t1, t2, cmp) \ +#define hfp_timespeccmp(t1, t2, cmp) \ (((t1)->tv_sec == (t2)->tv_sec \ - ? ((t1)->tv_usec cmp (t2)->tv_usec) \ + ? ((t1)->tv_nsec cmp (t2)->tv_nsec) \ : ((t1)->tv_sec cmp (t2)->tv_sec))) #endif /* _HFP_H */