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 /include/linux | |
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 'include/linux')
-rw-r--r-- | include/linux/time.h | 52 |
1 files changed, 5 insertions, 47 deletions
diff --git a/include/linux/time.h b/include/linux/time.h index 797ccd813bb0..9c444d9c4aa0 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. | 41 | extern 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 | */ | ||
56 | static inline unsigned long | ||
57 | mktime (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 | ||
74 | extern struct timespec xtime; | 45 | extern struct timespec xtime; |
75 | extern struct timespec wall_to_monotonic; | 46 | extern 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 | ||
54 | extern void set_normalized_timespec (struct timespec *ts, time_t sec, long nsec); | ||
55 | |||
83 | struct timespec current_kernel_time(void); | 56 | struct 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 | ||
100 | extern struct timespec timespec_trunc(struct timespec t, unsigned gran); | 73 | extern struct timespec timespec_trunc(struct timespec t, unsigned gran); |
101 | 74 | ||
102 | static inline void | ||
103 | set_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 |