]> git.proxmox.com Git - mirror_spl.git/blob - modules/spl/spl-time.c
c12c3d9bb2ae42e4e5f8dfa542ffddc67214430e
[mirror_spl.git] / modules / spl / spl-time.c
1 #include <sys/sysmacros.h>
2 #include <sys/time.h>
3 #include "config.h"
4
5 #ifdef DEBUG_SUBSYSTEM
6 #undef DEBUG_SUBSYSTEM
7 #endif
8
9 #define DEBUG_SUBSYSTEM S_TIME
10
11 void
12 __gethrestime(timestruc_t *ts)
13 {
14 getnstimeofday((struct timespec *)ts);
15 }
16 EXPORT_SYMBOL(__gethrestime);
17
18 int
19 __clock_gettime(clock_type_t type, timespec_t *tp)
20 {
21 /* Only support CLOCK_REALTIME+__CLOCK_REALTIME0 for now */
22 ASSERT((type == CLOCK_REALTIME) || (type == __CLOCK_REALTIME0));
23
24 getnstimeofday(tp);
25 return 0;
26 }
27 EXPORT_SYMBOL(__clock_gettime);
28
29 /* This function may not be as fast as using monotonic_clock() but it
30 * should be much more portable, if performance becomes as issue we can
31 * look at using monotonic_clock() for x86_64 and x86 arches.
32 */
33 hrtime_t
34 __gethrtime(void) {
35 timespec_t tv;
36 hrtime_t rc;
37
38 do_posix_clock_monotonic_gettime(&tv);
39 rc = (NSEC_PER_SEC * (hrtime_t)tv.tv_sec) + (hrtime_t)tv.tv_nsec;
40
41 return rc;
42 }
43 EXPORT_SYMBOL(__gethrtime);