Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
timekeeper_internal.h
Go to the documentation of this file.
1 /*
2  * You SHOULD NOT be including this unless you're vsyscall
3  * handling code or timekeeping internal code!
4  */
5 
6 #ifndef _LINUX_TIMEKEEPER_INTERNAL_H
7 #define _LINUX_TIMEKEEPER_INTERNAL_H
8 
9 #include <linux/clocksource.h>
10 #include <linux/jiffies.h>
11 #include <linux/time.h>
12 
13 /* Structure holding internal timekeeping values. */
14 struct timekeeper {
15  /* Current clocksource used for timekeeping. */
16  struct clocksource *clock;
17  /* NTP adjusted clock multiplier */
19  /* The shift value of the current clocksource. */
21  /* Number of clock cycles in one NTP interval. */
23  /* Number of clock shifted nano seconds in one NTP interval. */
25  /* shifted nano seconds left over when rounding cycle_interval */
27  /* Raw nano seconds accumulated per NTP interval. */
29 
30  /* Current CLOCK_REALTIME time in seconds */
32  /* Clock shifted nano seconds */
34 
35  /* Difference between accumulated time and NTP time in ntp
36  * shifted nano seconds. */
38  /* Shift conversion between clock shifted nano seconds and
39  * ntp shifted nano seconds. */
41 
42  /*
43  * wall_to_monotonic is what we need to add to xtime (or xtime corrected
44  * for sub jiffie times) to get to monotonic time. Monotonic is pegged
45  * at zero at system boot time, so wall_to_monotonic will be negative,
46  * however, we will ALWAYS keep the tv_nsec part positive so we can use
47  * the usual normalization.
48  *
49  * wall_to_monotonic is moved after resume from suspend for the
50  * monotonic time not to jump. We need to add total_sleep_time to
51  * wall_to_monotonic to get the real boot based time offset.
52  *
53  * - wall_to_monotonic is no longer the boot time, getboottime must be
54  * used instead.
55  */
57  /* Offset clock monotonic -> clock realtime */
59  /* time spent in suspend */
61  /* Offset clock monotonic -> clock boottime */
63  /* The raw monotonic time for the CLOCK_MONOTONIC_RAW posix clock. */
65  /* Seqlock for all timekeeper values */
67 };
68 
69 static inline struct timespec tk_xtime(struct timekeeper *tk)
70 {
71  struct timespec ts;
72 
73  ts.tv_sec = tk->xtime_sec;
74  ts.tv_nsec = (long)(tk->xtime_nsec >> tk->shift);
75  return ts;
76 }
77 
78 
79 #ifdef CONFIG_GENERIC_TIME_VSYSCALL
80 
81 extern void update_vsyscall(struct timekeeper *tk);
82 extern void update_vsyscall_tz(void);
83 
84 #elif defined(CONFIG_GENERIC_TIME_VSYSCALL_OLD)
85 
86 extern void update_vsyscall_old(struct timespec *ts, struct timespec *wtm,
87  struct clocksource *c, u32 mult);
88 extern void update_vsyscall_tz(void);
89 
90 static inline void update_vsyscall(struct timekeeper *tk)
91 {
92  struct timespec xt;
93 
94  xt = tk_xtime(tk);
95  update_vsyscall_old(&xt, &tk->wall_to_monotonic, tk->clock, tk->mult);
96 }
97 
98 #else
99 
100 static inline void update_vsyscall(struct timekeeper *tk)
101 {
102 }
103 static inline void update_vsyscall_tz(void)
104 {
105 }
106 #endif
107 
108 #endif /* _LINUX_TIMEKEEPER_INTERNAL_H */