]> git.proxmox.com Git - mirror_spl-debian.git/blob - include/sys/time.h
Reorganize /include/ to add a /sys/, this way we don't need to
[mirror_spl-debian.git] / include / sys / time.h
1 #ifndef _SPL_TIME_H
2 #define _SPL_TIME_H
3
4 /*
5 * Structure returned by gettimeofday(2) system call,
6 * and used in other calls.
7 */
8
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12
13 #include <linux/module.h>
14 #include <linux/time.h>
15 #include <sys/types.h>
16
17 extern unsigned long long monotonic_clock(void);
18 typedef struct timespec timestruc_t; /* definition per SVr4 */
19 typedef longlong_t hrtime_t;
20
21 #define TIME32_MAX INT32_MAX
22 #define TIME32_MIN INT32_MIN
23
24 #define SEC 1
25 #define MILLISEC 1000
26 #define MICROSEC 1000000
27 #define NANOSEC 1000000000
28
29 #define hz \
30 ({ \
31 BUG_ON(HZ < 100 || HZ > MICROSEC); \
32 HZ; \
33 })
34
35 #define gethrestime(ts) getnstimeofday((ts))
36
37 static __inline__ hrtime_t
38 gethrtime(void) {
39 /* BUG_ON(cur_timer == timer_none); */
40
41 /* Solaris expects a long long here but monotonic_clock() returns an
42 * unsigned long long. Note that monotonic_clock() returns the number
43 * of nanoseconds passed since kernel initialization. Even for a signed
44 * long long this will not "go negative" for ~292 years.
45 */
46 return monotonic_clock();
47 }
48
49 static __inline__ time_t
50 gethrestime_sec(void)
51 {
52 timestruc_t now;
53
54 gethrestime(&now);
55 return (now.tv_sec);
56 }
57
58
59 #ifdef __cplusplus
60 }
61 #endif
62
63 #endif /* _SPL_TIME_H */