diff options
author | jb <jb@FreeBSD.org> | 2006-08-04 23:10:11 +0000 |
---|---|---|
committer | jb <jb@FreeBSD.org> | 2006-08-04 23:10:11 +0000 |
commit | 17d6e198a2b28a42daf3a04ee0727ed063bb9bfd (patch) | |
tree | 527216f31a77e6d74eed860beb4e660597ac7d1b | |
parent | 99c6b9a5861bb5285b27fa675f22eef908acce7b (diff) | |
download | FreeBSD-src-17d6e198a2b28a42daf3a04ee0727ed063bb9bfd.zip FreeBSD-src-17d6e198a2b28a42daf3a04ee0727ed063bb9bfd.tar.gz |
Add some OpenSolaris compatibility definitions which are only visible
if _SOLARIS_C_SOURCE is defined.
Add two function prototypes which are required to feed high-resolution
times to DTrace. DTrace requires it's own functions with the dtrace_
prefix so that it knows not to try and trace them. This is a rule that
code executed from the DTrace probe context must obey.
The two functions are only be compiled if the KDTRACE option is defined
to compile in kernel support for loading the DTrace modules.
-rw-r--r-- | sys/sys/time.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/sys/time.h b/sys/sys/time.h index 657f0d4..359e472 100644 --- a/sys/sys/time.h +++ b/sys/sys/time.h @@ -304,6 +304,8 @@ int ratecheck(struct timeval *, const struct timeval *); void timevaladd(struct timeval *t1, const struct timeval *t2); void timevalsub(struct timeval *t1, const struct timeval *t2); int tvtohz(struct timeval *tv); +uint64_t dtrace_gethrtime(void); +uint64_t dtrace_gethrestime(void); #else /* !_KERNEL */ #include <time.h> @@ -322,4 +324,27 @@ __END_DECLS #endif /* !_KERNEL */ +/* + * Solaris compatibility definitions. + */ +#ifdef _SOLARIS_C_SOURCE +/* + * Definitions for commonly used resolutions. + */ +#define SEC 1 +#define MILLISEC 1000 +#define MICROSEC 1000000 +#define NANOSEC 1000000000 + +typedef longlong_t hrtime_t; + +#ifndef _KERNEL +static __inline hrtime_t gethrtime() { + struct timespec ts; + clock_gettime(CLOCK_UPTIME,&ts); + return (((u_int64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec); +} +#endif +#endif /* _SOLARIS_C_SOURCE */ + #endif /* !_SYS_TIME_H_ */ |