diff --git a/sys/cddl/compat/opensolaris/sys/time.h b/sys/cddl/compat/opensolaris/sys/time.h index 94d24a52f6a..770b2516319 100644 --- a/sys/cddl/compat/opensolaris/sys/time.h +++ b/sys/cddl/compat/opensolaris/sys/time.h @@ -31,9 +31,17 @@ #include_next +#define SEC 1 +#define MILLISEC 1000 +#define MICROSEC 1000000 +#define NANOSEC 1000000000 + +typedef longlong_t hrtime_t; + +#define LBOLT ((gethrtime() * hz) / NANOSEC) + #ifdef _KERNEL -#define lbolt ((gethrtime() * hz) / NANOSEC) -#define lbolt64 (int64_t)(lbolt) +#define lbolt64 (int64_t)(LBOLT) static __inline hrtime_t gethrtime(void) { @@ -53,6 +61,15 @@ gethrtime(void) { #define gethrestime_sec() (time_second) #define gethrestime(ts) getnanotime(ts) +#else + +static __inline hrtime_t gethrtime(void) { + struct timespec ts; + clock_gettime(CLOCK_UPTIME,&ts); + return (((u_int64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec); +} + + #endif /* _KERNEL */ #endif /* !_OPENSOLARIS_SYS_TIME_H_ */ diff --git a/sys/compat/opensolaris/sys/time.h b/sys/compat/opensolaris/sys/time.h index 94d24a52f6a..770b2516319 100644 --- a/sys/compat/opensolaris/sys/time.h +++ b/sys/compat/opensolaris/sys/time.h @@ -31,9 +31,17 @@ #include_next +#define SEC 1 +#define MILLISEC 1000 +#define MICROSEC 1000000 +#define NANOSEC 1000000000 + +typedef longlong_t hrtime_t; + +#define LBOLT ((gethrtime() * hz) / NANOSEC) + #ifdef _KERNEL -#define lbolt ((gethrtime() * hz) / NANOSEC) -#define lbolt64 (int64_t)(lbolt) +#define lbolt64 (int64_t)(LBOLT) static __inline hrtime_t gethrtime(void) { @@ -53,6 +61,15 @@ gethrtime(void) { #define gethrestime_sec() (time_second) #define gethrestime(ts) getnanotime(ts) +#else + +static __inline hrtime_t gethrtime(void) { + struct timespec ts; + clock_gettime(CLOCK_UPTIME,&ts); + return (((u_int64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec); +} + + #endif /* _KERNEL */ #endif /* !_OPENSOLARIS_SYS_TIME_H_ */