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