diff options
Diffstat (limited to 'include/linux/time.h')
-rw-r--r-- | include/linux/time.h | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/include/linux/time.h b/include/linux/time.h index ea3559f0b3f2..9f15ac7ab92a 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
@@ -38,7 +38,7 @@ extern struct timezone sys_tz; | |||
38 | #define NSEC_PER_MSEC 1000000L | 38 | #define NSEC_PER_MSEC 1000000L |
39 | #define USEC_PER_SEC 1000000L | 39 | #define USEC_PER_SEC 1000000L |
40 | #define NSEC_PER_SEC 1000000000L | 40 | #define NSEC_PER_SEC 1000000000L |
41 | #define FSEC_PER_SEC 1000000000000000L | 41 | #define FSEC_PER_SEC 1000000000000000LL |
42 | 42 | ||
43 | #define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1) | 43 | #define TIME_T_MAX (time_t)((1UL << ((sizeof(time_t) << 3) - 1)) - 1) |
44 | 44 | ||
@@ -76,9 +76,25 @@ extern unsigned long mktime(const unsigned int year, const unsigned int mon, | |||
76 | const unsigned int min, const unsigned int sec); | 76 | const unsigned int min, const unsigned int sec); |
77 | 77 | ||
78 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); | 78 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); |
79 | |||
80 | /* | ||
81 | * timespec_add_safe assumes both values are positive and checks | ||
82 | * for overflow. It will return TIME_T_MAX if the reutrn would be | ||
83 | * smaller then either of the arguments. | ||
84 | */ | ||
79 | extern struct timespec timespec_add_safe(const struct timespec lhs, | 85 | extern struct timespec timespec_add_safe(const struct timespec lhs, |
80 | const struct timespec rhs); | 86 | const struct timespec rhs); |
81 | 87 | ||
88 | |||
89 | static inline struct timespec timespec_add(struct timespec lhs, | ||
90 | struct timespec rhs) | ||
91 | { | ||
92 | struct timespec ts_delta; | ||
93 | set_normalized_timespec(&ts_delta, lhs.tv_sec + rhs.tv_sec, | ||
94 | lhs.tv_nsec + rhs.tv_nsec); | ||
95 | return ts_delta; | ||
96 | } | ||
97 | |||
82 | /* | 98 | /* |
83 | * sub = lhs - rhs, in normalized form | 99 | * sub = lhs - rhs, in normalized form |
84 | */ | 100 | */ |
@@ -97,8 +113,6 @@ static inline struct timespec timespec_sub(struct timespec lhs, | |||
97 | #define timespec_valid(ts) \ | 113 | #define timespec_valid(ts) \ |
98 | (((ts)->tv_sec >= 0) && (((unsigned long) (ts)->tv_nsec) < NSEC_PER_SEC)) | 114 | (((ts)->tv_sec >= 0) && (((unsigned long) (ts)->tv_nsec) < NSEC_PER_SEC)) |
99 | 115 | ||
100 | extern struct timespec xtime; | ||
101 | extern struct timespec wall_to_monotonic; | ||
102 | extern seqlock_t xtime_lock; | 116 | extern seqlock_t xtime_lock; |
103 | 117 | ||
104 | extern void read_persistent_clock(struct timespec *ts); | 118 | extern void read_persistent_clock(struct timespec *ts); |
@@ -110,7 +124,8 @@ extern int timekeeping_suspended; | |||
110 | 124 | ||
111 | unsigned long get_seconds(void); | 125 | unsigned long get_seconds(void); |
112 | struct timespec current_kernel_time(void); | 126 | struct timespec current_kernel_time(void); |
113 | struct timespec __current_kernel_time(void); /* does not hold xtime_lock */ | 127 | struct timespec __current_kernel_time(void); /* does not take xtime_lock */ |
128 | struct timespec __get_wall_to_monotonic(void); /* does not take xtime_lock */ | ||
114 | struct timespec get_monotonic_coarse(void); | 129 | struct timespec get_monotonic_coarse(void); |
115 | 130 | ||
116 | #define CURRENT_TIME (current_kernel_time()) | 131 | #define CURRENT_TIME (current_kernel_time()) |
@@ -135,7 +150,7 @@ extern void do_gettimeofday(struct timeval *tv); | |||
135 | extern int do_settimeofday(struct timespec *tv); | 150 | extern int do_settimeofday(struct timespec *tv); |
136 | extern int do_sys_settimeofday(struct timespec *tv, struct timezone *tz); | 151 | extern int do_sys_settimeofday(struct timespec *tv, struct timezone *tz); |
137 | #define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) | 152 | #define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) |
138 | extern long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags); | 153 | extern long do_utimes(int dfd, const char __user *filename, struct timespec *times, int flags); |
139 | struct itimerval; | 154 | struct itimerval; |
140 | extern int do_setitimer(int which, struct itimerval *value, | 155 | extern int do_setitimer(int which, struct itimerval *value, |
141 | struct itimerval *ovalue); | 156 | struct itimerval *ovalue); |