aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2006-01-09 23:52:22 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-10 11:01:35 -0500
commit753be6222728996974e9e12c185108fcabbb7c6e (patch)
treee7bce7ef8885919c2f0c11dbfe2e6d8c289096c3
parent67924be88607303a4459fe1c7dcd75527c338cf4 (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>
-rw-r--r--include/linux/time.h52
-rw-r--r--kernel/time.c61
2 files changed, 66 insertions, 47 deletions
diff --git a/include/linux/time.h b/include/linux/time.h
index 797ccd813bb..9c444d9c4aa 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -38,38 +38,9 @@ static __inline__ int timespec_equal(struct timespec *a, struct timespec *b)
38 return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec); 38 return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
39} 39}
40 40
41/* Converts Gregorian date to seconds since 1970-01-01 00:00:00. 41extern unsigned long mktime (unsigned int year, unsigned int mon,
42 * Assumes input in normal date format, i.e. 1980-12-31 23:59:59 42 unsigned int day, unsigned int hour,
43 * => year=1980, mon=12, day=31, hour=23, min=59, sec=59. 43 unsigned int min, unsigned int sec);
44 *
45 * [For the Julian calendar (which was used in Russia before 1917,
46 * Britain & colonies before 1752, anywhere else before 1582,
47 * and is still in use by some communities) leave out the
48 * -year/100+year/400 terms, and add 10.]
49 *
50 * This algorithm was first published by Gauss (I think).
51 *
52 * WARNING: this function will overflow on 2106-02-07 06:28:16 on
53 * machines were long is 32-bit! (However, as time_t is signed, we
54 * will already get problems at other places on 2038-01-19 03:14:08)
55 */
56static inline unsigned long
57mktime (unsigned int year, unsigned int mon,
58 unsigned int day, unsigned int hour,
59 unsigned int min, unsigned int sec)
60{
61 if (0 >= (int) (mon -= 2)) { /* 1..12 -> 11,12,1..10 */
62 mon += 12; /* Puts Feb last since it has leap day */
63 year -= 1;
64 }
65
66 return (((
67 (unsigned long) (year/4 - year/100 + year/400 + 367*mon/12 + day) +
68 year*365 - 719499
69 )*24 + hour /* now have hours */
70 )*60 + min /* now have minutes */
71 )*60 + sec; /* finally seconds */
72}
73 44
74extern struct timespec xtime; 45extern struct timespec xtime;
75extern struct timespec wall_to_monotonic; 46extern struct timespec wall_to_monotonic;
@@ -80,6 +51,8 @@ static inline unsigned long get_seconds(void)
80 return xtime.tv_sec; 51 return xtime.tv_sec;
81} 52}
82 53
54extern void set_normalized_timespec (struct timespec *ts, time_t sec, long nsec);
55
83struct timespec current_kernel_time(void); 56struct timespec current_kernel_time(void);
84 57
85#define CURRENT_TIME (current_kernel_time()) 58#define CURRENT_TIME (current_kernel_time())
@@ -99,21 +72,6 @@ extern void getnstimestamp(struct timespec *ts);
99 72
100extern struct timespec timespec_trunc(struct timespec t, unsigned gran); 73extern struct timespec timespec_trunc(struct timespec t, unsigned gran);
101 74
102static inline void
103set_normalized_timespec (struct timespec *ts, time_t sec, long nsec)
104{
105 while (nsec >= NSEC_PER_SEC) {
106 nsec -= NSEC_PER_SEC;
107 ++sec;
108 }
109 while (nsec < 0) {
110 nsec += NSEC_PER_SEC;
111 --sec;
112 }
113 ts->tv_sec = sec;
114 ts->tv_nsec = nsec;
115}
116
117#endif /* __KERNEL__ */ 75#endif /* __KERNEL__ */
118 76
119#define NFDBITS __NFDBITS 77#define NFDBITS __NFDBITS
diff --git a/kernel/time.c b/kernel/time.c
index b94bfa8c03e..fa569885e22 100644
--- a/kernel/time.c
+++ b/kernel/time.c
@@ -583,6 +583,67 @@ void getnstimestamp(struct timespec *ts)
583} 583}
584EXPORT_SYMBOL_GPL(getnstimestamp); 584EXPORT_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 */
601unsigned long
602mktime (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 */
633void 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)
587u64 get_jiffies_64(void) 648u64 get_jiffies_64(void)
588{ 649{