diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2006-01-09 23:52:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-10 11:01:35 -0500 |
commit | 753be6222728996974e9e12c185108fcabbb7c6e (patch) | |
tree | e7bce7ef8885919c2f0c11dbfe2e6d8c289096c3 /kernel/time.c | |
parent | 67924be88607303a4459fe1c7dcd75527c338cf4 (diff) |
[PATCH] hrtimer: deinline mktime and set_normalized_timespec
mktime() and set_normalized_timespec() are large inline functions used in many
places: deinline them.
From: George Anzinger, off-by-1 bugfix
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/time.c')
-rw-r--r-- | kernel/time.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/kernel/time.c b/kernel/time.c index b94bfa8c03e0..fa569885e22b 100644 --- a/kernel/time.c +++ b/kernel/time.c | |||
@@ -583,6 +583,67 @@ void getnstimestamp(struct timespec *ts) | |||
583 | } | 583 | } |
584 | EXPORT_SYMBOL_GPL(getnstimestamp); | 584 | EXPORT_SYMBOL_GPL(getnstimestamp); |
585 | 585 | ||
586 | /* Converts Gregorian date to seconds since 1970-01-01 00:00:00. | ||
587 | * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 | ||
588 | * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. | ||
589 | * | ||
590 | * [For the Julian calendar (which was used in Russia before 1917, | ||
591 | * Britain & colonies before 1752, anywhere else before 1582, | ||
592 | * and is still in use by some communities) leave out the | ||
593 | * -year/100+year/400 terms, and add 10.] | ||
594 | * | ||
595 | * This algorithm was first published by Gauss (I think). | ||
596 | * | ||
597 | * WARNING: this function will overflow on 2106-02-07 06:28:16 on | ||
598 | * machines were long is 32-bit! (However, as time_t is signed, we | ||
599 | * will already get problems at other places on 2038-01-19 03:14:08) | ||
600 | */ | ||
601 | unsigned long | ||
602 | mktime (unsigned int year, unsigned int mon, | ||
603 | unsigned int day, unsigned int hour, | ||
604 | unsigned int min, unsigned int sec) | ||
605 | { | ||
606 | if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */ | ||
607 | mon += 12; /* Puts Feb last since it has leap day */ | ||
608 | year -= 1; | ||
609 | } | ||
610 | |||
611 | return ((((unsigned long) | ||
612 | (year/4 - year/100 + year/400 + 367*mon/12 + day) + | ||
613 | year*365 - 719499 | ||
614 | )*24 + hour /* now have hours */ | ||
615 | )*60 + min /* now have minutes */ | ||
616 | )*60 + sec; /* finally seconds */ | ||
617 | } | ||
618 | |||
619 | /** | ||
620 | * set_normalized_timespec - set timespec sec and nsec parts and normalize | ||
621 | * | ||
622 | * @ts: pointer to timespec variable to be set | ||
623 | * @sec: seconds to set | ||
624 | * @nsec: nanoseconds to set | ||
625 | * | ||
626 | * Set seconds and nanoseconds field of a timespec variable and | ||
627 | * normalize to the timespec storage format | ||
628 | * | ||
629 | * Note: The tv_nsec part is always in the range of | ||
630 | * 0 <= tv_nsec < NSEC_PER_SEC | ||
631 | * For negative values only the tv_sec field is negative ! | ||
632 | */ | ||
633 | void set_normalized_timespec (struct timespec *ts, time_t sec, long nsec) | ||
634 | { | ||
635 | while (nsec >= NSEC_PER_SEC) { | ||
636 | nsec -= NSEC_PER_SEC; | ||
637 | ++sec; | ||
638 | } | ||
639 | while (nsec < 0) { | ||
640 | nsec += NSEC_PER_SEC; | ||
641 | --sec; | ||
642 | } | ||
643 | ts->tv_sec = sec; | ||
644 | ts->tv_nsec = nsec; | ||
645 | } | ||
646 | |||
586 | #if (BITS_PER_LONG < 64) | 647 | #if (BITS_PER_LONG < 64) |
587 | u64 get_jiffies_64(void) | 648 | u64 get_jiffies_64(void) |
588 | { | 649 | { |