diff options
-rw-r--r-- | include/linux/time.h | 17 | ||||
-rw-r--r-- | kernel/time/time.c | 20 |
2 files changed, 22 insertions, 15 deletions
diff --git a/include/linux/time.h b/include/linux/time.h index 8c42cf8d2444..203c2ad40d71 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
@@ -39,9 +39,20 @@ static inline int timeval_compare(const struct timeval *lhs, const struct timeva | |||
39 | return lhs->tv_usec - rhs->tv_usec; | 39 | return lhs->tv_usec - rhs->tv_usec; |
40 | } | 40 | } |
41 | 41 | ||
42 | extern unsigned long mktime(const unsigned int year, const unsigned int mon, | 42 | extern time64_t mktime64(const unsigned int year, const unsigned int mon, |
43 | const unsigned int day, const unsigned int hour, | 43 | const unsigned int day, const unsigned int hour, |
44 | const unsigned int min, const unsigned int sec); | 44 | const unsigned int min, const unsigned int sec); |
45 | |||
46 | /** | ||
47 | * Deprecated. Use mktime64(). | ||
48 | */ | ||
49 | static inline unsigned long mktime(const unsigned int year, | ||
50 | const unsigned int mon, const unsigned int day, | ||
51 | const unsigned int hour, const unsigned int min, | ||
52 | const unsigned int sec) | ||
53 | { | ||
54 | return mktime64(year, mon, day, hour, min, sec); | ||
55 | } | ||
45 | 56 | ||
46 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); | 57 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec); |
47 | 58 | ||
diff --git a/kernel/time/time.c b/kernel/time/time.c index a9ae20fb0b11..65015ff2f07c 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c | |||
@@ -304,7 +304,9 @@ struct timespec timespec_trunc(struct timespec t, unsigned gran) | |||
304 | } | 304 | } |
305 | EXPORT_SYMBOL(timespec_trunc); | 305 | EXPORT_SYMBOL(timespec_trunc); |
306 | 306 | ||
307 | /* Converts Gregorian date to seconds since 1970-01-01 00:00:00. | 307 | /* |
308 | * mktime64 - Converts date to seconds. | ||
309 | * Converts Gregorian date to seconds since 1970-01-01 00:00:00. | ||
308 | * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 | 310 | * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 |
309 | * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. | 311 | * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. |
310 | * | 312 | * |
@@ -314,15 +316,10 @@ EXPORT_SYMBOL(timespec_trunc); | |||
314 | * -year/100+year/400 terms, and add 10.] | 316 | * -year/100+year/400 terms, and add 10.] |
315 | * | 317 | * |
316 | * This algorithm was first published by Gauss (I think). | 318 | * This algorithm was first published by Gauss (I think). |
317 | * | ||
318 | * WARNING: this function will overflow on 2106-02-07 06:28:16 on | ||
319 | * machines where long is 32-bit! (However, as time_t is signed, we | ||
320 | * will already get problems at other places on 2038-01-19 03:14:08) | ||
321 | */ | 319 | */ |
322 | unsigned long | 320 | time64_t mktime64(const unsigned int year0, const unsigned int mon0, |
323 | mktime(const unsigned int year0, const unsigned int mon0, | 321 | const unsigned int day, const unsigned int hour, |
324 | const unsigned int day, const unsigned int hour, | 322 | const unsigned int min, const unsigned int sec) |
325 | const unsigned int min, const unsigned int sec) | ||
326 | { | 323 | { |
327 | unsigned int mon = mon0, year = year0; | 324 | unsigned int mon = mon0, year = year0; |
328 | 325 | ||
@@ -332,15 +329,14 @@ mktime(const unsigned int year0, const unsigned int mon0, | |||
332 | year -= 1; | 329 | year -= 1; |
333 | } | 330 | } |
334 | 331 | ||
335 | return ((((unsigned long) | 332 | return ((((time64_t) |
336 | (year/4 - year/100 + year/400 + 367*mon/12 + day) + | 333 | (year/4 - year/100 + year/400 + 367*mon/12 + day) + |
337 | year*365 - 719499 | 334 | year*365 - 719499 |
338 | )*24 + hour /* now have hours */ | 335 | )*24 + hour /* now have hours */ |
339 | )*60 + min /* now have minutes */ | 336 | )*60 + min /* now have minutes */ |
340 | )*60 + sec; /* finally seconds */ | 337 | )*60 + sec; /* finally seconds */ |
341 | } | 338 | } |
342 | 339 | EXPORT_SYMBOL(mktime64); | |
343 | EXPORT_SYMBOL(mktime); | ||
344 | 340 | ||
345 | /** | 341 | /** |
346 | * set_normalized_timespec - set timespec sec and nsec parts and normalize | 342 | * set_normalized_timespec - set timespec sec and nsec parts and normalize |